List of usage examples for org.apache.maven.project MavenProject getArtifact
public Artifact getArtifact()
From source file:com.github.ferstl.depgraph.dependency.AggregatingGraphFactory.java
License:Apache License
private boolean isPartOfGraph(MavenProject project) { boolean isIncluded = this.globalFilter.include(project.getArtifact()); // Project is not filtered and is a parent project if (isIncluded && project.getModules().size() > 0) { return this.includeParentProjects; }/*from w w w . ja va 2s .co m*/ return isIncluded; }
From source file:com.github.ferstl.depgraph.dependency.AggregatingGraphFactory.java
License:Apache License
private DependencyNode filterProject(MavenProject project) { Artifact artifact = project.getArtifact(); if (this.globalFilter.include(artifact)) { return new DependencyNode(artifact); }/*ww w.j av a2s . com*/ return null; }
From source file:com.github.ferstl.depgraph.dependency.SimpleGraphFactory.java
License:Apache License
@Override public String createGraph(MavenProject project) { this.graphBuilder.graphName(project.getArtifactId()); this.mavenGraphAdapter.buildDependencyGraph(project, this.globalFilter, this.graphBuilder); // Add the project as single node if the graph is empty Artifact artifact = project.getArtifact(); if (this.graphBuilder.isEmpty() && this.globalFilter.include(artifact)) { this.graphBuilder.addNode(new DependencyNode(artifact)); }/*from w w w . j a v a 2s . c om*/ return this.graphBuilder.toString(); }
From source file:com.github.ferstl.depgraph.graph.AggregatingGraphFactory.java
License:Apache License
private boolean isPartOfGraph(MavenProject project) { boolean result = this.globalFilter.include(project.getArtifact()); // Project is not filtered and is a parent project if (result && project.getModules().size() > 0) { result = result && this.includeParentProjects; }//from w w w .j av a 2s .c o m return result; }
From source file:com.github.ferstl.depgraph.graph.AggregatingGraphFactory.java
License:Apache License
private GraphNode filterProject(MavenProject project) { Artifact artifact = project.getArtifact(); if (this.globalFilter.include(artifact)) { return new GraphNode(artifact); }/*from w w w. ja v a 2s . c o m*/ return null; }
From source file:com.github.jeluard.maven.ParentEnforcerRule.java
License:Apache License
@Override public void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException { final MavenProject project; try {/* ww w. j a va 2 s . c o m*/ project = (MavenProject) helper.evaluate("${project}"); } catch (ExpressionEvaluationException e) { throw new EnforcerRuleException("Failed to access ${project} variable", e); } final String type = project.getArtifact().getType(); if (!ParentEnforcerRule.POM_ARTIFACT_TYPE.equals(type)) { helper.getLog().debug("Skipping non " + ParentEnforcerRule.POM_ARTIFACT_TYPE + " artifact."); return; } final Parent parent = new Parent(); parent.setGroupId(project.getGroupId()); parent.setArtifactId(project.getArtifactId()); parent.setVersion(project.getVersion()); try { validateSubModules(extractRootFolder(project), project.getModel(), parent); } catch (IOException e) { throw new EnforcerRuleException("Failed to process one of project's module", e); } }
From source file:com.github.lucapino.manifest.ManifestMojo.java
License:Apache License
public Set<Artifact> getDependencyArtifacts(MavenProject project, RepositorySystemSession repoSession, ProjectDependenciesResolver projectDependenciesResolver) throws MojoExecutionException { DefaultDependencyResolutionRequest dependencyResolutionRequest = new DefaultDependencyResolutionRequest( project, repoSession);/*w ww. j av a 2s. c om*/ DependencyResolutionResult dependencyResolutionResult; try { dependencyResolutionResult = projectDependenciesResolver.resolve(dependencyResolutionRequest); } catch (DependencyResolutionException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } Set artifacts = new LinkedHashSet(); if (dependencyResolutionResult.getDependencyGraph() != null && !dependencyResolutionResult.getDependencyGraph().getChildren().isEmpty()) { RepositoryUtils.toArtifacts(artifacts, dependencyResolutionResult.getDependencyGraph().getChildren(), Collections.singletonList(project.getArtifact().getId()), null); } return artifacts; }
From source file:com.github.panthers.maven.plugins.AbstractDependencyMojo.java
License:Apache License
/** * Checks to see if the specified artifact is available from the reactor. *//ww w .j a v a 2s . co m * @param artifact The artifact we are looking for. * @return The resolved artifact that is the same as the one we were looking for or <code>null</code> if one could * not be found. */ @SuppressWarnings("unchecked") private Artifact getArtifactFomReactor(Artifact artifact) { // check project dependencies first off for (Artifact a : (Set<Artifact>) project.getArtifacts()) { if (equals(artifact, a) && hasFile(a)) { return a; } } // check reactor projects for (MavenProject p : reactorProjects == null ? Collections.<MavenProject>emptyList() : reactorProjects) { // check the main artifact if (equals(artifact, p.getArtifact()) && hasFile(p.getArtifact())) { return p.getArtifact(); } // check any side artifacts for (Artifact a : (List<Artifact>) p.getAttachedArtifacts()) { if (equals(artifact, a) && hasFile(a)) { return a; } } } // not available return null; }
From source file:com.github.signed.sandboxes.maven.MyMojo.java
private MavenProject buildProjectFrom(Artifact artifact) { try {//from www. j a v a2 s . com MavenProject depMavenProject = mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository, true); depMavenProject.getArtifact().setScope(artifact.getScope()); return depMavenProject; } catch (ProjectBuildingException e) { throw new RuntimeException(e); } }
From source file:com.github.wix_maven.AbstractWixMojo.java
License:Apache License
/** * Copied from Maven-dependency-plugin Checks to see if the specified artifact is available from the reactor. * //from w ww . j a v a 2 s .c o m * @param artifact * The artifact we are looking for. * @return The resolved artifact that is the same as the one we were looking for or <code>null</code> if one could not be found. */ private Artifact getArtifactFomReactor(Artifact artifact) { // check project dependencies first off for (Artifact a : (Set<Artifact>) project.getArtifacts()) { if (equals(artifact, a) && hasFile(a)) { return a; } } // check reactor projects for (MavenProject p : reactorProjects == null ? Collections.<MavenProject>emptyList() : reactorProjects) { // check the main artifact if (equals(artifact, p.getArtifact()) && hasFile(p.getArtifact())) { return p.getArtifact(); } // check any side artifacts for (Artifact a : (List<Artifact>) p.getAttachedArtifacts()) { if (equals(artifact, a) && hasFile(a)) { return a; } } } // not available return null; }