Java Code Examples for org.apache.maven.model.Parent

The following examples show how to use org.apache.maven.model.Parent. These examples are extracted from open source projects. 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 Project: helidon-build-tools   Source File: CommandRequirements.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Require that a valid Maven project configuration exists.
 *
 * @param commonOptions The options.
 */
static void requireValidMavenProjectConfig(CommonOptions commonOptions) {
    try {
        Path projectDir = commonOptions.project();
        Path pomFile = PomUtils.toPomFile(projectDir);
        Path projectConfigFile = ProjectConfig.toDotHelidon(projectDir);
        if (!Files.exists(projectConfigFile)) {
            // Find the helidon version if we can and create the config file
            Model model = PomUtils.readPomModel(pomFile);
            Parent parent = model.getParent();
            String helidonVersion = null;
            if (parent != null && parent.getGroupId().startsWith("io.helidon.")) {
                helidonVersion = parent.getVersion();
            }
            ensureProjectConfig(projectDir, helidonVersion);
        }
    } catch (IllegalArgumentException e) {
        String message = e.getMessage();
        if (message.contains("does not exist")) {
            message = NOT_A_PROJECT_DIR;
        }
        Requirements.failed(message);
    }
}
 
Example 2
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 3
private static String getVersion(Model model) {
    if (model == null) {
        return null;
    }
    String version = model.getVersion();
    if (version != null) {
        return version;
    }
    final Parent parent = model.getParent();
    if (parent != null) {
        version = parent.getVersion();
        if (version != null) {
            return version;
        }
    }
    throw new IllegalStateException("Failed to determine the version for the POM of " + model.getArtifactId());
}
 
Example 4
Source Project: quarkus   Source File: LocalProject.java    License: Apache License 2.0 6 votes vote down vote up
private static Model loadRootModel(Path pomXml) throws BootstrapMavenException {
    Model model = null;
    while (pomXml != null && Files.exists(pomXml)) {
        model = readModel(pomXml);
        final Parent parent = model.getParent();
        if (parent != null
                && parent.getRelativePath() != null
                && !parent.getRelativePath().isEmpty()) {
            pomXml = pomXml.getParent().resolve(parent.getRelativePath()).normalize();
            if (Files.isDirectory(pomXml)) {
                pomXml = pomXml.resolve(POM_XML);
            }
        } else {
            final Path parentDir = pomXml.getParent().getParent();
            pomXml = parentDir == null ? null : parentDir.resolve(POM_XML);
        }
    }
    return model;
}
 
Example 5
Source Project: quarkus   Source File: MvnProjectBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public MvnProjectBuilder addModule(String path, String artifactId, boolean initParent) {
    model.addModule(path);
    final MvnProjectBuilder module = new MvnProjectBuilder(artifactId, this);
    if (initParent) {
        final Parent parentModel = new Parent();
        module.model.setParent(parentModel);
        parentModel.setGroupId(model.getGroupId());
        parentModel.setArtifactId(model.getArtifactId());
        parentModel.setVersion(model.getVersion());
        final Path rootDir = Paths.get("").toAbsolutePath();
        final Path moduleDir = rootDir.resolve(path).normalize();
        if (!moduleDir.getParent().equals(rootDir)) {
            parentModel.setRelativePath(moduleDir.relativize(rootDir).toString());
        }
    }
    modules.add(module);
    return module;
}
 
Example 6
Source Project: cyclonedx-gradle-plugin   Source File: MavenHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the parent pom for an artifact (if any). The parent pom may contain license,
 * description, and other metadata whereas the artifact itself may not.
 * @param artifact the artifact to retrieve the parent pom for
 * @param project the maven project the artifact is part of
 */
