Search in sources :

Example 11 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler in project intellij-community by JetBrains.

the class Maven3ServerEmbedder method retrieveAvailableVersions.

@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId, @NotNull String artifactId, @NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException {
    try {
        Artifact artifact = new DefaultArtifact(groupId, artifactId, "", Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
        List<ArtifactVersion> versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact, getLocalRepository(), convertRepositories(remoteRepositories));
        return ContainerUtil.map(versions, new Function<ArtifactVersion, String>() {

            @Override
            public String fun(ArtifactVersion version) {
                return version.toString();
            }
        });
    } catch (Exception e) {
        Maven3ServerGlobals.getLogger().info(e);
    }
    return Collections.emptyList();
}
Also used : ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) RemoteException(java.rmi.RemoteException) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler 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)

Example 13 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler 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 14 with DefaultArtifactHandler

use of org.apache.maven.artifact.handler.DefaultArtifactHandler 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 15 with DefaultArtifactHandler

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

the class TestSourcesMarkerFileHandler method setUp.

protected void setUp() throws Exception {
    super.setUp();
    ArtifactHandler ah = new DefaultArtifactHandler();
    VersionRange vr = VersionRange.createFromVersion("1.1");
    Artifact artifact = new DefaultArtifact("test", "1", vr, Artifact.SCOPE_COMPILE, "jar", "", ah, false);
    artifacts.add(artifact);
    artifact = new DefaultArtifact("test", "2", vr, Artifact.SCOPE_PROVIDED, "war", "", ah, false);
    artifacts.add(artifact);
    artifact = new DefaultArtifact("test", "3", vr, Artifact.SCOPE_TEST, "sources", "", ah, false);
    artifacts.add(artifact);
    artifact = new DefaultArtifact("test", "4", vr, Artifact.SCOPE_RUNTIME, "zip", "", ah, false);
    artifacts.add(artifact);
    // pick random output location
    Random a = new Random();
    outputFolder = new File("target/markers" + a.nextLong() + "/");
    outputFolder.delete();
    assertFalse(outputFolder.exists());
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) Random(java.util.Random) VersionRange(org.apache.maven.artifact.versioning.VersionRange) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Aggregations

DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)17 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)16 File (java.io.File)12 Artifact (org.apache.maven.artifact.Artifact)9 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)7 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7 MavenProject (org.apache.maven.project.MavenProject)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 RemoteException (java.rmi.RemoteException)2 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)2 ArtifactMetadataSource (org.apache.maven.artifact.metadata.ArtifactMetadataSource)2 VersionRange (org.apache.maven.artifact.versioning.VersionRange)2 ModelBuildingException (org.apache.maven.model.building.ModelBuildingException)2 NotNull (org.jetbrains.annotations.NotNull)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UnicastRemoteObject (java.rmi.server.UnicastRemoteObject)1