use of org.apache.maven.artifact.Artifact in project randomizedtesting by randomizedtesting.
the class JUnit4Mojo method validateParameters.
/**
* Initial validation of input parameters and configuration.
*/
private void validateParameters() throws MojoExecutionException {
// Check for junit dependency on project level.
Artifact junitArtifact = projectArtifactMap.get(junitArtifactName);
if (junitArtifact == null) {
throw new MojoExecutionException("Missing JUnit artifact in project dependencies: " + junitArtifactName);
}
checkVersion("JUnit", "[4.10,)", junitArtifact);
// Fill in complex defaults if not given.
if (includes == null || includes.isEmpty()) {
includes = Arrays.asList("**/Test*.class", "**/*Test.class");
}
if (excludes == null || excludes.isEmpty()) {
excludes = Arrays.asList("**/*$*.class");
}
}
use of org.apache.maven.artifact.Artifact in project randomizedtesting by randomizedtesting.
the class JUnit4Mojo method resolveArtifact.
/**
* Resolve a given artifact given exclusion list. (copied from surefire).
*/
@SuppressWarnings({ "deprecation" })
private ArtifactResolutionResult resolveArtifact(Artifact artifact, Artifact... filtered) {
final ArtifactFilter filter;
if (filtered.length > 0) {
List<String> exclusions = new ArrayList<>(filtered.length);
for (Artifact filteredArtifact : filtered) {
exclusions.add(filteredArtifact.getGroupId() + ":" + filteredArtifact.getArtifactId());
}
filter = new ExcludesArtifactFilter(exclusions);
} else {
filter = null;
}
Artifact originatingArtifact = repositorySystem.createArtifact("dummy", "dummy", "1.0", "jar");
try {
return resolver.resolveTransitively(Collections.singleton(artifact), originatingArtifact, session.getLocalRepository(), project.getPluginArtifactRepositories(), metadataSource, filter);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class IncludeFilterTests method includeGroupIdNoMatch.
@Test
public void includeGroupIdNoMatch() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.baz", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertThat(result).isEmpty();
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class ArtifactsLibrariesTests method renamesDuplicates.
@Test
public void renamesDuplicates() throws Exception {
Artifact artifact1 = mock(Artifact.class);
Artifact artifact2 = mock(Artifact.class);
given(artifact1.getType()).willReturn("jar");
given(artifact1.getScope()).willReturn("compile");
given(artifact1.getGroupId()).willReturn("g1");
given(artifact1.getArtifactId()).willReturn("artifact");
given(artifact1.getBaseVersion()).willReturn("1.0");
given(artifact1.getFile()).willReturn(new File("a"));
given(artifact1.getArtifactHandler()).willReturn(this.artifactHandler);
given(artifact2.getType()).willReturn("jar");
given(artifact2.getScope()).willReturn("compile");
given(artifact2.getGroupId()).willReturn("g2");
given(artifact2.getArtifactId()).willReturn("artifact");
given(artifact2.getBaseVersion()).willReturn("1.0");
given(artifact2.getFile()).willReturn(new File("a"));
given(artifact2.getArtifactHandler()).willReturn(this.artifactHandler);
this.artifacts = new LinkedHashSet<>(Arrays.asList(artifact1, artifact2));
this.libs = new ArtifactsLibraries(this.artifacts, null, mock(Log.class));
this.libs.doWithLibraries(this.callback);
verify(this.callback, times(2)).library(this.libraryCaptor.capture());
assertThat(this.libraryCaptor.getAllValues().get(0).getName()).isEqualTo("g1-artifact-1.0.jar");
assertThat(this.libraryCaptor.getAllValues().get(1).getName()).isEqualTo("g2-artifact-1.0.jar");
}
use of org.apache.maven.artifact.Artifact in project spring-boot by spring-projects.
the class DependencyFilterMojoTests method filterScopeKeepOrder.
@Test
public void filterScopeKeepOrder() throws MojoExecutionException {
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.<Exclude>emptyList(), "", "", new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
Artifact one = createArtifact("com.foo", "one");
Artifact two = createArtifact("com.foo", "two", Artifact.SCOPE_SYSTEM);
Artifact three = createArtifact("com.foo", "three", Artifact.SCOPE_RUNTIME);
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three);
assertThat(artifacts).containsExactly(one, three);
}
Aggregations