private MavenProject retrieveParentProject(ResolvedArtifact artifact, MavenProject project) {
    if (artifact.getFile() == null || artifact.getFile().getParentFile() == null || !isDescribedArtifact(artifact)) {
        return null;
    }
    final Model model = project.getModel();
    if (model.getParent() != null) {
        final Parent parent = model.getParent();
        // Navigate out of version, artifactId, and first (possibly only) level of groupId
        final StringBuilder getout = new StringBuilder("../../../");
        final ModuleVersionIdentifier mid = artifact.getModuleVersion().getId();
        final int periods = mid.getGroup().length() - mid.getGroup().replace(".", "").length();
        for (int i= 0; i< periods; i++) {
            getout.append("../");
        }
        final File parentFile = new File(artifact.getFile().getParentFile(), getout + parent.getGroupId().replace(".", "/") + "/" + parent.getArtifactId() + "/" + parent.getVersion() + "/" + parent.getArtifactId() + "-" + parent.getVersion() + ".pom");
        if (parentFile.exists() && parentFile.isFile()) {
            try {
                return readPom(parentFile.getCanonicalFile());
            } catch (Exception e) {
                logger.error("An error occurred retrieving an artifacts parent pom", e);
            }
        }
    }
    return null;
}
 
Example 7
Source Project: netbeans   Source File: LocationAwareMavenXpp3Writer.java    License: 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 8
Source Project: cyclonedx-maven-plugin   Source File: BaseCycloneDxMojo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the parent pom for an artifact (if any). The parent pom may contain license,
 * description, and other metadata whereas the artifact itself may not.
 * @param artifact the artifact to retrieve the parent pom for
 * @param project the maven project the artifact is part of
 */
private MavenProject retrieveParentProject(final Artifact artifact, final MavenProject project) {
    if (artifact.getFile() == null || artifact.getFile().getParentFile() == null || !isDescribedArtifact(artifact)) {
        return null;
    }
    final Model model = project.getModel();
    if (model.getParent() != null) {
        final Parent parent = model.getParent();
        // Navigate out of version, artifactId, and first (possibly only) level of groupId
        final StringBuilder getout = new StringBuilder("../../../");
        final int periods = artifact.getGroupId().length() - artifact.getGroupId().replace(".", "").length();
        for (int i= 0; i< periods; i++) {
            getout.append("../");
        }
        final File parentFile = new File(artifact.getFile().getParentFile(), getout + parent.getGroupId().replace(".", "/") + "/" + parent.getArtifactId() + "/" + parent.getVersion() + "/" + parent.getArtifactId() + "-" + parent.getVersion() + ".pom");
        if (parentFile.exists() && parentFile.isFile()) {
            try {
                return readPom(parentFile.getCanonicalFile());
            } catch (Exception e) {
                getLog().error("An error occurred retrieving an artifacts parent pom", e);
            }
        }
    }
    return null;
}
 
Example 9
Source Project: fabric8-forge   Source File: SetupProjectHelper.java    License: 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 10
private void setParentVersion(MavenProject project, Document document) {
  Parent parent = project.getModel().getParent();
  if (parent != null) {
    Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata
        .getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
    ArtifactCoordinates oldCoordinates = coordinatesByPhase.get(previousReleasePhase());
    ArtifactCoordinates newCoordinates = coordinatesByPhase.get(currentReleasePhase());

    // null indicates that the parent is not part of the reactor projects since no release version had been calculated
    // for it
    if (newCoordinates != null) {
      logParentVersionUpdate(project, oldCoordinates, newCoordinates);
      PomUtil.setParentVersion(project.getModel(), document, newCoordinates.getVersion());
    }
  }
}
 
Example 11
Source Project: unleash-maven-plugin   Source File: PomUtil.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Changes the project's parent version of the POM as well as directly in the XML document preserving the whole
 * document formatting.
 *
 * @param model the POM where to adapt the project's parent version.
 * @param document the POM as an XML document in which the project's parent version shall be adapted.
 * @param newParentVersion the new version to set for the project parent.
 */
