Search in sources :

Example 26 with Dependency

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

the class DependencyManagementRenderer method renderDependenciesForScope.

private void renderDependenciesForScope(String scope, List<Dependency> artifacts) {
    if (artifacts != null) {
        // can't use straight artifact comparison because we want optional last
        Collections.sort(artifacts, getDependencyComparator());
        startSection(scope);
        paragraph(getI18nString("intro." + scope));
        startTable();
        boolean hasClassifier = false;
        for (Dependency dependency : artifacts) {
            if (StringUtils.isNotEmpty(dependency.getClassifier())) {
                hasClassifier = true;
                break;
            }
        }
        String[] tableHeader = getDependencyTableHeader(hasClassifier);
        tableHeader(tableHeader);
        for (Dependency dependency : artifacts) {
            tableRow(getDependencyRow(dependency, hasClassifier));
        }
        endTable();
        endSection();
    }
}
Also used : Dependency(org.apache.maven.model.Dependency)

Example 27 with Dependency

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

the class MavenProjectArtifactsStub method getDependencies.

public List<Dependency> getDependencies() {
    if (getArtifacts() == null) {
        return new ArrayList<Dependency>();
    }
    final List<Dependency> dependencies = new ArrayList<Dependency>();
    for (Object o : getArtifacts()) {
        Artifact a = (Artifact) o;
        Dependency dependency = new Dependency();
        dependency.setArtifactId(a.getArtifactId());
        dependency.setGroupId(a.getGroupId());
        dependency.setVersion(a.getVersion());
        dependency.setScope(a.getScope());
        dependency.setType(a.getType());
        dependency.setClassifier(a.getClassifier());
        dependencies.add(dependency);
    }
    return dependencies;
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency) Artifact(org.apache.maven.artifact.Artifact)

Example 28 with Dependency

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

the class WebappStructureTest method testDependencyAnalysisNoChange.

public void testDependencyAnalysisNoChange() {
    final List<Dependency> dependencies = new ArrayList<Dependency>();
    dependencies.add(createDependency("groupTest", "artifactTest", "1.0"));
    final WebappStructure cache = new WebappStructure(dependencies);
    final WebappStructure webappStructure = new WebappStructure(dependencies, cache);
    webappStructure.analyseDependencies(new WebappStructure.DependenciesAnalysisCallback() {

        int count = 0;

        public void unchangedDependency(Dependency dependency) {
            if (count == 0) {
                count++;
            } else {
                fail("Should have called unchanged dependency only once");
            }
        }

        public void newDependency(Dependency dependency) {
            fail("Should have failed to trigger this callback");
        }

        public void removedDependency(Dependency dependency) {
            fail("Should have failed to trigger this callback");
        }

        public void updatedVersion(Dependency dependency, String previousVersion) {
            fail("Should have failed to trigger this callback");
        }

        public void updatedScope(Dependency dependency, String previousScope) {
            fail("Should have failed to trigger this callback");
        }

        public void updatedOptionalFlag(Dependency dependency, boolean previousOptional) {
            fail("Should have failed to trigger this callback");
        }

        public void updatedUnknown(Dependency dependency, Dependency previousDep) {
            fail("Should have failed to trigger this callback");
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.apache.maven.model.Dependency) WebappStructure(org.apache.maven.plugins.war.util.WebappStructure)

Example 29 with Dependency

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

the class WarUtilsTest method testDependencyEquals.

/**
     * Test for MWAR-160.
     */
public void testDependencyEquals() {
    Dependency firstDependency = new Dependency();
    firstDependency.setGroupId("1");
    firstDependency.setArtifactId("a");
    Dependency secondDependency = new Dependency();
    secondDependency.setGroupId("2");
    secondDependency.setArtifactId("b");
    Dependency thirdDependency = new Dependency();
    thirdDependency.setGroupId("1");
    thirdDependency.setArtifactId("c");
    Dependency fourthDependency = new Dependency();
    fourthDependency.setGroupId("4");
    fourthDependency.setArtifactId("a");
    assertFalse("dependencies 1:a and 2:b should not be equal", WarUtils.dependencyEquals(firstDependency, secondDependency));
    assertFalse("dependencies 1:a and 1:c should not be equal", WarUtils.dependencyEquals(firstDependency, thirdDependency));
    assertFalse("dependencies 1:a and 4:a should not be equal", WarUtils.dependencyEquals(firstDependency, fourthDependency));
    assertFalse("dependencies 2:b and 1:c should not be equal", WarUtils.dependencyEquals(secondDependency, thirdDependency));
    assertFalse("dependencies 2:b and 4:a should not be equal", WarUtils.dependencyEquals(secondDependency, fourthDependency));
    assertFalse("dependencies 1:c and 4:a should not be equal", WarUtils.dependencyEquals(thirdDependency, fourthDependency));
}
Also used : Dependency(org.apache.maven.model.Dependency)

Example 30 with Dependency

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

the class WebappStructureTest method testUnknownFileNotAvailable.

public void testUnknownFileNotAvailable() {
    final WebappStructure structure = new WebappStructure(new ArrayList<Dependency>());
    assertFalse(structure.isRegistered("/foo/bar.txt"));
}
Also used : Dependency(org.apache.maven.model.Dependency) WebappStructure(org.apache.maven.plugins.war.util.WebappStructure)

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