Search in sources :

Example 36 with Dependency

use of org.apache.maven.model.Dependency in project sling by apache.

the class ArtifactDefinition method toDependencyList.

public List<Dependency> toDependencyList(String scope) {
    ArrayList<Dependency> depList = new ArrayList<Dependency>();
    if (bundles == null) {
        Dependency dep = new Dependency();
        dep.setArtifactId(artifactId);
        dep.setGroupId(groupId);
        dep.setVersion(version);
        if (type != null) {
            dep.setType(type);
        }
        dep.setClassifier(classifier);
        dep.setScope(scope);
        depList.add(dep);
    } else {
        for (ArtifactDefinition bundle : bundles) {
            depList.addAll(bundle.toDependencyList(scope));
        }
    }
    return depList;
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency)

Example 37 with Dependency

use of org.apache.maven.model.Dependency in project sling by apache.

the class StartMojo method findLaunchpadJar.

/**
     * Finds the launchpad.jar artifact of the project being built.
     *
     * @return the launchpad.jar artifact
     * @throws MojoFailureException if a launchpad.jar artifact was not found
     */
private File findLaunchpadJar() throws MojoFailureException, MojoExecutionException {
    // If a launchpad JAR is specified, use it
    if (launchpadJar != null) {
        getLog().info("Using launchpad jar from '" + launchpadJar + "' given as configuration parameter!");
        return launchpadJar;
    }
    // If a launchpad dependency is configured, resolve it
    if (launchpadDependency != null) {
        getLog().info("Using launchpad dependency '" + launchpadDependency + "' given as configuration parameter!");
        return getArtifact(launchpadDependency).getFile();
    }
    // If the current project is a slingstart project, use its JAR artifact
    if (this.project.getPackaging().equals(BuildConstants.PACKAGING_SLINGSTART)) {
        File jarFile = project.getArtifact().getFile();
        if (jarFile != null && jarFile.exists()) {
            getLog().info("Using launchpad jar being generated as this project's primary artifact: '" + jarFile + "'!");
            return jarFile;
        } else {
            jarFile = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".jar");
            if (jarFile.exists()) {
                getLog().info("Using launchpad jar being generated as this project's primary artifact: '" + jarFile + "'!");
                return jarFile;
            }
        }
    }
    // In case there was a provisioning model found but this is not a slingstart project, the JAR might be attached already through goal "package"
    for (Artifact attachedArtifact : project.getAttachedArtifacts()) {
        // find the attached artifact with classifier "standalone"
        if (BuildConstants.TYPE_JAR.equals(attachedArtifact.getType()) && BuildConstants.CLASSIFIER_APP.equals(attachedArtifact.getClassifier())) {
            getLog().info("Using launchpad jar being attached as additional project artifact: '" + attachedArtifact.getFile() + "'!");
            return attachedArtifact.getFile();
        }
    }
    // Last chance: use the first declared dependency with type "slingstart"
    final Set<Artifact> dependencies = this.project.getDependencyArtifacts();
    for (final Artifact dep : dependencies) {
        if (BuildConstants.PACKAGING_SLINGSTART.equals(dep.getType())) {
            final Dependency d = new Dependency();
            d.setGroupId(dep.getGroupId());
            d.setArtifactId(dep.getArtifactId());
            d.setVersion(dep.getVersion());
            d.setScope(Artifact.SCOPE_RUNTIME);
            d.setType(BuildConstants.TYPE_JAR);
            getLog().info("Using launchpad jar from first dependency of type 'slingstart': '" + d + "'!");
            return getArtifact(d).getFile();
        }
    }
    // Launchpad has not been found, throw an exception
    throw new MojoFailureException("Could not find the launchpad jar. " + "Either specify the 'launchpadJar' configuration or use this inside a slingstart project.");
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException) Dependency(org.apache.maven.model.Dependency) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact)

Example 38 with Dependency

use of org.apache.maven.model.Dependency 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)

Example 39 with Dependency

use of org.apache.maven.model.Dependency in project gradle by gradle.

the class MavenPomFileGenerator method addDependencyManagement.

private void addDependencyManagement(MavenDependency dependency, String scope) {
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency.getGroupId());
    mavenDependency.setArtifactId(dependency.getArtifactId());
    mavenDependency.setVersion(mapToMavenSyntax(dependency.getVersion()));
    mavenDependency.setScope(scope);
    DependencyManagement dependencyManagement = getModel().getDependencyManagement();
    if (dependencyManagement == null) {
        dependencyManagement = new DependencyManagement();
        getModel().setDependencyManagement(dependencyManagement);
    }
    dependencyManagement.addDependency(mavenDependency);
}
Also used : MavenDependency(org.gradle.api.publish.maven.MavenDependency) Dependency(org.apache.maven.model.Dependency) DependencyManagement(org.apache.maven.model.DependencyManagement)

Example 40 with Dependency

use of org.apache.maven.model.Dependency in project drools by kiegroup.

the class AbstractKieCiTest method dependencyWithScope.

protected Dependency dependencyWithScope(String groupId, String artifactId, String version, String scope) {
    Dependency dep1 = new Dependency();
    dep1.setGroupId(groupId);
    dep1.setArtifactId(artifactId);
    dep1.setVersion(version);
    dep1.setScope(scope);
    return dep1;
}
Also used : Dependency(org.apache.maven.model.Dependency)

Aggregations

Dependency (org.apache.maven.model.Dependency)78 ArrayList (java.util.ArrayList)24 Artifact (org.apache.maven.artifact.Artifact)18 File (java.io.File)12 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)11 MavenProject (org.apache.maven.project.MavenProject)8 IOException (java.io.IOException)7 Exclusion (org.apache.maven.model.Exclusion)7 MojoFailureException (org.apache.maven.plugin.MojoFailureException)7 WebappStructure (org.apache.maven.plugins.war.util.WebappStructure)7 HashMap (java.util.HashMap)6 DependencyManagement (org.apache.maven.model.DependencyManagement)5 Model (org.apache.maven.model.Model)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Plugin (org.apache.maven.model.Plugin)4 List (java.util.List)3 Properties (java.util.Properties)3 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)3