use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class MinijarFilter method removeSpecificallyIncludedClasses.
private void removeSpecificallyIncludedClasses(MavenProject project, List<SimpleFilter> simpleFilters) throws IOException {
// remove classes specifically included in filters
Clazzpath checkCp = new Clazzpath();
for (Artifact dependency : project.getArtifacts()) {
File jar = dependency.getFile();
for (SimpleFilter simpleFilter : simpleFilters) {
if (simpleFilter.canFilter(jar)) {
ClazzpathUnit depClazzpathUnit = addDependencyToClasspath(checkCp, dependency);
if (depClazzpathUnit != null) {
Set<Clazz> clazzes = depClazzpathUnit.getClazzes();
Iterator<Clazz> j = removable.iterator();
while (j.hasNext()) {
Clazz clazz = j.next();
if (//
clazzes.contains(clazz) && simpleFilter.isSpecificallyIncluded(clazz.getName().replace('.', '/'))) {
log.info(clazz.getName() + " not removed because it was specifically included");
j.remove();
}
}
}
}
}
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class ShadeMojo method shadedArtifactFileWithClassifier.
private File shadedArtifactFileWithClassifier() {
Artifact artifact = project.getArtifact();
final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "." + artifact.getArtifactHandler().getExtension();
return new File(outputDirectory, shadedName);
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class ShadeMojo method processArtifactSelectors.
private void processArtifactSelectors(Set<File> artifacts, Set<String> artifactIds, Set<File> sourceArtifacts, ArtifactSelector artifactSelector) {
for (Artifact artifact : project.getArtifacts()) {
if (!artifactSelector.isSelected(artifact)) {
getLog().info("Excluding " + artifact.getId() + " from the shaded jar.");
continue;
}
if ("pom".equals(artifact.getType())) {
getLog().info("Skipping pom dependency " + artifact.getId() + " in the shaded jar.");
continue;
}
getLog().info("Including " + artifact.getId() + " in the shaded jar.");
artifacts.add(artifact.getFile());
artifactIds.add(getId(artifact));
if (createSourcesJar) {
File file = resolveArtifactSources(artifact);
if (file != null) {
sourceArtifacts.add(file);
}
}
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class ShadeMojo method shadedSourceArtifactFileWithClassifier.
private File shadedSourceArtifactFileWithClassifier() {
Artifact artifact = project.getArtifact();
final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName + "-sources." + artifact.getArtifactHandler().getExtension();
return new File(outputDirectory, shadedName);
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AntBuildWriterUtil method writeCopyLib.
/**
* Write copy tasks in an outputDir for EAR and WAR targets for project depencies without
* <code>provided</code> or <code>test</code> as scope
*
* @param writer not null
* @param project not null
* @param artifactResolverWrapper not null
* @param outputDir not null
*/
private static void writeCopyLib(XMLWriter writer, MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, String outputDir) {
writer.startElement("mkdir");
writer.addAttribute("dir", outputDir);
// mkdir
writer.endElement();
if (project.getArtifacts() != null) {
for (Object o : project.getArtifacts()) {
Artifact artifact = (Artifact) o;
if (Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact.getScope())) {
String path = artifactResolverWrapper.getLocalArtifactPath(artifact);
if (!new File(path).isAbsolute()) {
path = "${maven.repo.local}/" + path;
}
writer.startElement("copy");
writer.addAttribute("file", path);
addWrapAttribute(writer, "copy", "todir", outputDir, 3);
// copy
writer.endElement();
}
}
}
}
Aggregations