List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:org.codehaus.mojo.webstart.util.DefaultArtifactUtil.java
License:Apache License
/** * {@inheritDoc}// www . j av a 2s .c o m */ public MavenProject resolveFromReactor(Artifact artifact, MavenProject mp, List<MavenProject> reactorProjects) throws MojoExecutionException { MavenProject result = null; String artifactId = artifact.getArtifactId(); String groupId = artifact.getGroupId(); if (CollectionUtils.isNotEmpty(reactorProjects)) { for (MavenProject reactorProject : reactorProjects) { if (reactorProject.getArtifactId().equals(artifactId) && reactorProject.getGroupId().equals(groupId)) { result = reactorProject; break; } } } return result; }
From source file:org.commonjava.emb.project.graph.DepGraphRootNode.java
License:Open Source License
public DepGraphRootNode(final DependencyNode node, final MavenProject project) { super(node, ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion()), true); this.project = project; }
From source file:org.commonjava.emb.project.ProjectLoader.java
License:Apache License
private void addProjects(final ProjectToolsSession session, final List<MavenProject> projects) { final DependencyGraph depGraph = session.getDependencyGraph(); for (final MavenProject project : projects) { final LinkedList<Artifact> parentage = new LinkedList<Artifact>(); MavenProject parent = project;/* w ww. jav a2 s . c o m*/ while (parent != null) { final org.apache.maven.artifact.Artifact pomArtifact = mavenRepositorySystem .createArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "pom"); final Artifact aetherPomArtifact = RepositoryUtils.toArtifact(pomArtifact); parentage.addFirst(aetherPomArtifact); parent = parent.getParent(); } Artifact current = parentage.removeFirst(); while (!parentage.isEmpty()) { final Artifact next = parentage.getFirst(); // This is WEIRD, but the parent POM is actually a dependency of the current one, // since it's required in order to build the current project... if (LOGGER.isDebugEnabled()) { LOGGER.debug("Marking parent POM: " + current + " as dependency of POM: " + next); } depGraph.addDependency(next, current, true, true); if (!parentage.isEmpty()) { current = parentage.removeFirst(); } } } }
From source file:org.commonjava.emb.project.SimpleProjectToolsSession.java
License:Apache License
/** * {@inheritDoc}/*from w ww. j a v a 2s . co m*/ * * @see org.commonjava.emb.project.ProjectToolsSession#addReactorProject(org.apache.maven.project.MavenProject) */ @Override public synchronized ProjectToolsSession addReactorProject(final MavenProject project) { final String id = key(project.getGroupId(), project.getArtifactId(), project.getVersion()); if (!reactorProjects.containsKey(id)) { reactorProjects.put(id, project); } return this; }
From source file:org.commonjava.maven.ext.core.util.IdUtils.java
License:Apache License
public static String ga(final MavenProject project) { return ga(project.getGroupId(), project.getArtifactId()); }
From source file:org.commonjava.maven.ext.manip.util.IdUtils.java
License:Open Source License
public static String gav(final MavenProject project) { return String.format("%s:%s:%s", project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:org.commonjava.maven.plugins.betterdep.AbstractDepgraphGoal.java
License:Open Source License
protected void readFromReactorProjects() throws MojoExecutionException { getLog().info("Initializing direct graph relationships from reactor projects: " + projects); for (final MavenProject project : projects) { final List<Profile> activeProfiles = project.getActiveProfiles(); if (activeProfiles != null) { for (final Profile profile : activeProfiles) { profiles.add(RelationshipUtils.profileLocation(profile.getId())); }/* w w w. j a va2s . co m*/ } final ProjectVersionRef projectRef = new SimpleProjectVersionRef(project.getGroupId(), project.getArtifactId(), project.getVersion()); roots.add(projectRef); final List<Dependency> deps = project.getDependencies(); // final List<ProjectVersionRef> roots = new ArrayList<ProjectVersionRef>( deps.size() ); URI localUri; try { localUri = new URI(MavenLocationExpander.LOCAL_URI); } catch (final URISyntaxException e) { throw new MojoExecutionException( "Failed to construct dummy local URI to use as the source of the current project in the depgraph: " + e.getMessage(), e); } final int index = 0; for (final Dependency dep : deps) { final ProjectVersionRef depRef = new SimpleProjectVersionRef(dep.getGroupId(), dep.getArtifactId(), dep.getVersion()); // roots.add( depRef ); final List<Exclusion> exclusions = dep.getExclusions(); final List<ProjectRef> excludes = new ArrayList<ProjectRef>(); if (exclusions != null && !exclusions.isEmpty()) { for (final Exclusion exclusion : exclusions) { excludes.add(new SimpleProjectRef(exclusion.getGroupId(), exclusion.getArtifactId())); } } rootRels.add(new SimpleDependencyRelationship(localUri, projectRef, new SimpleArtifactRef(depRef, dep.getType(), dep.getClassifier(), dep.isOptional()), DependencyScope.getScope(dep.getScope()), index, false, excludes.toArray(new ProjectRef[excludes.size()]))); } final DependencyManagement dm = project.getDependencyManagement(); if (dm != null) { final List<Dependency> managed = dm.getDependencies(); int i = 0; for (final Dependency dep : managed) { if ("pom".equals(dep.getType()) && "import".equals(dep.getScope())) { final ProjectVersionRef depRef = new SimpleProjectVersionRef(dep.getGroupId(), dep.getArtifactId(), dep.getVersion()); rootRels.add(new SimpleBomRelationship(localUri, projectRef, depRef, i++)); } } } ProjectVersionRef lastParent = projectRef; MavenProject parent = project.getParent(); while (parent != null) { final ProjectVersionRef parentRef = new SimpleProjectVersionRef(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); rootRels.add(new SimpleParentRelationship(localUri, projectRef, parentRef)); lastParent = parentRef; parent = parent.getParent(); } rootRels.add(new SimpleParentRelationship(lastParent)); } }
From source file:org.commonjava.maven.plugins.execroot.ProjectRef.java
License:Apache License
public boolean matches(final MavenProject project) { return project.getGroupId().equals(groupId) && project.getArtifactId().equals(artifactId); }
From source file:org.commonjava.poc.ral.AppLauncher.java
License:Open Source License
public AppLauncher(final Options options) throws AppLauncherException { setupLogging(Level.INFO);// w ww.j av a 2s. co m this.options = options; try { load(); } catch (MAEException e) { throw new AppLauncherException("Failed to initialize MAE subsystem: %s", e, e.getMessage()); } SimpleProjectToolsSession session = new SimpleProjectToolsSession(); session.setPomValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); session.setDependencySelector( new FlexibleScopeDependencySelector(org.apache.maven.artifact.Artifact.SCOPE_TEST, org.apache.maven.artifact.Artifact.SCOPE_PROVIDED).setTransitive(true)); MavenProject project = loadProject(options.coordinate, session); DependencyGraph depGraph = resolveDependencies(project, session); List<URL> urls = new ArrayList<URL>(); try { ArtifactResult result = repositorySystem.resolveArtifact(session.getRepositorySystemSession(), new ArtifactRequest(RepositoryUtils.toArtifact(project.getArtifact()), session.getRemoteRepositoriesForResolution(), null)); mainJar = result.getArtifact().getFile().toURI().normalize().toURL(); urls.add(mainJar); } catch (ArtifactResolutionException e) { throw new AppLauncherException("Failed to resolve main project artifact: %s. Reason: %s", e, project.getId(), e.getMessage()); } catch (MalformedURLException e) { throw new AppLauncherException("Cannot format classpath URL from: %s. Reason: %s", e, project.getId(), e.getMessage()); } for (DepGraphNode node : depGraph) { try { ArtifactResult result = node.getLatestResult(); if (result == null) { if (node.getKey() .equals(key(project.getGroupId(), project.getArtifactId(), project.getVersion()))) { continue; } else { throw new AppLauncherException("Failed to resolve: %s", node.getKey()); } } Artifact artifact = result.getArtifact(); File file = artifact.getFile(); URL url = file.toURI().normalize().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new AppLauncherException("Cannot format classpath URL from: %s. Reason: %s", e, node.getKey(), e.getMessage()); } } classLoader = new URLClassLoader(urls.toArray(new URL[] {}), ClassLoader.getSystemClassLoader()); }
From source file:org.commonjava.sjbi.maven3.builder.M3BuildResult.java
License:Open Source License
M3BuildResult(final MavenExecutionResult mavenResult) { if (mavenResult.hasExceptions()) { setErrors(mavenResult.getExceptions()); }//from w ww . j a v a 2 s . co m final List<ArtifactSetRef> ars = new ArrayList<ArtifactSetRef>(); for (final MavenProject project : mavenResult.getTopologicallySortedProjects()) { final ProjectRef pr = new ProjectRef(project.getGroupId(), project.getArtifactId(), project.getVersion()); pr.setPomFile(project.getFile()); final ArtifactSetRef ar = new ArtifactSetRef(pr); final Artifact mainArtifact = project.getArtifact(); ar.addArtifactRef(mainArtifact.getType(), mainArtifact.getClassifier(), mainArtifact.getFile()); for (final Artifact a : project.getAttachedArtifacts()) { ar.addArtifactRef(a.getType(), a.getClassifier(), a.getFile()); } ars.add(ar); } setArtifactSets(ars); }