use of org.apache.maven.artifact.Artifact 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.artifact.Artifact 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.artifact.Artifact in project maven-plugins by apache.
the class DependencyFilesetsTask method execute.
/** {@inheritDoc} */
public void execute() {
if (this.getProject().getReference(mavenProjectId) == null) {
throw new BuildException("Maven project reference not found: " + mavenProjectId);
}
MavenProject mavenProject = (MavenProject) this.getProject().getReference("maven.project");
// Add filesets for depenedency artifacts
Set<Artifact> depArtifacts = filterArtifacts(mavenProject.getArtifacts());
FileSet dependenciesFileSet = new FileSet();
dependenciesFileSet.setProject(getProject());
ArtifactRepository localRepository = (ArtifactRepository) getProject().getReference("maven.local.repository");
dependenciesFileSet.setDir(new File(localRepository.getBasedir()));
for (Artifact artifact : depArtifacts) {
String relativeArtifactPath = localRepository.pathOf(artifact);
dependenciesFileSet.createInclude().setName(relativeArtifactPath);
String fileSetName = getPrefix() + artifact.getDependencyConflictId();
FileSet singleArtifactFileSet = new FileSet();
singleArtifactFileSet.setProject(getProject());
singleArtifactFileSet.setFile(artifact.getFile());
getProject().addReference(fileSetName, singleArtifactFileSet);
}
getProject().addReference((getPrefix() + projectDependenciesId), dependenciesFileSet);
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractCheckstyleReport method getCheckstylePluginDependenciesAsArtifacts.
private List<Artifact> getCheckstylePluginDependenciesAsArtifacts(Map<String, Plugin> plugins, String hint) {
List<Artifact> artifacts = new ArrayList<>();
Plugin checkstylePlugin = plugins.get(plugin.getGroupId() + ":" + plugin.getArtifactId());
if (checkstylePlugin != null) {
for (Dependency dep : checkstylePlugin.getDependencies()) {
// @todo if we can filter on hints, it should be done here...
String depKey = dep.getGroupId() + ":" + dep.getArtifactId();
artifacts.add((Artifact) plugin.getArtifactMap().get(depKey));
}
}
return artifacts;
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractEarModule method resolveArtifact.
/** {@inheritDoc} */
public void resolveArtifact(Set<Artifact> artifacts) throws EarPluginException, MojoFailureException {
// If the artifact is already set no need to resolve it
if (artifact == null) {
// Make sure that at least the groupId and the artifactId are specified
if (groupId == null || artifactId == null) {
throw new MojoFailureException("Could not resolve artifact[" + groupId + ":" + artifactId + ":" + getType() + "]");
}
final ArtifactRepository ar = earExecutionContext.getArtifactRepository();
artifact = ar.getUniqueArtifact(groupId, artifactId, getType(), classifier);
// Artifact has not been found
if (artifact == null) {
Set<Artifact> candidates = ar.getArtifacts(groupId, artifactId, getType());
if (candidates.size() > 1) {
throw new MojoFailureException("Artifact[" + this + "] has " + candidates.size() + " candidates, please provide a classifier.");
} else {
throw new MojoFailureException("Artifact[" + this + "] is not a dependency of the project.");
}
}
}
}
Aggregations