List of usage examples for org.apache.maven.project MavenProject setDependencyArtifacts
@Deprecated public void setDependencyArtifacts(Set<Artifact> dependencyArtifacts)
From source file:org.jetbrains.maven.embedder.MavenEmbedder.java
License:Apache License
@Nonnull public MavenExecutionResult resolveProject(@Nonnull final File file, @Nonnull final List<String> activeProfiles, @Nonnull final List<String> inactiveProfiles, List<ResolutionListener> listeners) { MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, Collections.<String>emptyList()); ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration(); request.getGlobalProfileManager().loadSettingsProfiles(mySettings); ProfileManager globalProfileManager = request.getGlobalProfileManager(); globalProfileManager.loadSettingsProfiles(request.getSettings()); List<Exception> exceptions = new ArrayList<Exception>(); MavenProject project = null; try {//from w w w. ja v a2s .co m // copied from DefaultMavenProjectBuilder.buildWithDependencies MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class); project = builder.build(new File(file.getPath()), config); builder.calculateConcreteState(project, config, false); // copied from DefaultLifecycleExecutor.execute findExtensions(project); // end copied from DefaultLifecycleExecutor.execute Artifact projectArtifact = project.getArtifact(); Map managedVersions = project.getManagedVersionMap(); ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class); project.setDependencyArtifacts( project.createArtifacts(getComponent(ArtifactFactory.class), null, null)); ArtifactResolver resolver = getComponent(ArtifactResolver.class); ArtifactResolutionResult result = resolver.resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository, project.getRemoteArtifactRepositories(), metadataSource, null, listeners); project.setArtifacts(result.getArtifacts()); // end copied from DefaultMavenProjectBuilder.buildWithDependencies } catch (Exception e) { return handleException(e); } return new MavenExecutionResult(project, exceptions); }
From source file:org.nuxeo.build.maven.EmbeddedMavenClient.java
License:Open Source License
public void resolveDependencyTree(Artifact artifact, ArtifactFilter filter, ResolutionListener listener) throws ArtifactResolutionException, ProjectBuildingException { MavenProject project = mavenProjectBuilder.buildFromRepository(artifact, getRemoteRepositories(), localRepository);// w w w .ja v a 2 s. com @SuppressWarnings("rawtypes") Set dependencyArtifacts = project.getDependencyArtifacts(); if (dependencyArtifacts == null) { try { dependencyArtifacts = project.createArtifacts(artifactFactory, null, null); } catch (InvalidDependencyVersionException e) { throw new ArtifactResolutionException("Cannot set dependencies", artifact, e); } project.setDependencyArtifacts(dependencyArtifacts); } ArtifactCollector collector = new DefaultArtifactCollector(); collector.collect(dependencyArtifacts, project.getArtifact(), project.getManagedVersionMap(), localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource, filter, Collections.singletonList(listener)); }
From source file:org.sonatype.flexmojos.utilities.MavenUtils.java
License:Apache License
/** * Get dependency artifacts for a project using the local and remote repositories to resolve the artifacts * /* w w w. j ava 2 s. c om*/ * @param project maven project * @param resolver artifact resolver * @param localRepository artifact repository * @param remoteRepositories List of remote repositories * @param artifactMetadataSource artifactMetadataSource * @param artifactFactory TODO * @return all dependencies from the project * @throws MojoExecutionException thrown if an exception occured during artifact resolving */ @SuppressWarnings("unchecked") public static Set<Artifact> getDependencyArtifacts(MavenProject project, ArtifactResolver resolver, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource artifactMetadataSource, ArtifactFactory artifactFactory) throws MojoExecutionException { Set<Artifact> artifacts = project.getDependencyArtifacts(); if (artifacts == null) { try { artifacts = project.createArtifacts(artifactFactory, null, null); } catch (InvalidDependencyVersionException e) { throw new MojoExecutionException(e.getMessage(), e); } project.setDependencyArtifacts(artifacts); } ArtifactResolutionResult arr; try { arr = resolver.resolveTransitively(project.getDependencyArtifacts(), project.getArtifact(), remoteRepositories, localRepository, artifactMetadataSource); } catch (AbstractArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } Set<Artifact> result = arr.getArtifacts(); // ## 6/18/09 StoneRiver Change to resolve RELEASE Artifact version ## for (Artifact artifact : result) { if (artifact.getVersion().equals(Artifact.RELEASE_VERSION)) { getReleaseVersion(artifact, localRepository, remoteRepositories, artifactMetadataSource); } } return result; }