Search in sources :

Example 61 with Dependency

use of org.apache.maven.model.Dependency in project maven-plugins by apache.

the class TestAnalyzeDepMgt method setUp.

protected void setUp() throws Exception {
    mojo = new AnalyzeDepMgt();
    MavenProject project = new DependencyProjectStub();
    stubFactory = new DependencyArtifactStubFactory(new File(""), false);
    Set<Artifact> allArtifacts = stubFactory.getMixedArtifacts();
    Set<Artifact> directArtifacts = stubFactory.getClassifiedArtifacts();
    exclusionArtifact = stubFactory.getReleaseArtifact();
    directArtifacts.add(exclusionArtifact);
    ex = new Exclusion();
    ex.setArtifactId(exclusionArtifact.getArtifactId());
    ex.setGroupId(exclusionArtifact.getGroupId());
    exclusion = new Dependency();
    exclusion.setArtifactId(exclusionArtifact.getArtifactId());
    exclusion.setGroupId(exclusionArtifact.getGroupId());
    exclusion.setType(exclusionArtifact.getType());
    exclusion.setClassifier("");
    exclusion.setVersion("3.0");
    exclusion.addExclusion(ex);
    List<Dependency> list = new ArrayList<Dependency>();
    list.add(exclusion);
    depMgt = new DependencyManagement();
    depMgt.setDependencies(list);
    project.setArtifacts(allArtifacts);
    project.setDependencyArtifacts(directArtifacts);
    mojo.setProject(project);
}
Also used : AnalyzeDepMgt(org.apache.maven.plugins.dependency.analyze.AnalyzeDepMgt) MavenProject(org.apache.maven.project.MavenProject) Exclusion(org.apache.maven.model.Exclusion) ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency) DependencyProjectStub(org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) DependencyManagement(org.apache.maven.model.DependencyManagement) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)

Example 62 with Dependency

use of org.apache.maven.model.Dependency in project maven-plugins by apache.

the class TestUnpackMojo method getDependencyMgtList.

public List<Dependency> getDependencyMgtList(ArtifactItem item) {
    Dependency dep = new Dependency();
    dep.setArtifactId(item.getArtifactId());
    dep.setClassifier(item.getClassifier());
    dep.setGroupId(item.getGroupId());
    dep.setType(item.getType());
    dep.setVersion("3.0-SNAPSHOT");
    Dependency dep2 = new Dependency();
    dep2.setArtifactId(item.getArtifactId());
    dep2.setClassifier("classifier");
    dep2.setGroupId(item.getGroupId());
    dep2.setType(item.getType());
    dep2.setVersion("3.1");
    List<Dependency> list = new ArrayList<Dependency>(2);
    list.add(dep2);
    list.add(dep);
    return list;
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency)

Example 63 with Dependency

use of org.apache.maven.model.Dependency in project maven-plugins by apache.

the class TestCopyMojo method getDependencyMgtList.

public List<Dependency> getDependencyMgtList(ArtifactItem item) {
    Dependency dep = new Dependency();
    dep.setArtifactId(item.getArtifactId());
    dep.setClassifier(item.getClassifier());
    dep.setGroupId(item.getGroupId());
    dep.setType(item.getType());
    dep.setVersion("3.0-SNAPSHOT");
    Dependency dep2 = new Dependency();
    dep2.setArtifactId(item.getArtifactId());
    dep2.setClassifier("classifier");
    dep2.setGroupId(item.getGroupId());
    dep2.setType(item.getType());
    dep2.setVersion("3.1");
    List<Dependency> list = new ArrayList<Dependency>(2);
    list.add(dep2);
    list.add(dep);
    return list;
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency)

Example 64 with Dependency

use of org.apache.maven.model.Dependency in project maven-plugins by apache.

the class JLinkMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    String jLinkExec;
    try {
        jLinkExec = getJLinkExecutable();
    } catch (IOException e) {
        throw new MojoFailureException("Unable to find jlink command: " + e.getMessage(), e);
    }
    getLog().info("Toolchain in maven-jlink-plugin: jlink [ " + jLinkExec + " ]");
    // TODO: Find a more better and cleaner way?
    File jLinkExecuteable = new File(jLinkExec);
    // Really Hacky...
    File jLinkParent = jLinkExecuteable.getParentFile().getParentFile();
    File jmodsFolder = new File(jLinkParent, "jmods");
    getLog().debug(" Parent: " + jLinkParent.getAbsolutePath());
    getLog().debug(" jmodsFolder: " + jmodsFolder.getAbsolutePath());
    failIfParametersAreNotInTheirValidValueRanges();
    deleteOutputDirectoryIfItAlreadyExists();
    List<MavenProject> sortedProjects = getSession().getProjectDependencyGraph().getSortedProjects();
    for (MavenProject mavenProject : sortedProjects) {
        getLog().info("MavenProject: " + mavenProject.getBasedir());
    }
    List<Dependency> dependencies = getSession().getCurrentProject().getDependencies();
    List<MavenProject> modulesToAdd = new ArrayList<>();
    for (Dependency dependency : dependencies) {
        if ("jmod".equals(dependency.getType())) {
            MavenProject mp = findDependencyInProjects(dependency);
            // TODO: What about module name != artifactId which has been
            // defined in module-info.java file!
            modulesToAdd.add(mp);
        }
    }
    if (addModules == null) {
        addModules = new ArrayList<>();
    }
    for (MavenProject mavenProject : modulesToAdd) {
        addModules.add(mavenProject.getArtifactId());
    }
    if (modulePaths == null) {
        modulePaths = new ArrayList<>();
    }
    // JDK mods folder
    modulePaths.add(jmodsFolder.getAbsolutePath());
    for (MavenProject mavenProject : modulesToAdd) {
        File output = new File(mavenProject.getBuild().getDirectory(), "jmods");
        modulePaths.add(output.getAbsolutePath());
    }
    // Synopsis
    // Usage: jlink <options> --module-path <modulepath> --add-modules <mods> --output <path>
    Commandline cmd;
    try {
        cmd = createJLinkCommandLine();
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage());
    }
    cmd.setExecutable(jLinkExec);
    executeCommand(cmd, outputDirectory);
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Commandline(org.codehaus.plexus.util.cli.Commandline) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Dependency(org.apache.maven.model.Dependency) File(java.io.File)

Example 65 with Dependency

use of org.apache.maven.model.Dependency in project maven-plugins by apache.

the class DependencyConvergenceReport method showVersionDetails.

private void showVersionDetails(DependencyNode projectNode, List<ReverseDependencyLink> depList, Sink sink) {
    if (depList == null || depList.isEmpty()) {
        return;
    }
    Dependency dependency = depList.get(0).getDependency();
    String key = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getType() + ":" + dependency.getVersion();
    serializeDependencyTree(projectNode, key, sink);
}
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