public static void setParentVersion(Model model, Document document, String newParentVersion) {
  Preconditions.checkArgument(hasChildNode(document, NODE_NAME_PROJECT),
      "The document doesn't seem to be a POM model, project element is missing.");

  // first step: update parent version of the in-memory model
  Parent parent = model.getParent();
  if (parent != null) {
    parent.setVersion(newParentVersion);
  }

  // second step: update the parent version in the DOM document that will be serialized for later building
  Node parentNode = document.getDocumentElement().getElementsByTagName(PomUtil.NODE_NAME_PARENT).item(0);
  if (parentNode != null) {
    NodeList children = parentNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (Objects.equal(child.getNodeName(), PomUtil.NODE_NAME_VERSION)) {
        child.setTextContent(newParentVersion);
      }
    }
  }
}
 
Example 12
Source Project: maven-git-versioning-extension   Source File: GAV.java    License: 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 13
Source Project: maven-git-versioning-extension   Source File: GAVTest.java    License: MIT License 6 votes vote down vote up
@Test
void of_model_withParent_noInheritance() {
    // Given
    Model model = new Model();
    model.setGroupId("group");
    model.setArtifactId("artifact");
    model.setVersion("version");

    Parent parent = new Parent();
    parent.setGroupId("parentGroup");
    parent.setArtifactId("parentArtifact");
    parent.setVersion("parentVersion");
    model.setParent(parent);

    // When
    GAV gav = GAV.of(model);

    // Then
    assertThat(gav).isNotNull();
    assertThat(gav.getGroupId()).isEqualTo("group");
    assertThat(gav.getArtifactId()).isEqualTo("artifact");
    assertThat(gav.getVersion()).isEqualTo("version");
}
 
Example 14
Source Project: maven-git-versioning-extension   Source File: GAVTest.java    License: MIT License 6 votes vote down vote up
@Test
void of_model_withParent_withInheritance() {
    // Given
    Model model = new Model();
    model.setArtifactId("artifact");

    Parent parent = new Parent();
    parent.setGroupId("parentGroup");
    parent.setArtifactId("parentArtifact");
    parent.setVersion("parentVersion");
    model.setParent(parent);

    // When
    GAV gav = GAV.of(model);

    // Then
    assertThat(gav).isNotNull();
    assertThat(gav.getGroupId()).isEqualTo("parentGroup");
    assertThat(gav.getArtifactId()).isEqualTo("artifact");
    assertThat(gav.getVersion()).isEqualTo("parentVersion");
}
 
Example 15
Source Project: flatten-maven-plugin   Source File: FlattenModelResolver.java    License: 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 16
Source Project: versions-maven-plugin   Source File: PomHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns all the models that have a specified groupId and artifactId as parent.
 *
 * @param reactor The map of models keyed by path.
 * @param groupId The groupId of the parent.
 * @param artifactId The artifactId of the parent.
 * @return a map of models that have a specified groupId and artifactId as parent keyed by path.
 */
public static Map<String, Model> getChildModels( Map<String, Model> reactor, String groupId, String artifactId )
{
    final Map<String, Model> result = new LinkedHashMap<String, Model>();
    for ( Map.Entry<String, Model> entry : reactor.entrySet() )
    {
        final String path = entry.getKey();
        final Model model = entry.getValue();
        final Parent parent = model.getParent();
        if ( parent != null && groupId.equals( parent.getGroupId() )
            && artifactId.equals( parent.getArtifactId() ) )
        {
            result.put( path, model );
        }
    }
    return result;
}
 
Example 17
@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 18
Source Project: msf4j   Source File: MSF4JProjectImporter.java    License: Apache License 2.0 6 votes vote down vote up
private void saveMavenParentInfo(MavenProjectInfo projectInfo) throws IOException, XmlPullParserException {
	File mavenProjectPomLocation = projectInfo.getPomFile();// project.getFile(POM_FILE).getLocation().toFile();
	MavenProject mavenProject = null;
	mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
	Parent msf4jParent = new Parent();
	msf4jParent.setGroupId(MSF4J_SERVICE_PARENT_GROUP_ID);
	msf4jParent.setArtifactId(MSF4J_SERVICE_PARENT_ARTIFACT_ID);
	msf4jParent.setVersion(MSF4JArtifactConstants.getMSF4JServiceParentVersion());
	mavenProject.getModel().setParent(msf4jParent);

	Properties generatedProperties = mavenProject.getModel().getProperties();
	generatedProperties.clear();

	mavenProject.getModel().addProperty(MSF4J_MAIN_CLASS_PROPERTY, DEFAULT_MAIN_CLASS_PROPERTY_VALUE);
	MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}
 
