use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class AbstractRunMojo method addDependencies.
private void addDependencies(List<URL> urls) throws MalformedURLException, MojoExecutionException {
FilterArtifacts filters = this.useTestClasspath ? getFilters() : getFilters(new TestArtifactFilter());
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), filters);
for (Artifact artifact : artifacts) {
if (artifact.getFile() != null) {
urls.add(artifact.getFile().toURI().toURL());
}
}
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class ArtifactsLibraries method doWithLibraries.
@Override
public void doWithLibraries(LibraryCallback callback) throws IOException {
Set<String> duplicates = getDuplicates(this.artifacts);
for (Artifact artifact : this.artifacts) {
LibraryScope scope = SCOPES.get(artifact.getScope());
if (scope != null && artifact.getFile() != null) {
String name = getFileName(artifact);
if (duplicates.contains(name)) {
this.log.debug("Duplicate found: " + name);
name = artifact.getGroupId() + "-" + name;
this.log.debug("Renamed to: " + name);
}
callback.library(new Library(name, artifact.getFile(), scope, isUnpackRequired(artifact)));
}
}
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class DependencyFilterMojoTests method filterGroupIdKeepOrder.
@Test
public void filterGroupIdKeepOrder() throws MojoExecutionException {
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.<Exclude>emptyList(), "com.foo", "");
Artifact one = createArtifact("com.foo", "one");
Artifact two = createArtifact("com.bar", "two");
Artifact three = createArtifact("com.bar", "three");
Artifact four = createArtifact("com.foo", "four");
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three, four);
assertThat(artifacts).containsExactly(two, three);
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class ExcludeFilterTests method excludeGroupIdNoMatch.
@Test
public void excludeGroupIdNoMatch() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.baz", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertThat(result).hasSize(1);
assertThat(result.iterator().next()).isSameAs(artifact);
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class IncludeFilterTests method createArtifact.
private Artifact createArtifact(String groupId, String artifactId, String classifier) {
Artifact a = mock(Artifact.class);
given(a.getGroupId()).willReturn(groupId);
given(a.getArtifactId()).willReturn(artifactId);
given(a.getClassifier()).willReturn(classifier);
return a;
}
Aggregations