use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class TestCopyDependenciesMojo2 method testCopyDependenciesMojoIncludeRuntimeScope.
public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception {
mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts());
mojo.getProject().setDependencyArtifacts(new HashSet<Artifact>());
mojo.includeScope = "runtime";
mojo.execute();
ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.includeScope);
Set<Artifact> artifacts = mojo.getProject().getArtifacts();
for (Artifact artifact : artifacts) {
String fileName = DependencyUtil.getFormattedFileName(artifact, false);
File file = new File(mojo.outputDirectory, fileName);
assertEquals(saf.include(artifact), file.exists());
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class TestCopyDependenciesMojo2 method testCopyDependenciesMojoIncludeprovidedScope.
public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception {
mojo.getProject().setArtifacts(stubFactory.getScopedArtifacts());
mojo.getProject().setDependencyArtifacts(new HashSet<Artifact>());
mojo.includeScope = "provided";
mojo.execute();
Set<Artifact> artifacts = mojo.getProject().getArtifacts();
for (Artifact artifact : artifacts) {
String fileName = DependencyUtil.getFormattedFileName(artifact, false);
File file = new File(mojo.outputDirectory, fileName);
assertEquals(Artifact.SCOPE_PROVIDED.equals(artifact.getScope()), file.exists());
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class TestCopyDependenciesMojo2 method createExpandedVersionArtifact.
private Artifact createExpandedVersionArtifact(String baseVersion, String groupId, String artifactId, String scope, String type, String classifier) throws IOException {
Artifact expandedSnapshot = this.stubFactory.createArtifact(groupId, artifactId, VersionRange.createFromVersion(baseVersion), scope, type, classifier, false);
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp("20130710.122148");
snapshot.setBuildNumber(1);
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata(expandedSnapshot, snapshot);
String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber();
expandedSnapshot.setResolvedVersion(StringUtils.replace(baseVersion, Artifact.SNAPSHOT_VERSION, newVersion));
expandedSnapshot.addMetadata(metadata);
return expandedSnapshot;
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class TestCopyDependenciesMojo2 method testSubPerArtifactAndTypeRemoveVersion.
public void testSubPerArtifactAndTypeRemoveVersion() throws Exception {
mojo.getProject().setArtifacts(stubFactory.getTypedArtifacts());
mojo.getProject().setDependencyArtifacts(new HashSet<Artifact>());
mojo.useSubDirectoryPerArtifact = true;
mojo.useSubDirectoryPerType = true;
mojo.stripVersion = true;
mojo.execute();
Set<Artifact> artifacts = mojo.getProject().getArtifacts();
for (Artifact artifact : artifacts) {
String fileName = DependencyUtil.getFormattedFileName(artifact, true);
File folder = DependencyUtil.getFormattedOutputDirectory(false, true, true, false, true, mojo.outputDirectory, artifact);
File file = new File(folder, fileName);
assertTrue(file.exists());
}
}
use of org.apache.maven.artifact.Artifact in project maven-plugins by apache.
the class TestCopyDependenciesMojo2 method testSubPerArtifact.
public void testSubPerArtifact() throws Exception {
mojo.useSubDirectoryPerArtifact = true;
mojo.execute();
Set<Artifact> artifacts = mojo.getProject().getArtifacts();
for (Artifact artifact : artifacts) {
String fileName = DependencyUtil.getFormattedFileName(artifact, false);
File folder = DependencyUtil.getFormattedOutputDirectory(false, false, true, false, false, mojo.outputDirectory, artifact);
File file = new File(folder, fileName);
assertTrue(file.exists());
}
}
Aggregations