Search in sources :

Example 41 with Artifact

use of org.apache.maven.artifact.Artifact in project jangaroo-tools by CoreMedia.

the class UnpackJarResourcesMojo method unpack.

public void unpack(File target) throws ArchiverException {
    unarchiver.setOverwrite(false);
    unarchiver.setFileSelectors(new FileSelector[] { new MetaInfResourcesFileSelector() });
    Set<Artifact> dependencies = getArtifacts();
    for (Artifact dependency : dependencies) {
        getLog().debug("Dependency: " + dependency);
        if (!dependency.isOptional() && "jar".equals(dependency.getType())) {
            unpack(unarchiver, dependency, target);
        }
    }
}
Also used : Artifact(org.apache.maven.artifact.Artifact)

Example 42 with Artifact

use of org.apache.maven.artifact.Artifact in project kotlin by JetBrains.

the class ExecuteKotlinScriptMojo method getDependencyFile.

private File getDependencyFile(ComponentDependency dep) {
    ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(dep.getType());
    Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), null, dep.getType(), null, artifactHandler);
    return getArtifactFile(artifact);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 43 with Artifact

use of org.apache.maven.artifact.Artifact in project kotlin by JetBrains.

the class ExecuteKotlinScriptMojo method getKotlinRuntimeDependencies.

private List<File> getKotlinRuntimeDependencies() throws MojoExecutionException {
    Artifact stdlibDep = null;
    Artifact runtimeDep = null;
    ArrayList<File> files = new ArrayList<File>(2);
    for (Artifact dep : project.getArtifacts()) {
        if (dep.getArtifactId().equals("kotlin-stdlib")) {
            files.add(getArtifactFile(dep));
            stdlibDep = dep;
        }
        if (dep.getArtifactId().equals("kotlin-runtime")) {
            files.add(getArtifactFile(dep));
            runtimeDep = dep;
        }
        if (stdlibDep != null && runtimeDep != null)
            break;
    }
    if (stdlibDep == null) {
        throw new MojoExecutionException("Unable to find kotlin-stdlib artifacts among project dependencies");
    }
    return files;
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 44 with Artifact

use of org.apache.maven.artifact.Artifact in project kotlin by JetBrains.

the class ExecuteKotlinScriptMojo method getDependencyFile.

private File getDependencyFile(Dependency dep) {
    ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(dep.getType());
    Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), null, dep.getType(), null, artifactHandler);
    return getArtifactFile(artifact);
}
Also used : ArtifactHandler(org.apache.maven.artifact.handler.ArtifactHandler) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 45 with Artifact

use of org.apache.maven.artifact.Artifact in project kotlin by JetBrains.

the class KotlinCompileMojoBase method getCompilerPluginClassPaths.

private List<String> getCompilerPluginClassPaths() {
    ArrayList<String> result = new ArrayList<String>();
    List<File> files = new ArrayList<File>();
    for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) {
        Artifact artifact = system.createDependencyArtifact(dependency);
        ArtifactResolutionResult resolved = system.resolve(new ArtifactResolutionRequest().setArtifact(artifact));
        for (Artifact resolvedArtifact : resolved.getArtifacts()) {
            File file = resolvedArtifact.getFile();
            if (file != null && file.exists()) {
                files.add(file);
            }
        }
    }
    for (File file : files) {
        result.add(file.getAbsolutePath());
    }
    return result;
}
Also used : ArtifactResolutionRequest(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) ArtifactResolutionResult(org.apache.maven.artifact.resolver.ArtifactResolutionResult) Dependency(org.apache.maven.model.Dependency) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

Artifact (org.apache.maven.artifact.Artifact)450 File (java.io.File)175 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)92 ArrayList (java.util.ArrayList)91 MavenProject (org.apache.maven.project.MavenProject)63 IOException (java.io.IOException)50 HashSet (java.util.HashSet)42 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)32 LinkedHashSet (java.util.LinkedHashSet)29 MojoFailureException (org.apache.maven.plugin.MojoFailureException)24 HashMap (java.util.HashMap)22 Set (java.util.Set)22 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)22 ScopeArtifactFilter (org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter)21 URL (java.net.URL)20 ArtifactNotFoundException (org.apache.maven.artifact.resolver.ArtifactNotFoundException)20 Test (org.junit.Test)20 MalformedURLException (java.net.MalformedURLException)18 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)17 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)16