use of org.apache.maven.plugins.ear.util.ArtifactRepository in project maven-plugins by apache.
the class ArtifactRepositoryTest method testRepositoryWithOneUnclassifiedArtifact.
@Test
public void testRepositoryWithOneUnclassifiedArtifact() {
ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", null));
}
use of org.apache.maven.plugins.ear.util.ArtifactRepository in project maven-plugins by apache.
the class ArtifactRepositoryTest method testRepositoryWithOneClassifiedArtifact.
@Test
public void testRepositoryWithOneClassifiedArtifact() {
ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact" }, null, null, new String[] { "classified" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "classified"));
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "wrong"));
}
use of org.apache.maven.plugins.ear.util.ArtifactRepository in project maven-plugins by apache.
the class EarExecutionContext method initialize.
private void initialize(MavenProject project, String mainArtifactId, String defaultLibBundleDir, JbossConfiguration jbossConfiguration, String fileNameMappingName, ArtifactTypeMappingService typeMappingService) {
this.artifactRepository = new ArtifactRepository(project.getArtifacts(), mainArtifactId, typeMappingService);
this.defaultLibBundleDir = defaultLibBundleDir;
this.jbossConfiguration = jbossConfiguration;
if (fileNameMappingName == null || fileNameMappingName.trim().length() == 0) {
this.fileNameMapping = FileNameMappingFactory.getDefaultFileNameMapping();
} else {
this.fileNameMapping = FileNameMappingFactory.getFileNameMapping(fileNameMappingName);
}
}
use of org.apache.maven.plugins.ear.util.ArtifactRepository in project maven-plugins by apache.
the class AbstractEarModule method resolveArtifact.
/** {@inheritDoc} */
public void resolveArtifact(Set<Artifact> artifacts) throws EarPluginException, MojoFailureException {
// If the artifact is already set no need to resolve it
if (artifact == null) {
// Make sure that at least the groupId and the artifactId are specified
if (groupId == null || artifactId == null) {
throw new MojoFailureException("Could not resolve artifact[" + groupId + ":" + artifactId + ":" + getType() + "]");
}
final ArtifactRepository ar = earExecutionContext.getArtifactRepository();
artifact = ar.getUniqueArtifact(groupId, artifactId, getType(), classifier);
// Artifact has not been found
if (artifact == null) {
Set<Artifact> candidates = ar.getArtifacts(groupId, artifactId, getType());
if (candidates.size() > 1) {
throw new MojoFailureException("Artifact[" + this + "] has " + candidates.size() + " candidates, please provide a classifier.");
} else {
throw new MojoFailureException("Artifact[" + this + "] is not a dependency of the project.");
}
}
}
}
use of org.apache.maven.plugins.ear.util.ArtifactRepository in project maven-plugins by apache.
the class ArtifactRepositoryTest method testRepositoryWithMultipleClassifiedArtifacts.
@Test
public void testRepositoryWithMultipleClassifiedArtifacts() {
ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact", "myartifact", "myartifact" }, null, null, new String[] { "class1", "class2", "class3" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class1"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class2"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class3"));
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "wrong"));
}
Aggregations