use of org.apache.maven.artifact.resolver.filter.AndArtifactFilter in project wso2-synapse by wso2.
the class AbstractXarMojo method addDependencies.
private void addDependencies(Archiver archiver) throws ArchiverException, MojoExecutionException {
Log log = getLog();
AndArtifactFilter filter = new AndArtifactFilter();
filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
filter.add(new ArtifactFilter() {
public boolean include(Artifact artifact) {
return !artifact.isOptional();
}
});
filter.add(new TypeArtifactFilter("jar"));
filter.add(buildSynapseRuntimeArtifactFilter());
for (Artifact artifact : filterArtifacts((Set<Artifact>) project.getArtifacts(), filter)) {
String targetFileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension();
log.info("Adding " + targetFileName + " (scope " + artifact.getScope() + ")");
archiver.addFile(artifact.getFile(), "lib/" + targetFileName);
}
}
use of org.apache.maven.artifact.resolver.filter.AndArtifactFilter in project abstools by abstools.
the class AbstractABSMojo method resolveDependencyArtifacts.
/**
* This method resolves the dependency artifacts from the project.
*
* @param theProject
* The POM.
* @return resolved set of dependency artifacts.
*
* @throws ArtifactResolutionException
* @throws ArtifactNotFoundException
* @throws InvalidDependencyVersionException
*/
@SuppressWarnings("unchecked")
protected Set<Artifact> resolveDependencyArtifacts(MavenProject theProject) throws Exception {
AndArtifactFilter filter = new AndArtifactFilter();
filter.add(new ScopeArtifactFilter(Artifact.SCOPE_TEST));
filter.add(new ArtifactFilter() {
public boolean include(Artifact artifact) {
return !artifact.isOptional();
}
});
// TODO follow the dependenciesManagement and override rules
Set<Artifact> artifacts = theProject.createArtifacts(factory, Artifact.SCOPE_RUNTIME, filter);
for (Artifact artifact : artifacts) {
resolver.resolve(artifact, remoteRepos, localRepo);
}
return artifacts;
}
use of org.apache.maven.artifact.resolver.filter.AndArtifactFilter in project xwiki-platform by xwiki.
the class PackageMojo method resolveTransitively.
private Set<Artifact> resolveTransitively(Set<Artifact> artifacts) throws MojoExecutionException {
AndArtifactFilter filter = new AndArtifactFilter(Arrays.asList(new ScopeArtifactFilter("runtime"), // for JSX. See https://jira.xwiki.org/browse/XWIKI-6151 for more details.
new ExcludesArtifactFilter(Arrays.asList("org.apache.xmlgraphic:batik-js", "commons-logging:commons-logging", "commons-logging:commons-logging-api", "log4j:log4j"))));
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact(this.project.getArtifact()).setArtifactDependencies(artifacts).setCollectionFilter(filter).setRemoteRepositories(this.remoteRepositories).setLocalRepository(this.localRepository).setManagedVersionMap(getManagedVersionMap()).setResolveRoot(false);
ArtifactResolutionResult resolutionResult = this.repositorySystem.resolve(request);
if (resolutionResult.hasExceptions()) {
throw new MojoExecutionException(String.format("Failed to resolve artifacts [%s]", artifacts, resolutionResult.getExceptions().get(0)));
}
return resolutionResult.getArtifacts();
}
use of org.apache.maven.artifact.resolver.filter.AndArtifactFilter in project scala-maven-plugin by davidB.
the class ScalaMojoSupport method resolveArtifactDependencies.
/**
* This method resolves all transitive dependencies of an artifact.
*
* @param artifact the {@link Artifact} used to retrieve dependencies.
*
* @return resolved {@link Set} of dependencies.
*
* @throws {@link Exception} when various artifact resolution mechanisms fail.
*/
protected final Set<Artifact> resolveArtifactDependencies(final Artifact artifact) throws Exception {
final AndArtifactFilter filter = new AndArtifactFilter();
filter.add(new ScopeArtifactFilter(Artifact.SCOPE_TEST));
filter.add(new ArtifactFilter() {
public boolean include(Artifact artifact) {
return !artifact.isOptional();
}
});
// Use the collection filter as the resolution filter.
return resolveDependencyArtifacts(artifact, filter, filter);
}
use of org.apache.maven.artifact.resolver.filter.AndArtifactFilter in project maven-plugins by apache.
the class DependencyFilesetsTask method filterArtifacts.
/**
* Filter a set of artifacts using the scopes and type filters.
*
* @param artifacts {@link Artifact} set.
* @return The set of filtered artifacts.
*/
public Set<Artifact> filterArtifacts(Set<Artifact> artifacts) {
if (scopes == null) {
scopes = "";
}
if (types == null) {
types = "";
}
if (scopes.equals("") && types.equals("")) {
return artifacts;
}
AndArtifactFilter filter = new AndArtifactFilter();
if (!scopes.equals("")) {
filter.add(new SpecificScopesArtifactFilter(getScopes()));
}
if (!types.equals("")) {
filter.add(new TypesArtifactFilter(getTypes()));
}
Set<Artifact> artifactsResult = new LinkedHashSet<Artifact>();
for (Artifact artifact : artifacts) {
if (filter.include(artifact)) {
artifactsResult.add(artifact);
}
}
return artifactsResult;
}
Aggregations