Example 19
private void fixParentProject(IProject p, IProject parentProject)
		throws CoreException {
	IFile existingPom = p.getFile("pom.xml");
	Model model = MavenPlugin.getMavenModelManager().readMavenModel(existingPom);
	Model parent = MavenPlugin.getMavenModelManager().readMavenModel(parentProject.getFile("pom.xml"));
	//Parent oldParent = model.getParent();
	Parent newParent = new Parent();
	newParent.setGroupId(parent.getGroupId());
	newParent.setArtifactId(parent.getArtifactId());
	newParent.setRelativePath(calculateRelativePath(p, parentProject));
	newParent.setVersion(parent.getVersion());
	model.setParent(newParent);
	// outright deletion doesn't work on windows as the process has a ref to the file itself
	// so creating a temp '_newpom_.xml'
	final IFile newPom = p.getFile("_newpom_.xml");
	MavenPlugin.getMavenModelManager().createMavenModel(newPom, model);
	// then copying that content over to the pom.xml
	existingPom.setContents(newPom.getContents(), true,  true, new NullProgressMonitor());
	// and deleting the temp pom
	newPom.delete(true,  false, new NullProgressMonitor());
	
}
 
Example 20
Source Project: developer-studio   Source File: MavenDetailsPage.java    License: Apache License 2.0 6 votes vote down vote up
private void setParentMavenInfo(Parent info) {
	if (info != null) {
		setParentProjectName(info.getArtifactId());
		setParentGroupID(info.getGroupId());
		setParentArtifactID(info.getArtifactId());
		setParentVersion(info.getVersion());
		setParentRelativePath(info.getRelativePath());
		txtParentArtifactId.setText(getParentArtifactID());
		txtParentGroupId.setText(getParentGroupID());
		txtParentVersion.setText(getParentVersion());
		String parentRelativePath2 = getParentRelativePath();
		if (hasParentProject && parentRelativePath2 != null) {
			txtRelativePath.setText(parentRelativePath2);
		} else {
			txtRelativePath.setText("");
		}
	}

}
 
Example 21
Source Project: pom-manipulation-ext   Source File: ParentInjectionState.java    License: Apache License 2.0 6 votes vote down vote up
public void initialise( Properties userProps )
{
    final String gav = userProps.getProperty( PARENT_INJECTION_PROPERTY );

    if ( gav != null )
    {
        ProjectVersionRef ref = SimpleProjectVersionRef.parse( gav );
        parent = new Parent();
        parent.setGroupId( ref.getGroupId() );
        parent.setArtifactId( ref.getArtifactId() );
        parent.setVersion( ref.getVersionString() );
        parent.setRelativePath( "" );
    }
    else
    {
        parent = null;
    }
}
 
Example 22
Source Project: LicenseScout   Source File: ArtifactServerUtil.java    License: Apache License 2.0 5 votes vote down vote up
private boolean processParentLicenses(final Archive archive, final String filePath,
                                      final LicenseStoreData licenseStoreData, final Parent parent,
                                      InputStream parentInputStream)
        throws IOException {
    boolean licenseFoundLocal = false;
    if (parentInputStream != null) {
        try {
            final String newFilePath = filePath + "![parent POM](" + parent.getId() + ")";
            licenseFoundLocal = addLicensesFromPom(parentInputStream, archive, newFilePath, licenseStoreData);
        } finally {
            parentInputStream.close();
        }
    }
    return licenseFoundLocal;
}
 
