Search in sources :

Example 31 with ArtifactRepository

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

the class JiraUnicodeTestProjectStub method getRemoteArtifactRepositories.

/**
 * {@inheritDoc}
 */
@Override
public List<ArtifactRepository> getRemoteArtifactRepositories() {
    ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE);
    ArtifactRepository repository = new MavenArtifactRepository("central", "http://repo1.maven.org/maven2", new DefaultRepositoryLayout(), policy, policy);
    return Collections.singletonList(repository);
}
Also used : ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository)

Example 32 with ArtifactRepository

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

the class RemoteResourcesMojoTest method testVelocityUTF8.

public void testVelocityUTF8() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-utf8");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.2" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.2"), null, "jar", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-utf8-create", "UTF-8", new String[] { "UTF-8.bin.vm" }, file);
    mojo.execute();
    file = (File) getVariableValueFromObject(mojo, "outputDirectory");
    file = new File(file, "UTF-8.bin");
    assertTrue(file.exists());
    InputStream in = new FileInputStream(file);
    byte[] data = IOUtil.toByteArray(in);
    in.close();
    byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes("UTF-8");
    assertTrue(Arrays.equals(expected, data));
}
Also used : MavenProjectResourcesStub(org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) FileInputStream(java.io.FileInputStream)

Example 33 with ArtifactRepository

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

the class RemoteResourcesMojoTest method testVelocityISO88591.

public void testVelocityISO88591() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-iso88591");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.3" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.3"), null, "jar", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-iso88591-create", "ISO-8859-1", new String[] { "ISO-8859-1.bin.vm" }, file);
    mojo.execute();
    file = (File) getVariableValueFromObject(mojo, "outputDirectory");
    file = new File(file, "ISO-8859-1.bin");
    assertTrue(file.exists());
    InputStream in = new FileInputStream(file);
    byte[] data = IOUtil.toByteArray(in);
    in.close();
    byte[] expected = "\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF".getBytes("ISO-8859-1");
    assertTrue(Arrays.equals(expected, data));
}
Also used : MavenProjectResourcesStub(org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) FileInputStream(java.io.FileInputStream)

Example 34 with ArtifactRepository

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

the class RemoteResourcesMojoTest method testSimpleBundlesWithType.

public void testSimpleBundlesWithType() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-simplebundles");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test:test:1.0:war" });
    setupDefaultProject(project);
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test", "test", VersionRange.createFromVersion("1.0"), null, "war", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".war");
    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 35 with ArtifactRepository

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

the class RemoteResourcesMojoTest method testFilteredBundlesWithProjectProperties.

public void testFilteredBundlesWithProjectProperties() throws Exception {
    final MavenProjectResourcesStub project = createTestProject("default-filterbundles-two");
    final ProcessRemoteResourcesMojo mojo = lookupProcessMojoWithSettings(project, new String[] { "test-filtered-bundles:test-filtered-bundles:2" });
    mojo.includeProjectProperties = true;
    setupDefaultProject(project);
    project.addProperty("testingPropertyOne", "maven");
    project.addProperty("testingPropertyTwo", "rules");
    ArtifactRepository repo = (ArtifactRepository) getVariableValueFromObject(mojo, "localRepository");
    String path = repo.pathOf(new DefaultArtifact("test-filtered-bundles", "test-filtered-bundles", VersionRange.createFromVersion("2"), null, "jar", "", new DefaultArtifactHandler()));
    File file = new File(repo.getBasedir() + "/" + path + ".jar");
    file.getParentFile().mkdirs();
    buildResourceBundle("default-filterbundles-two-create", null, new String[] { "PROPERTIES.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, "PROPERTIES.txt");
    assertTrue(file.exists());
    String data = FileUtils.fileRead(file);
    assertTrue(data.contains("maven"));
    assertTrue(data.contains("rules"));
}
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

ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)108 File (java.io.File)46 Artifact (org.apache.maven.artifact.Artifact)26 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)26 ArrayList (java.util.ArrayList)23 MavenProject (org.apache.maven.project.MavenProject)20 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)17 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)15 IOException (java.io.IOException)13 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)13 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)11 Properties (java.util.Properties)10 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)9 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)9 Model (org.apache.maven.model.Model)9 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)8 MojoFailureException (org.apache.maven.plugin.MojoFailureException)8 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)8 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)8 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7