use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractAntTestMavenProjectStub method getTestArtifacts.
/**
* @see org.apache.maven.project.MavenProject#getTestArtifacts()
*/
public List getTestArtifacts() {
Artifact junit = new DefaultArtifact("junit", "junit", VersionRange.createFromVersion("3.8.2"), Artifact.SCOPE_TEST, "jar", null, new DefaultArtifactHandler("jar"), false);
junit.setFile(new File("junit/junit/3.8.2/junit-3.8.2.jar"));
return Collections.singletonList(junit);
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AbstractAntTestMavenProjectStub method getCompileArtifacts.
/**
* @see org.apache.maven.project.MavenProject#getCompileArtifacts()
*/
public List getCompileArtifacts() {
Artifact junit = new DefaultArtifact("junit", "junit", VersionRange.createFromVersion("3.8.2"), Artifact.SCOPE_TEST, "jar", null, new DefaultArtifactHandler("jar"), false);
junit.setFile(new File("junit/junit/3.8.2/junit-3.8.2.jar"));
return Collections.singletonList(junit);
}
use of org.apache.maven.artifact.Artifact 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;
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class AddDependencySetsTask method resolveDependencyArtifacts.
Set<Artifact> resolveDependencyArtifacts(final DependencySet dependencySet) throws InvalidAssemblerConfigurationException {
final Set<Artifact> dependencyArtifacts = new LinkedHashSet<Artifact>();
if (resolvedArtifacts != null) {
dependencyArtifacts.addAll(resolvedArtifacts);
}
if (dependencySet.isUseProjectArtifact()) {
final Artifact projectArtifact = project.getArtifact();
if ((projectArtifact != null) && (projectArtifact.getFile() != null)) {
dependencyArtifacts.add(projectArtifact);
} else {
logger.warn("Cannot include project artifact: " + projectArtifact + "; it doesn't have an associated file or directory.");
}
}
if (dependencySet.isUseProjectAttachments()) {
final List<Artifact> attachments = project.getAttachedArtifacts();
if (attachments != null) {
for (final Artifact attachment : attachments) {
if (attachment.getFile() != null) {
dependencyArtifacts.add(attachment);
} else {
logger.warn("Cannot include attached artifact: " + project.getId() + " for project: " + project.getId() + "; it doesn't have an associated file or directory.");
}
}
}
}
if (dependencySet.isUseTransitiveFiltering()) {
logger.debug("Filtering dependency artifacts USING transitive dependency path information.");
} else {
logger.debug("Filtering dependency artifacts WITHOUT transitive dependency path information.");
}
final ScopeFilter scopeFilter = FilterUtils.newScopeFilter(dependencySet.getScope());
final ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform(scopeFilter);
FilterUtils.filterArtifacts(dependencyArtifacts, dependencySet.getIncludes(), dependencySet.getExcludes(), dependencySet.isUseStrictFiltering(), dependencySet.isUseTransitiveFiltering(), logger, filter);
return dependencyArtifacts;
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveNonTransitively.
Set<Artifact> resolveNonTransitively(final Assembly assembly, final Set<Artifact> dependencyArtifacts, final AssemblerConfigurationSource configSource, final List<ArtifactRepository> repos) throws DependencyResolutionException {
final List<Artifact> missing = new ArrayList<Artifact>();
final Set<Artifact> resolved = new LinkedHashSet<Artifact>();
for (final Artifact depArtifact : dependencyArtifacts) {
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(configSource.getLocalRepository());
req.setRemoteRepositories(repos);
req.setArtifact(depArtifact);
ArtifactResolutionResult resolve = resolver.resolve(req);
if (resolve.hasExceptions()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to resolve: " + depArtifact.getId() + " for assembly: " + assembly.getId());
}
missing.add(depArtifact);
} else {
resolved.add(depArtifact);
}
}
if (!missing.isEmpty()) {
final MavenProject project = configSource.getProject();
final Artifact rootArtifact = project.getArtifact();
final Throwable error = new MultipleArtifactsNotFoundException(rootArtifact, new ArrayList<Artifact>(resolved), missing, repos);
throw new DependencyResolutionException("Failed to resolve dependencies for: " + assembly.getId(), error);
}
return resolved;
}
Aggregations