Example 23
Source Project: LicenseScout   Source File: ArtifactServerUtil.java    License: 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 24
Source Project: quarkus   Source File: ModelUtils.java    License: 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 25
Source Project: quarkus   Source File: ModelUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the raw version of the model. If the model does not include
 * the version directly, it will return the version of the parent.
 * The version is raw in a sense if it's a property expression, the
 * expression will not be resolved.
 *
 * @param model POM
 * @return raw model
 */
public static String getRawVersion(Model model) {
    String version = model.getVersion();
    if (version != null) {
        return version;
    }
    final Parent parent = model.getParent();
    if (parent != null) {
        version = parent.getVersion();
        if (version != null) {
            return version;
        }
    }
    throw new IllegalStateException("Failed to determine version for project model");
}
 
Example 26
Source Project: butterfly   Source File: PomGetParent.java    License: MIT License 5 votes vote down vote up
@Override
protected TUExecutionResult pomExecution(Model model) {
    Parent parent = model.getParent();
    if (parent == null) {
        return TUExecutionResult.nullResult(this, "Specified Maven artifact does not have a parent");
    }

    String parentCoordinates = String.format("%s:%s:%s", parent.getGroupId(), parent.getArtifactId(), parent.getVersion());

    return TUExecutionResult.value(this, parentCoordinates);
}
 
Example 27
Source Project: butterfly   Source File: PomChangeParent.java    License: MIT License 5 votes vote down vote up
@Override
protected TOExecutionResult pomExecution(String relativePomFile, Model model) {
    String details;
    Parent parent = model.getParent();

    if (parent == null) {
        String message = String.format("Pom file %s does not have a parent", getRelativePath());

        switch (ifNotPresent) {
            case Warn:
                return TOExecutionResult.warning(this, new TransformationOperationException(message));
            case NoOp:
                return TOExecutionResult.noOp(this, message);
            case Fail:
                // Fail is the default
            default:
                return TOExecutionResult.error(this, new TransformationOperationException(message));
        }
    }

    if(groupId != null && artifactId != null && version != null) {
        parent.setGroupId(groupId);
        parent.setArtifactId(artifactId);
        parent.setVersion(version);
        String newParent = parent.toString();
        details = String.format("Parent for POM file (%s) has been set to %s", relativePomFile, newParent);
    } else if (groupId == null && artifactId == null && version != null) {
        String oldVersion = parent.getVersion();
        parent.setVersion(version);
        details = String.format("Parent's version for POM file (%s) has been changed from %s to %s", relativePomFile, oldVersion, version);
    } else {
        // FIXME this should be in a pre-validation
        return TOExecutionResult.error(this, new TransformationOperationException("Invalid POM parent transformation operation"));
    }

    return TOExecutionResult.success(this, details);
}
 
Example 28
Source Project: neoscada   Source File: AbstractSetQualifierMojo.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void checkNonRelativeParent ( final MavenProject project )
{
    if ( project.getModel ().getParent () == null )
    {
        // no parent
        return;
    }

    if ( project.getParentFile () != null )
    {
        // is a local parent
        return;
    }

    final Parent parent = project.getModel ().getParent ();

    final String prefix = String.format ( "%s:%s:", parent.getGroupId (), parent.getArtifactId () );
    for ( final String entry : this.forceUpdateParentQualifiers )
    {
        if ( entry.startsWith ( prefix ) )
        {
            final String qualifier = entry.substring ( prefix.length () );
            final String newVersion = makeVersion ( parent.getVersion (), qualifier );

            getLog ().info ( String.format ( "Force update parent of %s to %s -> %s", project.getId (), parent.getId (), newVersion ) );

            addChange ( project.getFile (), new ModelModifier () {

                @Override
                public boolean apply ( final Model model )
                {
                    model.getParent ().setVersion ( newVersion );
                    return true;
                }
            } );
        }
    }
}
 
Example 29
Source Project: sonarqube-licensecheck   Source File: LicenseFinder.java    License: 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 30
Source Project: maven-git-versioning-extension   Source File: GAV.java    License: 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);
    }