Search in sources :

Example 1 with ArtifactRepository

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));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

Example 2 with ArtifactRepository

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"));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

Example 3 with ArtifactRepository

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);
    }
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository)

Example 4 with ArtifactRepository

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.");
            }
        }
    }
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException) ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) Artifact(org.apache.maven.artifact.Artifact)

Example 5 with ArtifactRepository

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"));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

Aggregations

ArtifactRepository (org.apache.maven.plugins.ear.util.ArtifactRepository)7 ArtifactTypeMappingService (org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)5 Test (org.junit.Test)5 Artifact (org.apache.maven.artifact.Artifact)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1