Search in sources :

Example 51 with DefaultArtifact

use of org.apache.maven.artifact.DefaultArtifact in project maven-plugins by apache.

the class ResourceResolver method createResourceArtifact.

private Artifact createResourceArtifact(final Artifact artifact, final String classifier, final SourceResolverConfig config) {
    final DefaultArtifact a = (DefaultArtifact) artifactFactory.createArtifactWithClassifier(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), "jar", classifier);
    a.setRepository(artifact.getRepository());
    return a;
}
Also used : DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 52 with DefaultArtifact

use of org.apache.maven.artifact.DefaultArtifact in project maven-plugins by apache.

the class RemoteResourcesMojoTest method testFilteredBundles.

public void testFilteredBundles() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-filterbundles");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.1" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.1"), null, "jar", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-filterbundles-create", null, new String[] { "FILTER.txt.vm" }, file);
    mojo.execute();
    // executing a second time (example: forked lifecycle) should still work
    mojo.execute();
    file = (File) getVariableValueFromObject(mojo, "outputDirectory");
    file = new File(file, "FILTER.txt");
    assertTrue(file.exists());
    String data = FileUtils.fileRead(file);
    assertTrue(data.contains("2007"));
    assertTrue(data.contains("default-filterbundles"));
}
Also used : MavenProjectResourcesStub(org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 53 with DefaultArtifact

use of org.apache.maven.artifact.DefaultArtifact in project maven-plugins by apache.

the class RemoteResourcesMojoTest method testSimpleBundlesWithClassifier.

public void testSimpleBundlesWithClassifier() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.0:jar:test" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.0"), null, "jar", "test", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-simplebundles-create", null, new String[] { "SIMPLE.txt" }, file);
    mojo.execute();
    file = (File) getVariableValueFromObject(mojo, "outputDirectory");
    file = new File(file, "SIMPLE.txt");
    assertTrue(file.exists());
}
Also used : MavenProjectResourcesStub(org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 54 with DefaultArtifact

use of org.apache.maven.artifact.DefaultArtifact in project maven-plugins by apache.

the class RemoteResourcesMojoTest method testSimpleBundles.

public void testSimpleBundles() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.0" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.0"), null, "jar", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-simplebundles-create", null, new String[] { "SIMPLE.txt" }, file);
    mojo.execute();
    file = (File) getVariableValueFromObject(mojo, "outputDirectory");
    file = new File(file, "SIMPLE.txt");
    assertTrue(file.exists());
}
Also used : MavenProjectResourcesStub(org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)54 Artifact (org.apache.maven.artifact.Artifact)37 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)29 File (java.io.File)26 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)22 VersionRange (org.apache.maven.artifact.versioning.VersionRange)17 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)10 DefaultArtifactHandlerStub (org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub)10 MavenProject (org.apache.maven.project.MavenProject)10 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7 ArrayList (java.util.ArrayList)4 Random (java.util.Random)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 List (java.util.List)3 Map (java.util.Map)3 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 FileInputStream (java.io.FileInputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2