use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveTransitively.
private Set<Artifact> resolveTransitively(final Set<Artifact> dependencyArtifacts, final List<ArtifactRepository> repos, final ArtifactFilter filter, final AssemblerConfigurationSource configSource) throws DependencyResolutionException {
final MavenProject project = configSource.getProject();
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(configSource.getLocalRepository());
req.setResolveRoot(false);
req.setRemoteRepositories(repos);
req.setResolveTransitively(true);
req.setArtifact(project.getArtifact());
req.setArtifactDependencies(dependencyArtifacts);
req.setManagedVersionMap(project.getManagedVersionMap());
req.setCollectionFilter(filter);
req.setOffline(configSource.getMavenSession().isOffline());
req.setForceUpdate(configSource.getMavenSession().getRequest().isUpdateSnapshots());
req.setServers(configSource.getMavenSession().getRequest().getServers());
req.setMirrors(configSource.getMavenSession().getRequest().getMirrors());
req.setProxies(configSource.getMavenSession().getRequest().getProxies());
ArtifactResolutionResult result;
result = resolver.resolve(req);
if (result.hasExceptions()) {
throw new DependencyResolutionException("Failed to resolve dependencies for assembly: ", result.getExceptions().get(0));
}
getLogger().debug("While resolving dependencies of " + project.getId() + ":");
FilterUtils.reportFilteringStatistics(Collections.singleton(filter), getLogger());
return result.getArtifacts();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveNonTransitively.
Set<Artifact> resolveNonTransitively(final Assembly assembly, final Set<Artifact> dependencyArtifacts, final AssemblerConfigurationSource configSource, final List<ArtifactRepository> repos) throws DependencyResolutionException {
final List<Artifact> missing = new ArrayList<Artifact>();
final Set<Artifact> resolved = new LinkedHashSet<Artifact>();
for (final Artifact depArtifact : dependencyArtifacts) {
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(configSource.getLocalRepository());
req.setRemoteRepositories(repos);
req.setArtifact(depArtifact);
ArtifactResolutionResult resolve = resolver.resolve(req);
if (resolve.hasExceptions()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to resolve: " + depArtifact.getId() + " for assembly: " + assembly.getId());
}
missing.add(depArtifact);
} else {
resolved.add(depArtifact);
}
}
if (!missing.isEmpty()) {
final MavenProject project = configSource.getProject();
final Artifact rootArtifact = project.getArtifact();
final Throwable error = new MultipleArtifactsNotFoundException(rootArtifact, new ArrayList<Artifact>(resolved), missing, repos);
throw new DependencyResolutionException("Failed to resolve dependencies for: " + assembly.getId(), error);
}
return resolved;
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultDependencyResolver method updateModuleSetResolutionRequirements.
void updateModuleSetResolutionRequirements(AssemblyId assemblyId, ModuleSet set, DependencySet dependencySet, final ResolutionManagementInfo requirements, final AssemblerConfigurationSource configSource) throws DependencyResolutionException {
final ModuleBinaries binaries = set.getBinaries();
if (binaries != null) {
Set<MavenProject> projects;
try {
projects = ModuleSetAssemblyPhase.getModuleProjects(set, configSource, getLogger());
} catch (final ArchiveCreationException e) {
throw new DependencyResolutionException("Error determining project-set for moduleSet with binaries.", e);
}
if (!projects.isEmpty()) {
for (final MavenProject p : projects) {
requirements.enableProjectResolution(p);
if (p.getArtifact() == null) {
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of
// type
final Artifact artifact = resolver.createArtifact(p.getGroupId(), p.getArtifactId(), p.getVersion(), p.getPackaging());
p.setArtifact(artifact);
}
}
}
if (binaries.isIncludeDependencies()) {
updateDependencySetResolutionRequirements(dependencySet, requirements, assemblyId, configSource.getMavenSession().getProjectBuildingRequest(), projects.toArray(new MavenProject[projects.size()]));
}
}
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveDependencySets.
@Override
public Map<DependencySet, Set<Artifact>> resolveDependencySets(final Assembly assembly, ModuleSet moduleSet, final AssemblerConfigurationSource configSource, List<DependencySet> dependencySets) throws DependencyResolutionException {
Map<DependencySet, Set<Artifact>> result = new LinkedHashMap<DependencySet, Set<Artifact>>();
for (DependencySet dependencySet : dependencySets) {
final MavenProject currentProject = configSource.getProject();
final ResolutionManagementInfo info = new ResolutionManagementInfo(currentProject);
updateRepositoryResolutionRequirements(assembly, info);
final AssemblyId assemblyId = AssemblyId.createAssemblyId(assembly);
updateDependencySetResolutionRequirements(dependencySet, info, assemblyId, configSource.getMavenSession().getProjectBuildingRequest(), currentProject);
updateModuleSetResolutionRequirements(assemblyId, moduleSet, dependencySet, info, configSource);
resolve(assembly, configSource, result, dependencySet, info);
}
return result;
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class AntBuildWriterUtilTest method testGetMavenJavadocPluginConfiguration.
/**
* Test method for 'org.apache.maven.plugin.ant.AntBuildWriterUtil.getMavenJavadocPluginConfiguration(MavenProject, String, String)'
*
* @throws Exception
*/
public void testGetMavenJavadocPluginConfiguration() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/ant-javadoc-test/pom.xml");
MavenEmbedder maven = new MavenEmbedder();
maven.setClassLoader(Thread.currentThread().getContextClassLoader());
maven.setLogger(new MavenEmbedderConsoleLogger());
maven.setLocalRepositoryDirectory(getTestFile("target/local-repo"));
maven.setOffline(true);
maven.start();
MavenProject project = maven.readProject(testPom);
assertEquals(AntBuildWriterUtil.getMavenJavadocPluginBasicOption(project, "doclet", null), "gr.spinellis.umlgraph.doclet.UmlGraphDoc");
assertNotNull(AntBuildWriterUtil.getMavenJavadocPluginOptions(project, "links", null));
assertEquals(AntBuildWriterUtil.getMavenJavadocPluginOptions(project, "links", null).length, 2);
assertNotNull(AntBuildWriterUtil.getMavenJavadocPluginOptions(project, "docletArtifacts", null));
assertEquals(AntBuildWriterUtil.getMavenJavadocPluginOptions(project, "docletArtifacts", null).length, 2);
Map[] options = AntBuildWriterUtil.getMavenJavadocPluginOptions(project, "tags", null);
assertNotNull(options);
assertEquals(options.length, 1);
assertEquals(1, options[0].size());
Map properties = (Map) options[0].get("tag");
assertNotNull(properties);
assertEquals("requirement", properties.get("name"));
assertEquals("a", properties.get("placement"));
assertEquals("Software Requirement:", properties.get("head"));
maven.stop();
}
Aggregations