use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class AbstractJavadocMojo method createAndResolveArtifact.
/**
* creates an {@link Artifact} representing the configured {@link JavadocPathArtifact} and resolves it.
*
* @param javadocArtifact the {@link JavadocPathArtifact} to resolve
* @return a resolved {@link Artifact}
* @throws ArtifactResolverException
*/
private Artifact createAndResolveArtifact(JavadocPathArtifact javadocArtifact) throws ArtifactResolverException {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(javadocArtifact.getGroupId());
coordinate.setArtifactId(javadocArtifact.getArtifactId());
coordinate.setVersion(javadocArtifact.getVersion());
return artifactResolver.resolveArtifact(session.getProjectBuildingRequest(), coordinate).getArtifact();
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class CopyDependenciesMojo method getResolvedPomArtifact.
protected Artifact getResolvedPomArtifact(Artifact artifact) {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(artifact.getGroupId());
coordinate.setArtifactId(artifact.getArtifactId());
coordinate.setVersion(artifact.getVersion());
coordinate.setExtension("pom");
Artifact pomArtifact = null;
// Resolve the pom artifact using repos
try {
ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest();
pomArtifact = getArtifactResolver().resolveArtifact(buildingRequest, coordinate).getArtifact();
} catch (ArtifactResolverException e) {
getLog().info(e.getMessage());
}
return pomArtifact;
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class ClassifierTypeTranslator method translate.
/*
* (non-Javadoc)
*
* @see org.apache.mojo.dependency.utils.translators.ArtifactTranslator#translate(java.util.Set,
* org.apache.maven.plugin.logging.Log)
*/
@Override
public Set<ArtifactCoordinate> translate(Set<Artifact> artifacts, Log log) {
Set<ArtifactCoordinate> results;
log.debug("Translating Artifacts using Classifier: " + this.classifier + " and Type: " + this.type);
results = new LinkedHashSet<ArtifactCoordinate>();
for (Artifact artifact : artifacts) {
// this translator must pass both type and classifier here so we
// will use the
// base artifact value if null comes in
final String useType;
if (StringUtils.isNotEmpty(this.type)) {
useType = this.type;
} else {
useType = artifact.getType();
}
ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(useType);
final String extension;
if (artifactHandler != null) {
extension = artifactHandler.getExtension();
} else {
extension = this.type;
}
String useClassifier;
if (StringUtils.isNotEmpty(this.classifier)) {
useClassifier = this.classifier;
} else {
useClassifier = artifact.getClassifier();
}
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(artifact.getGroupId());
coordinate.setArtifactId(artifact.getArtifactId());
coordinate.setVersion(artifact.getVersion());
coordinate.setClassifier(useClassifier);
coordinate.setExtension(extension);
// // Create a new artifact
// Artifact newArtifact = factory.createArtifactWithClassifier( artifact.getGroupId(), artifact
// .getArtifactId(), artifact.getVersion(), useType, useClassifier );
//
// // note the new artifacts will always have the scope set to null. We
// // should
// // reset it here so that it will pass other filters if needed
// newArtifact.setScope( artifact.getScope() );
//
// if ( Artifact.SCOPE_SYSTEM.equals( newArtifact.getScope() ) )
// {
// File baseDir = repositoryManager.getLocalRepositoryBasedir( buildingRequest );
// String path = repositoryManager.getPathForLocalArtifact( buildingRequest, newArtifact );
// newArtifact.setFile( new File( baseDir, path ) );
// }
results.add(coordinate);
}
return results;
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class DeployFileMojo method getLocalRepoFile.
/**
* Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier and
* packaging within the local repository. Note that the returned path need not exist (yet).
*
* @return The absolute path to the artifact when installed, never <code>null</code>.
*/
private File getLocalRepoFile() {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(groupId);
coordinate.setArtifactId(artifactId);
coordinate.setVersion(version);
coordinate.setClassifier(classifier);
coordinate.setExtension(packaging);
String path = repoManager.getPathForLocalArtifact(getSession().getProjectBuildingRequest(), coordinate);
return new File(repoManager.getLocalRepositoryBasedir(getSession().getProjectBuildingRequest()), path);
}
use of org.apache.maven.shared.artifact.DefaultArtifactCoordinate in project maven-plugins by apache.
the class ShadeMojo method resolveArtifactSources.
private File resolveArtifactSources(Artifact artifact) {
DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
coordinate.setGroupId(artifact.getGroupId());
coordinate.setArtifactId(artifact.getArtifactId());
coordinate.setVersion(artifact.getVersion());
coordinate.setExtension("jar");
coordinate.setClassifier("sources");
Artifact resolvedArtifact;
try {
resolvedArtifact = artifactResolver.resolveArtifact(session.getProjectBuildingRequest(), coordinate).getArtifact();
} catch (ArtifactResolverException e) {
getLog().warn("Could not get sources for " + artifact);
return null;
}
if (resolvedArtifact.isResolved()) {
return resolvedArtifact.getFile();
}
return null;
}
Aggregations