use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class MarkerFileFilter method isArtifactIncluded.
@Override
public boolean isArtifactIncluded(ArtifactItem item) throws ArtifactFilterException {
Artifact artifact = item.getArtifact();
boolean overWrite = (artifact.isSnapshot() && this.overWriteSnapshots) || (!artifact.isSnapshot() && this.overWriteReleases);
handler.setArtifact(artifact);
try {
return overWrite || !handler.isMarkerSet() || (overWriteIfNewer && handler.isMarkerOlder(artifact));
} catch (MojoExecutionException e) {
throw new ArtifactFilterException(e.getMessage(), e);
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class DestFileFilter method isArtifactIncluded.
@Override
public boolean isArtifactIncluded(ArtifactItem item) {
Artifact artifact = item.getArtifact();
boolean overWrite = (artifact.isSnapshot() && this.overWriteSnapshots) || (!artifact.isSnapshot() && this.overWriteReleases);
File destFolder = item.getOutputDirectory();
if (destFolder == null) {
destFolder = DependencyUtil.getFormattedOutputDirectory(useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact, useRepositoryLayout, removeVersion, this.outputFileDirectory, artifact);
}
File destFile;
if (StringUtils.isEmpty(item.getDestFileName())) {
String formattedFileName = DependencyUtil.getFormattedFileName(artifact, removeVersion, prependGroupId, useBaseVersion, removeClassifier);
destFile = new File(destFolder, formattedFileName);
} else {
destFile = new File(destFolder, item.getDestFileName());
}
return overWrite || !destFile.exists() || (overWriteIfNewer && artifact.getFile().lastModified() > destFile.lastModified());
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class DependencyStatusSets method buildArtifactListOutput.
private StringBuilder buildArtifactListOutput(Set<Artifact> artifacts, boolean outputAbsoluteArtifactFilename, boolean outputScope, boolean sort) {
StringBuilder sb = new StringBuilder();
List<String> artifactStringList = new ArrayList<String>();
for (Artifact artifact : artifacts) {
String artifactFilename = null;
if (outputAbsoluteArtifactFilename) {
try {
// we want to print the absolute file name here
artifactFilename = artifact.getFile().getAbsoluteFile().getPath();
} catch (NullPointerException e) {
// ignore the null pointer, we'll output a null string
artifactFilename = null;
}
}
String id = outputScope ? artifact.toString() : artifact.getId();
String optionalMarker = "";
if (outputScope && artifact.isOptional()) {
optionalMarker = " (optional) ";
}
String moduleNameMarker = "";
// dependencies:collect won't download jars
if (artifact.getFile() != null) {
ModuleDescriptor moduleDescriptor = getModuleDescriptor(artifact.getFile());
if (moduleDescriptor != null) {
moduleNameMarker = " -- module " + moduleDescriptor.name;
if (moduleDescriptor.automatic) {
moduleNameMarker += " (auto)";
}
}
}
artifactStringList.add(" " + id + (outputAbsoluteArtifactFilename ? ":" + artifactFilename : "") + optionalMarker + moduleNameMarker + "\n");
}
if (sort) {
Collections.sort(artifactStringList);
}
for (String artifactString : artifactStringList) {
sb.append(artifactString);
}
return sb;
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractAnalyzeMojo method writeScriptableOutput.
private void writeScriptableOutput(Set<Artifact> artifacts) {
if (!artifacts.isEmpty()) {
getLog().info("Missing dependencies: ");
String pomFile = baseDir.getAbsolutePath() + File.separatorChar + "pom.xml";
StringBuilder buf = new StringBuilder();
for (Artifact artifact : artifacts) {
// called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961
artifact.isSnapshot();
buf.append(scriptableFlag).append(":").append(pomFile).append(":").append(artifact.getDependencyConflictId()).append(":").append(artifact.getClassifier()).append(":").append(artifact.getBaseVersion()).append(":").append(artifact.getScope()).append("\n");
}
getLog().info("\n" + buf);
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractAnalyzeMojo method filterDependencies.
private List<Artifact> filterDependencies(Set<Artifact> artifacts, String[] excludes) throws MojoExecutionException {
ArtifactFilter filter = new StrictPatternExcludesArtifactFilter(Arrays.asList(excludes));
List<Artifact> result = new ArrayList<Artifact>();
for (Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); ) {
Artifact artifact = it.next();
if (!filter.include(artifact)) {
it.remove();
result.add(artifact);
}
}
return result;
}
Aggregations