use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class AbstractFromConfigurationMojo method getArtifact.
/**
* Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved
* from the dependency list or from the DependencyManagement section of the pom.
*
* @param artifactItem containing information about artifact from plugin configuration.
* @return Artifact object representing the specified file.
* @throws MojoExecutionException with a message if the version can't be found in DependencyManagement.
*/
protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException {
Artifact artifact;
try {
// mdep-50 - rolledback for now because it's breaking some functionality.
/*
* List listeners = new ArrayList(); Set theSet = new HashSet(); theSet.add( artifact );
* ArtifactResolutionResult artifactResolutionResult = artifactCollector.collect( theSet, project
* .getArtifact(), managedVersions, this.local, project.getRemoteArtifactRepositories(),
* artifactMetadataSource, null, listeners ); Iterator iter =
* artifactResolutionResult.getArtifactResolutionNodes().iterator(); while ( iter.hasNext() ) {
* ResolutionNode node = (ResolutionNode) iter.next(); artifact = node.getArtifact(); }
*/
ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest();
if (localRepositoryDirectory != null) {
buildingRequest = repositoryManager.setLocalRepositoryBasedir(buildingRequest, localRepositoryDirectory);
}
// Map dependency to artifact coordinate
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(artifactItem.getGroupId());
coordinate.setArtifactId(artifactItem.getArtifactId());
coordinate.setVersion(artifactItem.getVersion());
coordinate.setClassifier(artifactItem.getClassifier());
final String extension;
ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(artifactItem.getType());
if (artifactHandler != null) {
extension = artifactHandler.getExtension();
} else {
extension = artifactItem.getType();
}
coordinate.setExtension(extension);
artifact = artifactResolver.resolveArtifact(buildingRequest, coordinate).getArtifact();
} catch (ArtifactResolverException e) {
throw new MojoExecutionException("Unable to find/resolve artifact.", e);
}
return artifact;
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class GetMojo method toArtifactCoordinate.
private ArtifactCoordinate toArtifactCoordinate(DependableCoordinate dependableCoordinate) {
ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(dependableCoordinate.getType());
DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
artifactCoordinate.setGroupId(dependableCoordinate.getGroupId());
artifactCoordinate.setArtifactId(dependableCoordinate.getArtifactId());
artifactCoordinate.setVersion(dependableCoordinate.getVersion());
artifactCoordinate.setClassifier(dependableCoordinate.getClassifier());
artifactCoordinate.setExtension(artifactHandler.getExtension());
return artifactCoordinate;
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class AbstractHelpMojo method getArtifactCoordinate.
protected ArtifactCoordinate getArtifactCoordinate(String groupId, String artifactId, String version, String type) {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(groupId);
coordinate.setArtifactId(artifactId);
coordinate.setVersion(version);
coordinate.setExtension(type);
return coordinate;
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class AbstractChangesReport method getSkinArtifactFile.
private File getSkinArtifactFile() throws MojoExecutionException {
Skin skin = Skin.getDefaultSkin();
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(skin.getGroupId());
coordinate.setArtifactId(skin.getArtifactId());
coordinate.setVersion(skin.getVersion());
ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest(mavenSession.getProjectBuildingRequest());
pbr.setRemoteRepositories(project.getRemoteArtifactRepositories());
try {
return resolver.resolveArtifact(pbr, coordinate).getArtifact().getFile();
} catch (ArtifactResolverException e) {
throw new MojoExecutionException("Couldn't resolve the skin.", e);
}
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class AbstractJavadocMojo method resolveDependency.
/**
* @param dependency {@link Dependency}
* @return {@link Artifact}
* @throws MavenReportException
*/
public Artifact resolveDependency(Dependency dependency) throws MavenReportException {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(dependency.getGroupId());
coordinate.setArtifactId(dependency.getArtifactId());
coordinate.setVersion(dependency.getVersion());
coordinate.setClassifier(dependency.getClassifier());
coordinate.setExtension(artifactHandlerManager.getArtifactHandler(dependency.getType()).getExtension());
try {
return artifactResolver.resolveArtifact(session.getProjectBuildingRequest(), coordinate).getArtifact();
} catch (ArtifactResolverException e) {
throw new MavenReportException("artifact resolver problem - " + e.getMessage(), e);
}
}
Aggregations