Search in sources :

Example 21 with DefaultArtifact

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

the class DependencyProjectStub method getArtifact.

public Artifact getArtifact() {
    if (artifact == null) {
        ArtifactHandler ah = new DefaultArtifactHandlerStub("jar", null);
        VersionRange vr = VersionRange.createFromVersion("1.0");
        Artifact art = new DefaultArtifact("group", "artifact", vr, Artifact.SCOPE_COMPILE, "jar", null, ah, false);
        setArtifact(art);
    }
    return artifact;
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) DefaultArtifactHandlerStub(org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub) VersionRange(org.apache.maven.artifact.versioning.VersionRange) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 22 with DefaultArtifact

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

the class TestDefaultMarkerFileHandler 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);
    outputFolder = new File("target/markers/");
    DependencyTestUtils.removeDirectory(this.outputFolder);
    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) 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)

Example 23 with DefaultArtifact

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

the class TestJavadocMavenProjectStub method getArtifacts.

@Override
public Set<Artifact> getArtifacts() {
    Artifact junit = new DefaultArtifact("junit", "junit", VersionRange.createFromVersion("3.8.1"), Artifact.SCOPE_TEST, "jar", null, new DefaultArtifactHandler("jar"), false);
    junit.setFile(new File(getBasedir() + "/junit/junit/3.8.1/junit-3.8.1.jar"));
    return Collections.singleton(junit);
}
Also used : DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) File(java.io.File) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 24 with DefaultArtifact

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

the class Maven2ServerEmbedderImpl 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, VersionRange.createFromVersion(""), Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
        ArtifactRepositoryLayout repositoryLayout = getComponent(ArtifactRepositoryLayout.class);
        List versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(artifact, new DefaultArtifactRepository("local", getLocalRepositoryFile().getPath(), repositoryLayout), convertRepositories(remoteRepositories));
        List<String> result = new ArrayList<String>();
        for (Object version : versions) {
            result.add(version.toString());
        }
        return result;
    } catch (Exception e) {
        Maven2ServerGlobals.getLogger().info(e);
    }
    return Collections.emptyList();
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) DefaultArtifactHandler(org.apache.maven.artifact.handler.DefaultArtifactHandler) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) 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) TimeoutException(java.util.concurrent.TimeoutException) ArtifactNotFoundException(org.apache.maven.artifact.resolver.ArtifactNotFoundException) InitializationException(org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException) ModelInterpolationException(org.apache.maven.project.interpolation.ModelInterpolationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ContextException(org.codehaus.plexus.context.ContextException) ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ExecutionException(java.util.concurrent.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with DefaultArtifact

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

Aggregations

DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)51 Artifact (org.apache.maven.artifact.Artifact)35 File (java.io.File)26 DefaultArtifactHandler (org.apache.maven.artifact.handler.DefaultArtifactHandler)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)9 MavenProjectResourcesStub (org.apache.maven.plugin.resources.remote.stub.MavenProjectResourcesStub)7 ArrayList (java.util.ArrayList)4 Random (java.util.Random)4 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 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2