Java Code Examples for org.apache.maven.model.Parent#getGroupId()

The following examples show how to use org.apache.maven.model.Parent#getGroupId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuarkusJsonPlatformDescriptorResolver.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static String getGroupId(Model model) {
    if (model == null) {
        return null;
    }
    String groupId = model.getGroupId();
    if (groupId != null) {
        return groupId;
    }
    final Parent parent = model.getParent();
    if (parent != null) {
        groupId = parent.getGroupId();
        if (groupId != null) {
            return groupId;
        }
    }
    throw new IllegalStateException("Failed to determine the groupId for the POM of " + model.getArtifactId());
}
 
Example 2
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void writeParent(Parent parent, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (parent.getGroupId() != null) {
        writeValue(serializer, "groupId", parent.getGroupId(), parent);
    }
    if (parent.getArtifactId() != null) {
        writeValue(serializer, "artifactId", parent.getArtifactId(), parent);
    }
    if (parent.getVersion() != null) {
        writeValue(serializer, "version", parent.getVersion(), parent);
    }
    if ((parent.getRelativePath() != null) && !parent.getRelativePath().equals("../pom.xml")) {
        writeValue(serializer, "relativePath", parent.getRelativePath(), parent);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(parent, "", start, b.length());
}
 
Example 3
Source File: SetupProjectHelper.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
@Deprecated
public static boolean isFunktionParentPom(Project project) {
    MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
    if (mavenFacet != null) {
        Model model = mavenFacet.getModel();
        if (model != null) {
            Parent parent = model.getParent();
            if (parent != null) {
                String groupId = parent.getGroupId();
                if (groupId != null && groupId.startsWith("io.fabric8.funktion")) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 4
Source File: GAV.java    From maven-git-versioning-extension with MIT License 6 votes vote down vote up
public static GAV of(Model model) {

        String groupId = model.getGroupId();
        String artifactId = model.getArtifactId();
        String version = model.getVersion();

        Parent parent = model.getParent();
        if (parent != null) {
            if (groupId == null) {
                groupId = parent.getGroupId();
            }
            if (version == null) {
                version = parent.getVersion();
            }
        }

        return new GAV(groupId, artifactId, version);
    }
 
Example 5
Source File: FlattenModelResolver.java    From flatten-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Resolves the POM for the specified parent.
 *
 * @param parent the parent coordinates to resolve, must not be {@code null}
 * @return The source of the requested POM, never {@code null}
 * @since Apache-Maven-3.2.2 (MNG-5639)
 */
public ModelSource resolveModel( Parent parent )
    throws UnresolvableModelException
{

    String groupId = parent.getGroupId();
    String artifactId = parent.getArtifactId();
    String version = parent.getVersion();

    // resolve version range (if present)
    if ( isRestrictedVersionRange( version, groupId, artifactId ) )
    {
        version = resolveParentVersionRange( groupId, artifactId, version );
    }

    return resolveModel( groupId, artifactId, version );
}
 
Example 6
Source File: ParentPOMPropagatingArtifactDescriptorReaderDelegate.java    From mvn2nix-maven-plugin with MIT License 6 votes vote down vote up
@Override
public void populateResult(RepositorySystemSession session,
	ArtifactDescriptorResult result,
	Model model) {
	super.populateResult(session, result, model);
	Parent parent = model.getParent();
	if (parent != null) {
		DefaultArtifact art =
			new DefaultArtifact(parent.getGroupId(),
				parent.getArtifactId(),
				"pom",
				parent.getVersion());
		Dependency dep = new Dependency(art, "compile");
		result.addDependency(dep);
	}
}
 
Example 7
Source File: ArtifactServerUtil.java    From LicenseScout with Apache License 2.0 5 votes vote down vote up
private URL getParentUrl(final Parent parent) throws MalformedURLException {
    final String groupId = parent.getGroupId();
    final String artifactId = parent.getArtifactId();
    final String version = parent.getVersion();
    final String urlString = getArtifactUrlString(groupId, artifactId, version);
    return new URL(urlString);
}
 
Example 8
Source File: ModelUtils.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public static String getGroupId(Model model) {
    String groupId = model.getGroupId();
    if (groupId != null) {
        return groupId;
    }
    final Parent parent = model.getParent();
    if (parent != null) {
        groupId = parent.getGroupId();
        if (groupId != null) {
            return groupId;
        }
    }
    throw new IllegalStateException("Failed to determine groupId for project model");
}
 
Example 9
Source File: LicenseFinder.java    From sonarqube-licensecheck with Apache License 2.0 5 votes vote down vote up
public static List<License> getLicenses(File filePath, String userSettings, String globalSettings)
{
    try
    {
        Model model = new MavenXpp3Reader().read(new FileInputStream(filePath));

        if (!model.getLicenses().isEmpty())
        {
            return model.getLicenses();
        }
        else
        {
            if (model.getParent() != null)
            {
                Parent parent = model.getParent();
                Dependency dependency =
                    new Dependency(parent.getGroupId() + ":" + parent.getArtifactId(), parent.getVersion(), null);
                return getLicenses(DirectoryFinder.getPomPath(dependency,
                    DirectoryFinder.getMavenRepsitoryDir(userSettings, globalSettings)),
                    userSettings, globalSettings);
            }
            else
            {
                return Collections.emptyList();
            }
        }

    }
    catch (Exception e)
    {
        LOGGER.warn("Could not parse Maven POM " + filePath, e);
        return Collections.emptyList();
    }
}
 
Example 10
Source File: GAV.java    From maven-git-versioning-extension with MIT License 5 votes vote down vote up
public static GAV of(Parent parent) {

        String groupId = parent.getGroupId();
        String artifactId = parent.getArtifactId();
        String version = parent.getVersion();

        return new GAV(groupId, artifactId, version);
    }