diff -Nru maven-dependency-plugin-2.1/debian/README.source maven-dependency-plugin-2.4/debian/README.source --- maven-dependency-plugin-2.1/debian/README.source 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/README.source 2013-10-30 06:37:30.000000000 +0000 @@ -1,5 +1,12 @@ Information about maven-dependency-plugin ------------------------------- +----------------------------------------- + +This plugin is a core Maven plugin, if you update it to a new upstream release +the superpom in the maven2-core package must be updated to specify the new +version of the plugin. This pom is bundled in a jar built by the maven2 package, +so the maven2 package has to be rebuilt after installing the updated maven2-core +package. + This package was debianized using the mh_make command from the maven-debian-helper package. diff -Nru maven-dependency-plugin-2.1/debian/changelog maven-dependency-plugin-2.4/debian/changelog --- maven-dependency-plugin-2.1/debian/changelog 2011-09-28 19:55:28.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/changelog 2013-10-30 06:37:30.000000000 +0000 @@ -1,3 +1,19 @@ +maven-dependency-plugin (2.4-1) unstable; urgency=low + + * Team upload. + * New upstream release + - Added a dependency on libcommons-collections3-java + - Removed artifact-filter-1.1.patch + * debian/control: + - Use canonical URLs for the Vcs-* fields + - Updated Standards-Version to 3.9.4 (no changes) + * debian/copyright: Updated the Format URI + * Build depend on debhelper >= 9 + * Use XZ compression for the upstream tarball + * Documented the procedure to update the core Maven plugins in README.source + + -- Emmanuel Bourg Fri, 18 Oct 2013 13:55:45 +0200 + maven-dependency-plugin (2.1-4) unstable; urgency=low * Add missing Build-Depends-Indep: libmaven-plugin-tools-java. diff -Nru maven-dependency-plugin-2.1/debian/compat maven-dependency-plugin-2.4/debian/compat --- maven-dependency-plugin-2.1/debian/compat 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/compat 2013-10-30 06:37:30.000000000 +0000 @@ -1 +1 @@ -7 +9 diff -Nru maven-dependency-plugin-2.1/debian/control maven-dependency-plugin-2.4/debian/control --- maven-dependency-plugin-2.1/debian/control 2011-09-28 19:55:28.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/control 2013-10-30 06:37:30.000000000 +0000 @@ -3,21 +3,34 @@ Priority: optional Maintainer: Debian Java Maintainers Uploaders: Torsten Werner -Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper (>= 1.4) -Build-Depends-Indep: libmaven-common-artifact-filters-java, libmaven-dependency-analyzer-java, - libmaven-dependency-tree-java, libmaven-file-management-java, libmaven-reporting-impl-java, - libmaven2-core-java, libplexus-archiver-java, libplexus-container-default-java, - libplexus-io-java, libplexus-utils-java, junit, libmaven-plugin-testing-java, - default-jdk-doc, libmaven2-core-java-doc, libplexus-container-default-java-doc, - libplexus-utils-java-doc, libmaven-javadoc-plugin-java, libmaven-plugin-tools-java -Standards-Version: 3.9.1 -Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/maven-dependency-plugin -Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/maven-dependency-plugin/ +Build-Depends: cdbs, debhelper (>= 9), default-jdk, maven-debian-helper (>= 1.4) +Build-Depends-Indep: default-jdk-doc, + junit, + libcommons-collections3-java, + libmaven-common-artifact-filters-java, + libmaven-dependency-analyzer-java, + libmaven-dependency-tree-java, + libmaven-file-management-java, + libmaven-javadoc-plugin-java, + libmaven-plugin-testing-java, + libmaven-plugin-tools-java, + libmaven-reporting-impl-java, + libmaven2-core-java, + libmaven2-core-java-doc, + libplexus-archiver-java, + libplexus-container-default-java, + libplexus-container-default-java-doc, + libplexus-io-java, + libplexus-utils-java, + libplexus-utils-java-doc +Standards-Version: 3.9.4 +Vcs-Svn: svn://anonscm.debian.org/pkg-java/trunk/maven-dependency-plugin +Vcs-Browser: http://anonscm.debian.org/viewvc/pkg-java/trunk/maven-dependency-plugin/ Homepage: http://maven.apache.org/plugins/maven-dependency-plugin/ Package: libmaven-dependency-plugin-java Architecture: all -Depends: ${misc:Depends}, ${maven:Depends} +Depends: ${maven:Depends}, ${misc:Depends} Recommends: ${maven:OptionalDepends} Suggests: libmaven-dependency-plugin-java-doc Description: Maven Dependency Plugin @@ -41,7 +54,7 @@ Package: libmaven-dependency-plugin-java-doc Architecture: all Section: doc -Depends: ${misc:Depends}, ${maven:DocDepends} +Depends: ${maven:DocDepends}, ${misc:Depends} Recommends: ${maven:DocOptionalDepends} Suggests: libmaven-dependency-plugin-java Description: Documentation for Maven Dependency Plugin diff -Nru maven-dependency-plugin-2.1/debian/copyright maven-dependency-plugin-2.4/debian/copyright --- maven-dependency-plugin-2.1/debian/copyright 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/copyright 2013-10-30 06:37:30.000000000 +0000 @@ -1,8 +1,8 @@ -Format: http://dep.debian.net/deps/dep5/ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Maven Dependency Plugin -Upstream-Contact: Brian Fox as Lead Developer - Dan T. Tran as Developer - John Casey as Developer +Upstream-Contact: Brian Fox as Lead Developer + Dan T. Tran as Developer + John Casey as Developer Source: http://maven.apache.org/plugins/maven-dependency-plugin/ Files: * @@ -18,8 +18,7 @@ On Debian GNU/Linux system you can find the complete text of the Apache-2.0 license in '/usr/share/common-licenses/Apache-2.0'. -License: GPL-3 +License: GPL-3+ On Debian GNU/Linux system you can find the complete text of the - GNU General Public License version 3 license in + GNU General Public License version 3 license in '/usr/share/common-licenses/GPL-3'. - diff -Nru maven-dependency-plugin-2.1/debian/libmaven-dependency-plugin-java.poms maven-dependency-plugin-2.4/debian/libmaven-dependency-plugin-java.poms --- maven-dependency-plugin-2.1/debian/libmaven-dependency-plugin-java.poms 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/libmaven-dependency-plugin-java.poms 2013-10-30 06:37:30.000000000 +0000 @@ -2,7 +2,9 @@ # Format of this file is: # [option]* # where option can be: -# --ignore: ignore this POM or +# --ignore: ignore this POM and its artifact if any +# --ignore-pom: don't install the POM. To use on POM files that are created +# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms] # --no-parent: remove the tag from the POM # --package=: an alternative package to use when installing this POM # and its artifact @@ -11,16 +13,16 @@ # --keep-elements=: a list of XML elements to keep in the POM # during a clean operation with mh_cleanpom or mh_installpom # --artifact=: path to the build artifact associated with this POM, -# it will be installed when using the command mh_install +# it will be installed when using the command mh_install. [mh_install] # --java-lib: install the jar into /usr/share/java to comply with Debian # packaging guidelines # --usj-name=: name to use when installing the library in /usr/share/java # --usj-version=: version to use when installing the library in /usr/share/java # --no-usj-versionless: don't install the versionless link in /usr/share/java -# --dest-jar=: the destination for the real jar -# it will be installed with mh_install. +# --dest-jar=: the destination for the real jar. +# It will be installed with mh_install. [mh_install] # --classifier=: Optional, the classifier for the jar. Empty by default. -# --ignore-pom: don't install the POM with mh_install or mh_installpoms. To use with POM files that are created -# temporarily for certain artifacts such as Javadoc jars. +# --site-xml=: Optional, the location for site.xml if it needs to be installed. +# Empty by default. [mh_install] # pom.xml --no-parent --has-package-version diff -Nru maven-dependency-plugin-2.1/debian/maven.rules maven-dependency-plugin-2.4/debian/maven.rules --- maven-dependency-plugin-2.1/debian/maven.rules 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/maven.rules 2013-10-30 06:37:30.000000000 +0000 @@ -22,3 +22,4 @@ s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-tools * s/.*/debian/ * * s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing * s/.*/debian/ * * s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-test-tools * s/.*/debian/ * * +commons-collections commons-collections * s/.*/3.x/ * * diff -Nru maven-dependency-plugin-2.1/debian/orig-tar.sh maven-dependency-plugin-2.4/debian/orig-tar.sh --- maven-dependency-plugin-2.1/debian/orig-tar.sh 2011-08-22 19:50:59.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/orig-tar.sh 2013-10-30 06:37:30.000000000 +0000 @@ -1,12 +1,12 @@ #!/bin/sh -e VERSION=$2 -TAR=../maven-dependency-plugin_$VERSION.orig.tar.gz +TAR=../maven-dependency-plugin_$VERSION.orig.tar.xz DIR=maven-dependency-plugin-$VERSION TAG=$(echo "maven-dependency-plugin-$VERSION" | sed -re's/~(alpha|beta)/-\1-/') svn export http://svn.apache.org/repos/asf/maven/plugins/tags/${TAG}/ $DIR -GZIP=--best tar -c -z -f $TAR --exclude '*.jar' --exclude '*.class' $DIR +XZ_OPT=--best tar -c -J -f $TAR --exclude '*.jar' --exclude '*.class' $DIR rm -rf $DIR ../$TAG # move to directory 'tarballs' diff -Nru maven-dependency-plugin-2.1/debian/patches/artifact-filter-1.1.patch maven-dependency-plugin-2.4/debian/patches/artifact-filter-1.1.patch --- maven-dependency-plugin-2.1/debian/patches/artifact-filter-1.1.patch 2009-06-11 14:08:06.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/patches/artifact-filter-1.1.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ ---- a/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java -+++ b/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java -@@ -36,7 +36,7 @@ - import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; - import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; - import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; --import org.apache.maven.shared.artifact.filter.collection.TransitivityFilter; -+import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter; - import org.apache.maven.shared.artifact.filter.collection.TypeFilter; - import org.codehaus.plexus.util.StringUtils; - -@@ -243,7 +243,7 @@ - // add filters in well known order, least specific to most specific - FilterArtifacts filter = new FilterArtifacts(); - -- filter.addFilter( new TransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive ) ); -+ filter.addFilter( new ProjectTransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive ) ); - filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) ); - filter.addFilter( new TypeFilter( this.includeTypes, this.excludeTypes ) ); - filter.addFilter( new ClassifierFilter( this.includeClassifiers, this.excludeClassifiers ) ); diff -Nru maven-dependency-plugin-2.1/debian/patches/series maven-dependency-plugin-2.4/debian/patches/series --- maven-dependency-plugin-2.1/debian/patches/series 2009-06-11 14:08:06.000000000 +0000 +++ maven-dependency-plugin-2.4/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -artifact-filter-1.1.patch diff -Nru maven-dependency-plugin-2.1/pom.xml maven-dependency-plugin-2.4/pom.xml --- maven-dependency-plugin-2.1/pom.xml 2009-01-07 15:39:44.000000000 +0000 +++ maven-dependency-plugin-2.4/pom.xml 2011-11-12 06:24:54.000000000 +0000 @@ -1,4 +1,4 @@ - + - + 4.0.0 - + maven-plugins org.apache.maven.plugins - 12 + 21 + ../maven-plugins/pom.xml - + maven-dependency-plugin - 2.1 + 2.4 maven-plugin Maven Dependency Plugin @@ -68,91 +69,102 @@ - 2.0.3 + ${mavenVersion} - scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-dependency-plugin-2.1 - scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-dependency-plugin-2.1 - http://svn.apache.org/viewvc/maven/plugins/tags/maven-dependency-plugin-2.1 + scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-dependency-plugin-2.4 + scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-dependency-plugin-2.4 + http://svn.apache.org/viewvc/maven/plugins/tags/maven-dependency-plugin-2.4 JIRA http://jira.codehaus.org/browse/MDEP - + - 2.0.9 + 2.0.9 + 1.0 + 1.2 - + + org.apache.maven maven-artifact - ${maven.version} + ${mavenVersion} org.apache.maven maven-plugin-api - ${maven.version} + ${mavenVersion} org.apache.maven maven-project - ${maven.version} + ${mavenVersion} org.apache.maven maven-model - ${maven.version} + ${mavenVersion} org.apache.maven maven-core - ${maven.version} + ${mavenVersion} - org.apache.maven.shared - maven-plugin-testing-tools - 1.0-alpha-3 - test + org.apache.maven + maven-artifact-manager + ${mavenVersion} - org.apache.maven.shared - maven-plugin-testing-harness - test - 1.1 + org.apache.maven + maven-repository-metadata + ${mavenVersion} + + + + + org.apache.maven.reporting + maven-reporting-api + 3.0 + org.apache.maven.reporting + maven-reporting-impl + 2.0.5 + + + + + org.apache.maven.doxia + doxia-sink-api + ${doxiaVersion} + + + org.apache.maven.doxia + doxia-site-renderer + ${doxiaVersion} + + + + org.codehaus.plexus plexus-archiver - 1.0-alpha-9 - - - org.codehaus.plexus - plexus-container-default - - - org.codehaus.plexus - plexus-component-api - - + 2.0 org.codehaus.plexus plexus-utils - 1.4.6 + 3.0 org.apache.maven.shared file-management - 1.1 - - - junit - junit - 3.8.2 - test + 1.2.1 org.codehaus.plexus @@ -160,9 +172,16 @@ 1.0-alpha-9-stable-1 + org.codehaus.plexus + plexus-io + 2.0.1 + + + + org.apache.maven.shared maven-dependency-analyzer - 1.1 + 1.2 org.apache.maven.shared @@ -172,81 +191,159 @@ org.apache.maven.shared maven-common-artifact-filters - 1.0 + 1.2 - org.codehaus.plexus - plexus-io - 1.0-alpha-1 - - - org.codehaus.plexus - plexus-container-default - - - org.codehaus.plexus - plexus-component-api - - + org.apache.maven.shared + maven-invoker + 2.0.11 - - + - org.apache.maven.reporting - maven-reporting-api - 2.0.6 + commons-lang + commons-lang + 2.6 + - org.apache.maven.reporting - maven-reporting-impl - 2.0.4 + commons-collections + commons-collections + 3.2.1 + + + + classworlds + classworlds + 1.1 + + + + junit + junit + 3.8.2 + test + + + org.apache.maven.plugin-testing + maven-plugin-testing-tools + ${pluginTestingVersion} + test + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + ${pluginTestingVersion} + + + org.codehaus.plexus + plexus-interpolation + 1.9 + test + + - + + + + + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + org.apache.maven.plugins maven-surefire-plugin + 2.9 -Xmx256m - - - maven.home - ${maven.home} - - + + ${maven.home} + - + run-its - org.codehaus.mojo - shitty-maven-plugin - 1.0-alpha-3 + maven-invoker-plugin + 1.5 + + true + src/it + ${project.build.directory}/it + + */pom.xml + + + setup-custom-analyzer/pom.xml + + setup + validate + ${project.build.directory}/local-repo + src/it/settings.xml + + clean + process-sources + + + integration-test - clean install - test + run - - false - + + reporting + + + + maven-pmd-plugin + + 1.5 + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.6 + + + org.codehaus.mojo + l10n-maven-plugin + 1.0-alpha-2 + + + de + pt_BR + sv + + + + + + - + diff -Nru maven-dependency-plugin-2.1/src/it/analyze/invoker.properties maven-dependency-plugin-2.4/src/it/analyze/invoker.properties --- maven-dependency-plugin-2.1/src/it/analyze/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean ${project.groupId}:${project.artifactId}:${project.version}:analyze diff -Nru maven-dependency-plugin-2.1/src/it/analyze/pom.xml maven-dependency-plugin-2.4/src/it/analyze/pom.xml --- maven-dependency-plugin-2.1/src/it/analyze/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:analyze + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + diff -Nru maven-dependency-plugin-2.1/src/it/analyze/src/main/java/Main.java maven-dependency-plugin-2.4/src/it/analyze/src/main/java/Main.java --- maven-dependency-plugin-2.1/src/it/analyze/src/main/java/Main.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze/src/main/java/Main.java 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,3 @@ +public class Main +{ +} diff -Nru maven-dependency-plugin-2.1/src/it/analyze/validate.bsh maven-dependency-plugin-2.4/src/it/analyze/validate.bsh --- maven-dependency-plugin-2.1/src/it/analyze/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze/validate.bsh 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,10 @@ +import java.io.*; + +File classFile = new File( basedir, "target/classes/Main.class" ); + +if ( !classFile.isFile() ) +{ + throw new Exception( "Build was not forked, class missing " + classFile ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/analyze-dep-mgt/invoker.properties maven-dependency-plugin-2.4/src/it/analyze-dep-mgt/invoker.properties --- maven-dependency-plugin-2.1/src/it/analyze-dep-mgt/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze-dep-mgt/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:analyze-dep-mgt diff -Nru maven-dependency-plugin-2.1/src/it/analyze-dep-mgt/pom.xml maven-dependency-plugin-2.4/src/it/analyze-dep-mgt/pom.xml --- maven-dependency-plugin-2.1/src/it/analyze-dep-mgt/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/analyze-dep-mgt/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,56 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:analyze-dep-mgt + + + + UTF-8 + + + + + + junit + junit + 3.8.2 + + + + + + + org.apache.maven + maven-project + 2.0.6 + + + diff -Nru maven-dependency-plugin-2.1/src/it/build-classpath/invoker.properties maven-dependency-plugin-2.4/src/it/build-classpath/invoker.properties --- maven-dependency-plugin-2.1/src/it/build-classpath/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/build-classpath/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:build-classpath diff -Nru maven-dependency-plugin-2.1/src/it/build-classpath/pom.xml maven-dependency-plugin-2.4/src/it/build-classpath/pom.xml --- maven-dependency-plugin-2.1/src/it/build-classpath/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/build-classpath/pom.xml 2010-11-06 12:37:11.000000000 +0000 @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:build-classpath + + + + UTF-8 + + + + + org.apache.maven + maven-profile + 2.0.6 + + + + classworlds + classworlds + + + + + + diff -Nru maven-dependency-plugin-2.1/src/it/build-classpath/test.properties maven-dependency-plugin-2.4/src/it/build-classpath/test.properties --- maven-dependency-plugin-2.1/src/it/build-classpath/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/build-classpath/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,4 @@ +mdep.outputFile = target/classpath.txt +mdep.fileSeparator = / +mdep.pathSeparator = : +mdep.prefix = PREFIX \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/it/build-classpath/validate.bsh maven-dependency-plugin-2.4/src/it/build-classpath/validate.bsh --- maven-dependency-plugin-2.1/src/it/build-classpath/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/build-classpath/validate.bsh 2010-11-06 12:37:11.000000000 +0000 @@ -0,0 +1,28 @@ +import java.io.*; +import java.util.*; + +import org.codehaus.plexus.util.*; + +String classpath = FileUtils.fileRead( new File( basedir, "target/classpath.txt" ) ); + +classpath = StringUtils.replace( classpath, "PREFIX/", "" ); + +List actual = Arrays.asList( classpath.split( ":" ) ); + +List expected = new ArrayList(); +expected.add( "maven-profile-2.0.6.jar" ); +expected.add( "maven-model-2.0.6.jar" ); +expected.add( "plexus-utils-1.4.1.jar" ); +expected.add( "plexus-container-default-1.0-alpha-9-stable-1.jar" ); +expected.add( "junit-3.8.1.jar" ); + +System.out.println( "Checking classpath... " ); +System.out.println( "Actual : " + actual ); +System.out.println( "Expected: " + expected ); + +if ( !actual.equals( expected ) ) +{ + throw new Exception( "Unexpected classpath" ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/copy/invoker.properties maven-dependency-plugin-2.4/src/it/copy/invoker.properties --- maven-dependency-plugin-2.1/src/it/copy/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean process-sources diff -Nru maven-dependency-plugin-2.1/src/it/copy/pom.xml maven-dependency-plugin-2.4/src/it/copy/pom.xml --- maven-dependency-plugin-2.1/src/it/copy/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy/pom.xml 2009-12-29 23:33:02.000000000 +0000 @@ -0,0 +1,64 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:copy + + + + UTF-8 + + + + + + maven-dependency-plugin + @project.version@ + + + test + + copy + + + + + org.apache.maven + maven-model + 2.0.6 + + + + + + + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy/validate.bsh maven-dependency-plugin-2.4/src/it/copy/validate.bsh --- maven-dependency-plugin-2.1/src/it/copy/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy/validate.bsh 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,19 @@ +import java.io.*; + +File libDir = new File( basedir, "target/dependency" ); + +String[] expectedFiles = { + "maven-model-2.0.6.jar", +}; + +for ( String expectedFile : expectedFiles ) +{ + File file = new File( libDir, expectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( !file.isFile() ) + { + throw new Exception( "Missing file " + file ); + } +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/invoker.properties maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/invoker.properties --- maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/invoker.properties 2009-12-29 23:33:02.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean package diff -Nru maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml --- maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml 2010-01-02 19:28:47.000000000 +0000 @@ -0,0 +1,81 @@ + + + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:copy and dependency:unpack with alternate local repository + + + + UTF-8 + + + + + + maven-dependency-plugin + @project.version@ + + + copy + + copy + + + ${project.build.directory}/repo + + + junit + junit + 3.8.1 + + + + + + unpack + + unpack + + + ${project.build.directory}/repo + + + junit + junit + 3.8.1 + + + + + + + + + \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/validate.bsh maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/validate.bsh --- maven-dependency-plugin-2.1/src/it/copy-and-unpack-with-alternate-local-repo/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-and-unpack-with-alternate-local-repo/validate.bsh 2009-12-29 23:33:02.000000000 +0000 @@ -0,0 +1,26 @@ +import java.io.*; + + +File file = new File( basedir, "target/dependency/junit-3.8.1.jar" ); + +System.out.println( "Checking for existence of " + file ); +if ( !file.isFile() ) +{ + throw new Exception( "Missing " + file ); +} + +file = new File( basedir, "target/dependency/junit" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isDirectory() ) +{ + throw new Exception( "Missing " + file ); +} + +file = new File( basedir, "target/repo/junit/junit/3.8.1/junit-3.8.1.jar" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isFile() ) +{ + throw new Exception( "Missing " + file ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/copy-dependencies/invoker.properties maven-dependency-plugin-2.4/src/it/copy-dependencies/invoker.properties --- maven-dependency-plugin-2.1/src/it/copy-dependencies/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-dependencies/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean process-sources diff -Nru maven-dependency-plugin-2.1/src/it/copy-dependencies/pom.xml maven-dependency-plugin-2.4/src/it/copy-dependencies/pom.xml --- maven-dependency-plugin-2.1/src/it/copy-dependencies/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-dependencies/pom.xml 2010-01-01 08:42:13.000000000 +0000 @@ -0,0 +1,98 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:copy-dependencies + + + + + + org.apache.maven + maven-model + 2.0.6 + + + org.apache.maven + maven-model + 2.0.6 + sources + + + org.apache.maven + maven-model + 2.0.6 + javadoc + + + + + UTF-8 + + + + + package + + + + maven-dependency-plugin + @project.version@ + + + test-1 + + copy-dependencies + + + true + ${project.build.directory}/it/copy-dep-test-1 + + + + test-2 + + copy-dependencies + + + + + sources, + javadoc + + ${project.build.directory}/it/copy-dep-test-2 + + + + test-3 + + copy-dependencies + + + sources + ${project.build.directory}/it/copy-dep-test-3 + + + + + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy-dependencies/validate.bsh maven-dependency-plugin-2.4/src/it/copy-dependencies/validate.bsh --- maven-dependency-plugin-2.1/src/it/copy-dependencies/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-dependencies/validate.bsh 2010-01-01 08:33:29.000000000 +0000 @@ -0,0 +1,93 @@ +import java.io.*; + +File libDir = new File( basedir, "target/it/copy-dep-test-1" ); + +String[] expectedFiles = { + "maven-model-2.0.6.jar", + "maven-model-2.0.6.pom", + "plexus-utils-1.4.1.jar", + "plexus-utils-1.4.1.pom", + "maven-model-2.0.6-sources.jar", + "maven-model-2.0.6-javadoc.jar", +}; + +for ( String expectedFile : expectedFiles ) +{ + File file = new File( libDir, expectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( !file.isFile() ) + { + throw new Exception( "Missing file " + file ); + } +} + +libDir = new File( basedir, "target/it/copy-dep-test-2" ); + +String [] expectedFiles2 = { + "maven-model-2.0.6.jar", + "plexus-utils-1.4.1.jar", +}; + +String [] unexpectedFiles2 = { + "plexus-utils-1.4.1.pom", + "maven-model-2.0.6.pom", + "maven-model-2.0.6-sources.jar", + "maven-model-2.0.6-javadoc.jar", +}; + +for ( String expectedFile : expectedFiles2 ) +{ + File file = new File( libDir, expectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( !file.isFile() ) + { + throw new Exception( "Missing file " + file ); + } +} + +for ( String unexpectedFile : unexpectedFiles2 ) +{ + File file = new File( libDir, unexpectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new Exception( "Unexpected file " + file + " found" ); + } +} + +libDir = new File( basedir, "target/it/copy-dep-test-3" ); + +String [] expectedFiles3 = { + "maven-model-2.0.6-sources.jar", +}; + +String [] unexpectedFiles3 = { + "plexus-utils-1.4.1.pom", + "maven-model-2.0.6.pom", + "maven-model-2.0.6-javadoc.jar", + "maven-model-2.0.6.jar", + "plexus-utils-1.4.1.jar", +}; + +for ( String expectedFile : expectedFiles3 ) +{ + File file = new File( libDir, expectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( !file.isFile() ) + { + throw new Exception( "Missing file " + file ); + } +} + +for ( String unexpectedFile : unexpectedFiles3 ) +{ + File file = new File( libDir, unexpectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new Exception( "Unexpected file " + file + " found" ); + } +} + + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-a/pom.xml maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-a/pom.xml --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-a/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-a/pom.xml 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + child-a + jar + + Copy from reactor source of dependency + + Test dependency:copy when searching the reactor + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-a/src/main/resources/DoNotDelete.xml maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-a/src/main/resources/DoNotDelete.xml --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-a/src/main/resources/DoNotDelete.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-a/src/main/resources/DoNotDelete.xml 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,20 @@ + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-b/pom.xml maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-b/pom.xml --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/child-b/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/child-b/pom.xml 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,74 @@ + + + + + 4.0.0 + + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + child-b + pom + + Copy from reactor + + Test dependency:copy when searching the reactor + + + + UTF-8 + + + + + org.apache.maven.its.dependency + child-a + 1.0-SNAPSHOT + + + + + + + maven-dependency-plugin + + + test + + copy + + + + + org.apache.maven.its.dependency + child-a + + + + + + + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/invoker.properties maven-dependency-plugin-2.4/src/it/copy-from-reactor/invoker.properties --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/invoker.properties 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean package diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/pom.xml maven-dependency-plugin-2.4/src/it/copy-from-reactor/pom.xml --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/pom.xml 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,53 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + pom + + + child-a + child-b + + + Copy from reactor + + Test dependency:copy when searching the reactor + + + + UTF-8 + + + + + + maven-dependency-plugin + @project.version@ + + + + diff -Nru maven-dependency-plugin-2.1/src/it/copy-from-reactor/validate.bsh maven-dependency-plugin-2.4/src/it/copy-from-reactor/validate.bsh --- maven-dependency-plugin-2.1/src/it/copy-from-reactor/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/copy-from-reactor/validate.bsh 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,19 @@ +import java.io.*; + +File libDir = new File( basedir, "child-b/target/dependency" ); + +String[] expectedFiles = { + "child-a-1.0-SNAPSHOT.jar", +}; + +for ( String expectedFile : expectedFiles ) +{ + File file = new File( libDir, expectedFile ); + System.out.println( "Checking for existence of " + file ); + if ( !file.isFile() ) + { + throw new Exception( "Missing file " + file ); + } +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/dependency-properties/invoker.properties maven-dependency-plugin-2.4/src/it/dependency-properties/invoker.properties --- maven-dependency-plugin-2.1/src/it/dependency-properties/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/dependency-properties/invoker.properties 2010-12-13 17:22:53.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = initialize diff -Nru maven-dependency-plugin-2.1/src/it/dependency-properties/pom.xml maven-dependency-plugin-2.4/src/it/dependency-properties/pom.xml --- maven-dependency-plugin-2.1/src/it/dependency-properties/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/dependency-properties/pom.xml 2010-12-13 17:22:53.000000000 +0000 @@ -0,0 +1,88 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:properties + + + + + + org.apache.maven.plugins + maven-dependency-plugin + @project.version@ + + + test-1 + + properties + + initialize + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0-alpha-2 + + + test-1 + + write-project-properties + + initialize + + ${project.build.directory}/project.properties + + + + + + + + + UTF-8 + + + + + org.apache.maven + maven-artifact + 2.0.9 + + + junit + junit + 4.1 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/dependency-properties/validate.bsh maven-dependency-plugin-2.4/src/it/dependency-properties/validate.bsh --- maven-dependency-plugin-2.1/src/it/dependency-properties/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/dependency-properties/validate.bsh 2010-12-13 17:22:53.000000000 +0000 @@ -0,0 +1,28 @@ +import java.io.*; + +File projectProperties = new File( basedir, "target/project.properties" ); + +Properties props = new Properties(); +props.load( new FileInputStream( projectProperties ) ); + +String junitJarPath = props.getProperty( "junit:junit:jar" ); +if ( junitJarPath == null ) +{ + throw new Exception( "junit:junit:jar is null" ); +} +if ( ! (new File( junitJarPath )).isFile() ) +{ + throw new Exception( "junit jar is not a file: " + junitJarPath ); +} + +String mavenArtifactPath = props.getProperty( "org.apache.maven:maven-artifact:jar" ); +if ( mavenArtifactPath == null ) +{ + throw new Exception( "org.apache.maven:maven-artifact:jar is null" ); +} +if ( ! (new File( mavenArtifactPath )).isFile() ) +{ + throw new Exception( "maven-artifact jar is not a file: " + mavenArtifactPath ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/filterunpack/goals.txt maven-dependency-plugin-2.4/src/it/filterunpack/goals.txt --- maven-dependency-plugin-2.1/src/it/filterunpack/goals.txt 2008-03-24 12:57:08.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/filterunpack/goals.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -package \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/it/filterunpack/pom.xml maven-dependency-plugin-2.4/src/it/filterunpack/pom.xml --- maven-dependency-plugin-2.1/src/it/filterunpack/pom.xml 2008-03-24 12:57:08.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/filterunpack/pom.xml 2009-03-13 14:44:21.000000000 +0000 @@ -1,4 +1,5 @@ - + + 4.0.0 dependency @@ -10,7 +11,7 @@ junit junit - 3.8.1 + 3.8.2 test @@ -19,7 +20,7 @@ maven-dependency-plugin - testing + @project.version@ diff -Nru maven-dependency-plugin-2.1/src/it/filterunpack/validate.groovy maven-dependency-plugin-2.4/src/it/filterunpack/validate.groovy --- maven-dependency-plugin-2.1/src/it/filterunpack/validate.groovy 2008-03-28 10:43:39.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/filterunpack/validate.groovy 2009-03-13 14:44:21.000000000 +0000 @@ -19,3 +19,5 @@ throw new RuntimeException("This file shouldn't be here: "+file.name); } } + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/go-offline/invoker.properties maven-dependency-plugin-2.4/src/it/go-offline/invoker.properties --- maven-dependency-plugin-2.1/src/it/go-offline/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/go-offline/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:go-offline diff -Nru maven-dependency-plugin-2.1/src/it/go-offline/pom.xml maven-dependency-plugin-2.4/src/it/go-offline/pom.xml --- maven-dependency-plugin-2.1/src/it/go-offline/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/go-offline/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:go-offline + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/go-offline/test.properties maven-dependency-plugin-2.4/src/it/go-offline/test.properties --- maven-dependency-plugin-2.1/src/it/go-offline/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/go-offline/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +outputFile = target/tree.txt diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository/invoker.properties maven-dependency-plugin-2.4/src/it/purge-local-repository/invoker.properties --- maven-dependency-plugin-2.1/src/it/purge-local-repository/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository/pom.xml maven-dependency-plugin-2.4/src/it/purge-local-repository/pom.xml --- maven-dependency-plugin-2.1/src/it/purge-local-repository/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:purge-local-repository + + + + UTF-8 + + + + + org.apache.maven.its.dependency + purged + 1.0 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository/setup.bsh maven-dependency-plugin-2.4/src/it/purge-local-repository/setup.bsh --- maven-dependency-plugin-2.1/src/it/purge-local-repository/setup.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository/setup.bsh 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,10 @@ +import java.io.*; + +File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); + +purgedJar.getParentFile().mkdirs(); +purgedJar.createNewFile(); + +System.out.println( "Created dummy JAR " + purgedJar ); + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository/test.properties maven-dependency-plugin-2.4/src/it/purge-local-repository/test.properties --- maven-dependency-plugin-2.1/src/it/purge-local-repository/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +reResolve = false diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository/validate.bsh maven-dependency-plugin-2.4/src/it/purge-local-repository/validate.bsh --- maven-dependency-plugin-2.1/src/it/purge-local-repository/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository/validate.bsh 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,12 @@ +import java.io.*; + +File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); + +System.out.println( "Checking for absence of dummy JAR " + purgedJar ); + +if ( purgedJar.exists() ) +{ + throw new Exception( "JAR was not purged: " + purgedJar ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/invoker.properties maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/invoker.properties --- maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/invoker.properties 2011-10-28 13:02:02.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/pom.xml maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/pom.xml --- maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/pom.xml 2011-10-28 13:02:02.000000000 +0000 @@ -0,0 +1,52 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:purge-local-repository + + + + UTF-8 + + + + + org.apache.maven.its.dependency + purged + 1.0 + + + org.apache.maven.its.dependency + snap-purged + 1.0-SNAPSHOT + + + + diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/setup.bsh maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/setup.bsh --- maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/setup.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/setup.bsh 2011-10-28 13:02:02.000000000 +0000 @@ -0,0 +1,18 @@ +import java.io.*; + +File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); + +purgedJar.getParentFile().mkdirs(); +purgedJar.createNewFile(); + +System.out.println( "Created dummy JAR " + purgedJar ); + +purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/snap-purged/1.0-SNAPSHOT/snap-purged-1.0-SNAPSHOT.jar" ); + +purgedJar.getParentFile().mkdirs(); +purgedJar.createNewFile(); + +System.out.println( "Created dummy JAR " + purgedJar ); + + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/test.properties maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/test.properties --- maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/test.properties 2011-10-28 13:02:02.000000000 +0000 @@ -0,0 +1,2 @@ +reResolve = false +snapshotsOnly = true diff -Nru maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/validate.bsh maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/validate.bsh --- maven-dependency-plugin-2.1/src/it/purge-local-repository-snapshots-only/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/purge-local-repository-snapshots-only/validate.bsh 2011-10-28 13:02:02.000000000 +0000 @@ -0,0 +1,22 @@ +import java.io.*; + +File nonPurgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/purged/1.0/purged-1.0.jar" ); + +System.out.println( "Checking for presence of dummy JAR " + nonPurgedJar ); + +if ( !nonPurgedJar.exists() ) +{ + throw new Exception( "JAR was purged: " + nonPurgedJar ); +} + + +File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/snap-purged/1.0-SNAPSHOT/snap-purged-1.0-SNAPSHOT.jar" ); + +System.out.println( "Checking for absence of dummy JAR " + purgedJar ); + +if ( purgedJar.exists() ) +{ + throw new Exception( "JAR was not purged: " + purgedJar ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/resolve/invoker.properties maven-dependency-plugin-2.4/src/it/resolve/invoker.properties --- maven-dependency-plugin-2.1/src/it/resolve/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve diff -Nru maven-dependency-plugin-2.1/src/it/resolve/pom.xml maven-dependency-plugin-2.4/src/it/resolve/pom.xml --- maven-dependency-plugin-2.1/src/it/resolve/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:resolve + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/resolve/test.properties maven-dependency-plugin-2.4/src/it/resolve/test.properties --- maven-dependency-plugin-2.1/src/it/resolve/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +outputFile = target/resolved.txt diff -Nru maven-dependency-plugin-2.1/src/it/resolve-plugins/invoker.properties maven-dependency-plugin-2.4/src/it/resolve-plugins/invoker.properties --- maven-dependency-plugin-2.1/src/it/resolve-plugins/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve-plugins/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve-plugins diff -Nru maven-dependency-plugin-2.1/src/it/resolve-plugins/pom.xml maven-dependency-plugin-2.4/src/it/resolve-plugins/pom.xml --- maven-dependency-plugin-2.1/src/it/resolve-plugins/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve-plugins/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:resolve-plugins + + + + UTF-8 + + + diff -Nru maven-dependency-plugin-2.1/src/it/resolve-plugins/test.properties maven-dependency-plugin-2.4/src/it/resolve-plugins/test.properties --- maven-dependency-plugin-2.1/src/it/resolve-plugins/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/resolve-plugins/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +outputFile = target/resolved.txt diff -Nru maven-dependency-plugin-2.1/src/it/settings.xml maven-dependency-plugin-2.4/src/it/settings.xml --- maven-dependency-plugin-2.1/src/it/settings.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/settings.xml 2009-09-26 14:51:47.000000000 +0000 @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff -Nru maven-dependency-plugin-2.1/src/it/sources/invoker.properties maven-dependency-plugin-2.4/src/it/sources/invoker.properties --- maven-dependency-plugin-2.1/src/it/sources/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/sources/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:sources diff -Nru maven-dependency-plugin-2.1/src/it/sources/pom.xml maven-dependency-plugin-2.4/src/it/sources/pom.xml --- maven-dependency-plugin-2.1/src/it/sources/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/sources/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:sources + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/sources/test.properties maven-dependency-plugin-2.4/src/it/sources/test.properties --- maven-dependency-plugin-2.1/src/it/sources/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/sources/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +outputFile = target/resolved.txt diff -Nru maven-dependency-plugin-2.1/src/it/tree/expected.txt maven-dependency-plugin-2.4/src/it/tree/expected.txt --- maven-dependency-plugin-2.1/src/it/tree/expected.txt 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/tree/expected.txt 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,14 @@ +org.apache.maven.its.dependency:test:jar:1.0-SNAPSHOT +\- org.apache.maven:maven-project:jar:2.0.6:compile + +- org.apache.maven:maven-settings:jar:2.0.6:compile + +- org.apache.maven:maven-profile:jar:2.0.6:compile + +- org.apache.maven:maven-model:jar:2.0.6:compile + +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile + | +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile + | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile + +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile + +- org.codehaus.plexus:plexus-utils:jar:1.4.1:compile + +- org.apache.maven:maven-artifact:jar:2.0.6:compile + \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile + +- junit:junit:jar:3.8.1:compile + \- classworlds:classworlds:jar:1.1-alpha-2:compile diff -Nru maven-dependency-plugin-2.1/src/it/tree/invoker.properties maven-dependency-plugin-2.4/src/it/tree/invoker.properties --- maven-dependency-plugin-2.1/src/it/tree/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/tree/invoker.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:tree diff -Nru maven-dependency-plugin-2.1/src/it/tree/pom.xml maven-dependency-plugin-2.4/src/it/tree/pom.xml --- maven-dependency-plugin-2.1/src/it/tree/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/tree/pom.xml 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:tree + + + + UTF-8 + + + + + org.apache.maven + maven-project + 2.0.6 + + + + diff -Nru maven-dependency-plugin-2.1/src/it/tree/test.properties maven-dependency-plugin-2.4/src/it/tree/test.properties --- maven-dependency-plugin-2.1/src/it/tree/test.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/tree/test.properties 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1 @@ +outputFile = target/tree.txt diff -Nru maven-dependency-plugin-2.1/src/it/tree/validate.bsh maven-dependency-plugin-2.4/src/it/tree/validate.bsh --- maven-dependency-plugin-2.1/src/it/tree/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/tree/validate.bsh 2009-09-02 14:43:48.000000000 +0000 @@ -0,0 +1,18 @@ +import java.io.*; + +import org.codehaus.plexus.util.*; + +String actual = FileUtils.fileRead( new File( basedir, "target/tree.txt" ) ); +String expected = FileUtils.fileRead( new File( basedir, "expected.txt" ) ); + +actual = actual.replaceAll( "[\n\r]+", "\n" ); +expected = expected.replaceAll( "[\n\r]+", "\n" ); + +System.out.println( "Checking dependency tree..." ); + +if ( !actual.equals( expected ) ) +{ + throw new Exception( "Unexpected dependency tree" ); +} + +return true; diff -Nru maven-dependency-plugin-2.1/src/it/unpack/invoker.properties maven-dependency-plugin-2.4/src/it/unpack/invoker.properties --- maven-dependency-plugin-2.1/src/it/unpack/invoker.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/unpack/invoker.properties 2009-12-30 05:10:23.000000000 +0000 @@ -0,0 +1 @@ +invoker.goals = clean package diff -Nru maven-dependency-plugin-2.1/src/it/unpack/pom.xml maven-dependency-plugin-2.4/src/it/unpack/pom.xml --- maven-dependency-plugin-2.1/src/it/unpack/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/unpack/pom.xml 2010-01-01 01:42:30.000000000 +0000 @@ -0,0 +1,72 @@ + + + + + + + 4.0.0 + + org.apache.maven.its.dependency + test + 1.0-SNAPSHOT + + Test + + Test dependency:unpack + + + + UTF-8 + + + + + package + + + + maven-dependency-plugin + @project.version@ + + + unpack + + unpack + + + + ${project.build.directory}/output spaces directory + + + qdox + qdox + 1.5 + src + tar.gz + src + + + + + + + + + \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/it/unpack/validate.bsh maven-dependency-plugin-2.4/src/it/unpack/validate.bsh --- maven-dependency-plugin-2.1/src/it/unpack/validate.bsh 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/it/unpack/validate.bsh 2010-01-01 01:42:30.000000000 +0000 @@ -0,0 +1,33 @@ +import java.io.*; + + +File file = new File( basedir, "target/output spaces directory" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isDirectory() ) +{ + throw new Exception( "Missing " + file ); +} + +file = new File( file, "qdox-1.5" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isDirectory() ) +{ + throw new Exception( "Missing " + file ); +} + +file = new File( file, "build.xml" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isFile() ) +{ + throw new Exception( "Missing " + file ); +} + +//until MDEP-242 is fixed, the next test will passed +file = new File( file.getParent(), "src" ); +System.out.println( "Checking for existence of " + file ); +if ( !file.isDirectory() ) +{ + + throw new Exception( "Missing " + file ); +} +return true; diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractAnalyzeMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractAnalyzeMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractAnalyzeMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractAnalyzeMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -33,24 +34,36 @@ import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer; import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.ContextException; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; /** * Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused * and declared. - * + * * @author Mark Hobson - * @version $Id: AbstractAnalyzeMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: AbstractAnalyzeMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0-alpha-5 */ public abstract class AbstractAnalyzeMojo extends AbstractMojo + implements Contextualizable { // fields ----------------------------------------------------------------- /** + * The plexus context to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo + * configuration. + */ + private Context context; + + /** * The Maven project to analyze. - * + * * @parameter expression="${project}" * @required * @readonly @@ -58,38 +71,37 @@ private MavenProject project; /** - * The Maven project dependency analyzer to use. - * - * @component - * @required - * @readonly + * Project dependency analyzer to use (plexus component role-hint). + * + * @parameter expression="${analyzer}" default-value="default" + * @since 2.2 */ - private ProjectDependencyAnalyzer analyzer; + private String analyzer; /** * Whether to fail the build if a dependency warning is found. - * + * * @parameter expression="${failOnWarning}" default-value="false" */ private boolean failOnWarning; /** * Output used dependencies - * + * * @parameter expression="${verbose}" default-value="false" */ private boolean verbose; /** * Ignore Runtime,Provide,Test,System scopes for unused dependency analysis - * + * * @parameter expression="${ignoreNonCompile}" default-value="false" */ private boolean ignoreNonCompile; /** * Output the xml for the missing dependencies - * + * * @parameter expression="${outputXML}" default-value="false" * @since 2.0-alpha-5 */ @@ -97,7 +109,7 @@ /** * Output scriptable values - * + * * @parameter expression="${scriptableOutput}" default-value="false" * @since 2.0-alpha-5 */ @@ -105,7 +117,7 @@ /** * Flag to use for scriptable output - * + * * @parameter expression="${scriptableFlag}" default-value="$$$%%%" * @since 2.0-alpha-5 */ @@ -113,7 +125,7 @@ /** * Flag to use for scriptable output - * + * * @parameter expression="${basedir}" * @readonly * @since 2.0-alpha-5 @@ -122,7 +134,7 @@ /** * Target folder - * + * * @parameter expression="${project.build.directory}" * @readonly * @since 2.0-alpha-5 @@ -142,8 +154,8 @@ getLog().info( "Skipping pom project" ); return; } - - if ( outputDirectory == null || !outputDirectory.exists()) + + if ( outputDirectory == null || !outputDirectory.exists() ) { getLog().info( "Skipping project with no build directory" ); return; @@ -157,6 +169,32 @@ } } + protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() + throws MojoExecutionException + { + + final String role = ProjectDependencyAnalyzer.ROLE; + final String roleHint = analyzer; + + try + { + final PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + + return (ProjectDependencyAnalyzer) container.lookup( role, roleHint ); + } + catch ( Exception exception ) + { + throw new MojoExecutionException( "Failed to instantiate ProjectDependencyAnalyser with role " + role + + " / role-hint " + roleHint,exception ); + } + } + + public void contextualize( Context context ) + throws ContextException + { + this.context = context; + } + // private methods -------------------------------------------------------- private boolean checkDependencies() @@ -165,24 +203,24 @@ ProjectDependencyAnalysis analysis; try { - analysis = analyzer.analyze( project ); + analysis = createProjectDependencyAnalyzer().analyze( project ); } catch ( ProjectDependencyAnalyzerException exception ) { throw new MojoExecutionException( "Cannot analyze dependencies", exception ); } - Set usedDeclared = analysis.getUsedDeclaredArtifacts(); - Set usedUndeclared = analysis.getUsedUndeclaredArtifacts(); - Set unusedDeclared = analysis.getUnusedDeclaredArtifacts(); - + Set usedDeclared = analysis.getUsedDeclaredArtifacts(); + Set usedUndeclared = analysis.getUsedUndeclaredArtifacts(); + Set unusedDeclared = analysis.getUnusedDeclaredArtifacts(); + if ( ignoreNonCompile ) { - Set filteredUnusedDeclared = new HashSet( unusedDeclared ); - Iterator iter = filteredUnusedDeclared.iterator(); + Set filteredUnusedDeclared = new HashSet( unusedDeclared ); + Iterator iter = filteredUnusedDeclared.iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); if ( !artifact.getScope().equals( Artifact.SCOPE_COMPILE ) ) { iter.remove(); @@ -196,14 +234,14 @@ getLog().info( "No dependency problems found" ); return false; } - + if ( verbose && !usedDeclared.isEmpty() ) { getLog().info( "Used declared dependencies found:" ); logArtifacts( analysis.getUsedDeclaredArtifacts(), false ); } - + if ( !usedUndeclared.isEmpty() ) { getLog().warn( "Used undeclared dependencies found:" ); @@ -214,7 +252,7 @@ if ( !unusedDeclared.isEmpty() ) { getLog().warn( "Unused declared dependencies found:" ); - + logArtifacts( unusedDeclared, true ); } @@ -222,7 +260,7 @@ { writeDependencyXML( usedUndeclared ); } - + if ( scriptableOutput ) { writeScriptableOutput( usedUndeclared ); @@ -231,7 +269,7 @@ return !usedUndeclared.isEmpty() || !unusedDeclared.isEmpty(); } - private void logArtifacts( Set artifacts, boolean warn ) + private void logArtifacts( Set artifacts, boolean warn ) { if ( artifacts.isEmpty() ) { @@ -239,10 +277,8 @@ } else { - for ( Iterator iterator = artifacts.iterator(); iterator.hasNext(); ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iterator.next(); - // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961 artifact.isSnapshot(); @@ -259,7 +295,7 @@ } } - private void writeDependencyXML( Set artifacts ) + private void writeDependencyXML( Set artifacts ) { if ( !artifacts.isEmpty() ) { @@ -268,11 +304,8 @@ StringWriter out = new StringWriter(); PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( out ); - Iterator iter = artifacts.iterator(); - while ( iter.hasNext() ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iter.next(); - // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961 artifact.isSnapshot(); @@ -285,6 +318,12 @@ writer.endElement(); writer.startElement( "version" ); writer.writeText( artifact.getBaseVersion() ); + if ( !StringUtils.isBlank( artifact.getClassifier() ) ) + { + writer.startElement( "classifier" ); + writer.writeText( artifact.getClassifier() ); + writer.endElement(); + } writer.endElement(); if ( !Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) ) @@ -299,19 +338,17 @@ getLog().info( "\n" + out.getBuffer() ); } } - - private void writeScriptableOutput( Set artifacts ) + + private void writeScriptableOutput( Set artifacts ) { if ( !artifacts.isEmpty() ) { getLog().info( "Missing dependencies: " ); String pomFile = baseDir.getAbsolutePath() + File.separatorChar + "pom.xml"; StringBuffer buf = new StringBuffer(); - Iterator iter = artifacts.iterator(); - while ( iter.hasNext() ) - { - Artifact artifact = (Artifact) iter.next(); + for ( Artifact artifact : artifacts ) + { // called because artifact will set the version to -SNAPSHOT only if I do this. MNG-2961 artifact.isSnapshot(); diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -1,30 +1,28 @@ package org.apache.maven.plugin.dependency; /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ import java.io.File; import java.util.HashSet; import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.dependency.utils.DependencyStatusSets; +import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.resolvers.ArtifactsResolver; import org.apache.maven.plugin.dependency.utils.resolvers.DefaultArtifactsResolver; import org.apache.maven.plugin.dependency.utils.translators.ArtifactTranslator; @@ -35,17 +33,17 @@ import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter; +import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter; import org.apache.maven.shared.artifact.filter.collection.ScopeFilter; -import org.apache.maven.shared.artifact.filter.collection.TransitivityFilter; import org.apache.maven.shared.artifact.filter.collection.TypeFilter; import org.codehaus.plexus.util.StringUtils; /** - * Class that excapusulates the plugin parameters, and contains methods that + * Class that encapsulates the plugin parameters, and contains methods that * handle dependency filtering - * + * * @author Brian Fox - * @version $Id: AbstractDependencyFilterMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: AbstractDependencyFilterMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @see org.apache.maven.plugin.dependency.AbstractDependencyMojo */ public abstract class AbstractDependencyFilterMojo @@ -53,7 +51,7 @@ { /** * If we should exclude transitive dependencies - * + * * @since 2.0 * @optional * @parameter expression="${excludeTransitive}" default-value="false" @@ -63,7 +61,7 @@ /** * Comma Separated list of Types to include. Empty String indicates include * everything (default). - * + * * @since 2.0 * @parameter expression="${includeTypes}" default-value="" * @optional @@ -73,7 +71,7 @@ /** * Comma Separated list of Types to exclude. Empty String indicates don't * exclude anything (default). - * + * * @since 2.0 * @parameter expression="${excludeTypes}" default-value="" * @optional @@ -82,7 +80,7 @@ /** * Scope to include. An Empty string indicates all scopes (default). - * + * * @since 2.0 * @parameter expression="${includeScope}" default-value="" * @optional @@ -91,7 +89,7 @@ /** * Scope to exclude. An Empty string indicates no scopes (default). - * + * * @since 2.0 * @parameter expression="${excludeScope}" default-value="" * @optional @@ -101,7 +99,7 @@ /** * Comma Separated list of Classifiers to include. Empty String indicates * include everything (default). - * + * * @since 2.0 * @parameter expression="${includeClassifiers}" default-value="" * @optional @@ -111,7 +109,7 @@ /** * Comma Separated list of Classifiers to exclude. Empty String indicates * don't exclude anything (default). - * + * * @since 2.0 * @parameter expression="${excludeClassifiers}" default-value="" * @optional @@ -120,7 +118,7 @@ /** * Specify classifier to look for. Example: sources - * + * * @optional * @since 2.0 * @parameter expression="${classifier}" default-value="" @@ -130,7 +128,7 @@ /** * Specify type to look for when constructing artifact based on classifier. * Example: java-source,jar,war - * + * * @optional * @since 2.0 * @parameter expression="${type}" default-value="java-source" @@ -139,7 +137,7 @@ /** * Comma separated list of Artifact names too exclude. - * + * * @since 2.0 * @optional * @parameter expression="${excludeArtifactIds}" default-value="" @@ -148,7 +146,7 @@ /** * Comma separated list of Artifact names to include. - * + * * @since 2.0 * @optional * @parameter expression="${includeArtifactIds}" default-value="" @@ -157,7 +155,7 @@ /** * Comma separated list of GroupId Names to exclude. - * + * * @since 2.0 * @optional * @parameter expression="${excludeGroupIds}" default-value="" @@ -166,7 +164,7 @@ /** * Comma separated list of GroupIds to include. - * + * * @since 2.0 * @optional * @parameter expression="${includeGroupIds}" default-value="" @@ -175,7 +173,7 @@ /** * Directory to store flag files - * + * * @parameter expression="${markersDirectory}" * default-value="${project.build.directory}/dependency-maven-plugin-markers" * @optional @@ -185,7 +183,7 @@ /** * Overwrite release artifacts - * + * * @optional * @since 1.0 * @parameter expression="${overWriteReleases}" default-value="false" @@ -194,7 +192,7 @@ /** * Overwrite snapshot artifacts - * + * * @optional * @since 1.0 * @parameter expression="${overWriteSnapshots}" default-value="false" @@ -203,22 +201,33 @@ /** * Overwrite artifacts that don't exist or are older than the source. - * + * * @optional * @since 2.0 * @parameter expression="${overWriteIfNewer}" default-value="true" */ protected boolean overWriteIfNewer; + + /** + * Prepend the groupId during copy. + * + * @optional + * @since 2.2 + * @parameter expression="${mdep.prependGroupId}" default-value="false" + * @parameter + */ + protected boolean prependGroupId = false; protected abstract ArtifactsFilter getMarkedArtifactFilter(); /** * Retrieves dependencies, either direct only or all including transitive. - * + * * @return A HashSet of artifacts - * @throws MojoExecutionException + * @throws MojoExecutionException */ - protected Set getResolvedDependencies( boolean stopOnFailure )throws MojoExecutionException + protected Set getResolvedDependencies( boolean stopOnFailure ) + throws MojoExecutionException { DependencyStatusSets status = getDependencySets( stopOnFailure ); @@ -227,15 +236,15 @@ } /** - * + * * Method creates filters and filters the projects dependencies. This method * also transforms the dependencies if classifier is set. The dependencies * are filtered in least specific to most specific order - * + * * @param stopOnFailure * @return DependencyStatusSets - Bean of TreeSets that contains information * on the projects dependencies - * @throws MojoExecutionException + * @throws MojoExecutionException */ protected DependencyStatusSets getDependencySets( boolean stopOnFailure ) throws MojoExecutionException @@ -243,15 +252,25 @@ // add filters in well known order, least specific to most specific FilterArtifacts filter = new FilterArtifacts(); - filter.addFilter( new TransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive ) ); - filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) ); - filter.addFilter( new TypeFilter( this.includeTypes, this.excludeTypes ) ); - filter.addFilter( new ClassifierFilter( this.includeClassifiers, this.excludeClassifiers ) ); - filter.addFilter( new GroupIdFilter( this.includeGroupIds, this.excludeGroupIds ) ); - filter.addFilter( new ArtifactIdFilter( this.includeArtifactIds, this.excludeArtifactIds ) ); + filter.addFilter( new ProjectTransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive ) ); + + filter.addFilter( new ScopeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeScope ), + DependencyUtil.cleanToBeTokenizedString( this.excludeScope ) ) ); + + filter.addFilter( new TypeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeTypes ), + DependencyUtil.cleanToBeTokenizedString( this.excludeTypes ) ) ); + + filter.addFilter( new ClassifierFilter( DependencyUtil.cleanToBeTokenizedString( this.includeClassifiers ), + DependencyUtil.cleanToBeTokenizedString( this.excludeClassifiers ) ) ); + + filter.addFilter( new GroupIdFilter( DependencyUtil.cleanToBeTokenizedString( this.includeGroupIds ), + DependencyUtil.cleanToBeTokenizedString( this.excludeGroupIds ) ) ); + + filter.addFilter( new ArtifactIdFilter( DependencyUtil.cleanToBeTokenizedString( this.includeArtifactIds ), + DependencyUtil.cleanToBeTokenizedString( this.excludeArtifactIds ) ) ); // start with all artifacts. - Set artifacts = project.getArtifacts(); + Set artifacts = project.getArtifacts(); // perform filtering try @@ -260,7 +279,7 @@ } catch ( ArtifactFilterException e ) { - throw new MojoExecutionException(e.getMessage(),e); + throw new MojoExecutionException( e.getMessage(), e ); } // transform artifacts if classifier is set @@ -278,20 +297,20 @@ } /** - * + * * Transform artifacts - * + * * @param artifacts * @param stopOnFailure * @return DependencyStatusSets - Bean of TreeSets that contains information * on the projects dependencies * @throws MojoExecutionException */ - protected DependencyStatusSets getClassifierTranslatedDependencies( Set artifacts, boolean stopOnFailure ) + protected DependencyStatusSets getClassifierTranslatedDependencies( Set artifacts, boolean stopOnFailure ) throws MojoExecutionException { - Set unResolvedArtifacts = new HashSet(); - Set resolvedArtifacts = artifacts; + Set unResolvedArtifacts = new HashSet(); + Set resolvedArtifacts = artifacts; DependencyStatusSets status = new DependencyStatusSets(); // possibly translate artifacts into a new set of artifacts based on the @@ -308,7 +327,7 @@ artifacts = status.getResolvedDependencies(); // resolve the rest of the artifacts - ArtifactsResolver artifactsResolver = new DefaultArtifactsResolver( this.resolver, this.local, + ArtifactsResolver artifactsResolver = new DefaultArtifactsResolver( this.resolver, this.getLocal(), this.remoteRepos, stopOnFailure ); resolvedArtifacts = artifactsResolver.resolve( artifacts, getLog() ); @@ -326,12 +345,12 @@ /** * Filter the marked dependencies - * + * * @param artifacts * @return * @throws MojoExecutionException */ - protected DependencyStatusSets filterMarkedDependencies( Set artifacts ) + protected DependencyStatusSets filterMarkedDependencies( Set artifacts ) throws MojoExecutionException { // remove files that have markers already @@ -339,18 +358,18 @@ filter.clearFilters(); filter.addFilter( getMarkedArtifactFilter() ); - Set unMarkedArtifacts; + Set unMarkedArtifacts; try { unMarkedArtifacts = filter.filter( artifacts ); } catch ( ArtifactFilterException e ) { - throw new MojoExecutionException(e.getMessage(),e); + throw new MojoExecutionException( e.getMessage(), e ); } // calculate the skipped artifacts - Set skippedArtifacts = new HashSet(); + Set skippedArtifacts = new HashSet(); skippedArtifacts.addAll( artifacts ); skippedArtifacts.removeAll( unMarkedArtifacts ); @@ -375,4 +394,21 @@ } // TODO: Set marker files. + + /** + * @return true, if the groupId should be prepended to the filename. + */ + public boolean isPrependGroupId() + { + return prependGroupId; + } + + /** + * @param prependGroupId - + * true if the groupId must be prepended during the copy. + */ + public void setPrependGroupId( boolean prependGroupId ) + { + this.prependGroupId = prependGroupId; + } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java 2009-01-04 13:11:57.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java 2011-04-02 15:55:28.000000000 +0000 @@ -23,8 +23,11 @@ import java.lang.reflect.Field; import java.util.List; +import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactCollector; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.dependency.utils.DependencySilentLog; @@ -52,14 +55,14 @@ * * @component */ - protected org.apache.maven.artifact.factory.ArtifactFactory factory; + protected ArtifactFactory factory; /** * Used to look up Artifacts in the remote repository. * * @component */ - protected org.apache.maven.artifact.resolver.ArtifactResolver resolver; + protected ArtifactResolver resolver; /** * Artifact collector, needed to resolve dependencies. @@ -85,7 +88,7 @@ * @readonly * @required */ - protected org.apache.maven.artifact.repository.ArtifactRepository local; + private ArtifactRepository local; /** * List of Remote Repositories used by the resolver @@ -94,7 +97,7 @@ * @readonly * @required */ - protected java.util.List remoteRepos; + protected List remoteRepos; /** * To look up Archiver/UnArchiver implementations @@ -119,7 +122,7 @@ * @required * @readonly */ - protected List reactorProjects; + protected List reactorProjects; /** * If the plugin should be silent. @@ -146,7 +149,7 @@ /** * @return Returns the log. */ - public Log getLog () + public Log getLog() { if ( silent ) { @@ -163,7 +166,7 @@ /** * @return Returns the archiverManager. */ - public ArchiverManager getArchiverManager () + public ArchiverManager getArchiverManager() { return this.archiverManager; } @@ -177,7 +180,7 @@ * @throws MojoExecutionException with a message if an * error occurs. */ - protected void copyFile ( File artifact, File destFile ) + protected void copyFile( File artifact, File destFile ) throws MojoExecutionException { Log theLog = this.getLog(); @@ -195,7 +198,7 @@ } } - protected void unpack ( File file, File location ) + protected void unpack( File file, File location ) throws MojoExecutionException { unpack( file, location, null, null ); @@ -205,23 +208,18 @@ * Unpacks the archive file. * * @param file File to be unpacked. - * @param location Location where to put the unpacked - * files. - * @param includes Comma separated list of file patterns - * to include i.e. **/.xml, - * **/*.properties - * @param excludes Comma separated list of file patterns - * to exclude i.e. **/*.xml, - * **/*.properties + * @param location Location where to put the unpacked files. + * @param includes Comma separated list of file patterns to include i.e. **/.xml, + * **/*.properties + * @param excludes Comma separated list of file patterns to exclude i.e. **/*.xml, + * **/*.properties */ - protected void unpack ( File file, File location, String includes, String excludes ) + protected void unpack( File file, File location, String includes, String excludes ) throws MojoExecutionException { try { - getLog().info( - "Unpacking " + file.getPath() + " to\n " + location.getPath() - + "\n with includes " + includes + " and excludes:" + excludes ); + logUnpack( file, location, includes, excludes ); location.mkdirs(); @@ -271,11 +269,9 @@ } } - private void silenceUnarchiver ( UnArchiver unArchiver ) + private void silenceUnarchiver( UnArchiver unArchiver ) { - // dangerous but handle any errors. It's the only - // way to silence the - // unArchiver. + // dangerous but handle any errors. It's the only way to silence the unArchiver. try { Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( "logger", unArchiver.getClass() ); @@ -286,15 +282,14 @@ } catch ( Exception e ) { - // was a nice try. Don't bother logging because - // the log is silent. + // was a nice try. Don't bother logging because the log is silent. } } /** * @return Returns the factory. */ - public org.apache.maven.artifact.factory.ArtifactFactory getFactory () + public ArtifactFactory getFactory() { return this.factory; } @@ -302,7 +297,7 @@ /** * @param factory The factory to set. */ - public void setFactory ( org.apache.maven.artifact.factory.ArtifactFactory factory ) + public void setFactory( ArtifactFactory factory ) { this.factory = factory; } @@ -310,7 +305,7 @@ /** * @return Returns the project. */ - public MavenProject getProject () + public MavenProject getProject() { return this.project; } @@ -318,7 +313,7 @@ /** * @return Returns the local. */ - public org.apache.maven.artifact.repository.ArtifactRepository getLocal () + protected ArtifactRepository getLocal() { return this.local; } @@ -326,7 +321,7 @@ /** * @param local The local to set. */ - public void setLocal ( org.apache.maven.artifact.repository.ArtifactRepository local ) + public void setLocal( ArtifactRepository local ) { this.local = local; } @@ -334,7 +329,7 @@ /** * @return Returns the remoteRepos. */ - public java.util.List getRemoteRepos () + public List getRemoteRepos() { return this.remoteRepos; } @@ -342,7 +337,7 @@ /** * @param remoteRepos The remoteRepos to set. */ - public void setRemoteRepos ( java.util.List remoteRepos ) + public void setRemoteRepos( List remoteRepos ) { this.remoteRepos = remoteRepos; } @@ -350,7 +345,7 @@ /** * @return Returns the resolver. */ - public org.apache.maven.artifact.resolver.ArtifactResolver getResolver () + public org.apache.maven.artifact.resolver.ArtifactResolver getResolver() { return this.resolver; } @@ -358,7 +353,7 @@ /** * @param resolver The resolver to set. */ - public void setResolver ( org.apache.maven.artifact.resolver.ArtifactResolver resolver ) + public void setResolver( ArtifactResolver resolver ) { this.resolver = resolver; } @@ -366,7 +361,7 @@ /** * @param archiverManager The archiverManager to set. */ - public void setArchiverManager ( ArchiverManager archiverManager ) + public void setArchiverManager( ArchiverManager archiverManager ) { this.archiverManager = archiverManager; } @@ -374,16 +369,15 @@ /** * @return Returns the artifactCollector. */ - public ArtifactCollector getArtifactCollector () + public ArtifactCollector getArtifactCollector() { return this.artifactCollector; } /** - * @param theArtifactCollector The artifactCollector to - * set. + * @param theArtifactCollector The artifactCollector to set. */ - public void setArtifactCollector ( ArtifactCollector theArtifactCollector ) + public void setArtifactCollector( ArtifactCollector theArtifactCollector ) { this.artifactCollector = theArtifactCollector; } @@ -391,17 +385,53 @@ /** * @return Returns the artifactMetadataSource. */ - public ArtifactMetadataSource getArtifactMetadataSource () + public ArtifactMetadataSource getArtifactMetadataSource() { return this.artifactMetadataSource; } /** - * @param theArtifactMetadataSource The - * artifactMetadataSource to set. + * @param theArtifactMetadataSource The artifactMetadataSource to set. */ - public void setArtifactMetadataSource ( ArtifactMetadataSource theArtifactMetadataSource ) + public void setArtifactMetadataSource( ArtifactMetadataSource theArtifactMetadataSource ) { this.artifactMetadataSource = theArtifactMetadataSource; } + + private void logUnpack( File file, File location, String includes, String excludes ) + { + if ( !getLog().isInfoEnabled() ) + { + return; + } + + StringBuffer msg = new StringBuffer(); + msg.append( "Unpacking " ); + msg.append( file ); + msg.append( " to " ); + msg.append( location ); + + if ( includes != null && excludes != null ) + { + msg.append( " with includes \"" ); + msg.append( includes ); + msg.append( "\" and excludes \"" ); + msg.append( excludes ); + msg.append( "\"" ); + } + else if ( includes != null ) + { + msg.append( " with includes \"" ); + msg.append( includes ); + msg.append( "\"" ); + } + else if ( excludes != null ) + { + msg.append( " with excludes \"" ); + msg.append( excludes ); + msg.append( "\"" ); + } + + getLog().info( msg.toString() ); + } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractFromDependenciesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractFromDependenciesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractFromDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractFromDependenciesMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -16,7 +16,7 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; @@ -24,9 +24,9 @@ /** * Abstract Parent class used by mojos that get Artifact information from the * project dependencies. - * + * * @author Brian Fox - * @version $Id: AbstractFromDependenciesMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: AbstractFromDependenciesMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ */ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFilterMojo @@ -34,16 +34,16 @@ /** * Strip artifact version during copy - * + * * @optional * @parameter expression="${mdep.stripVersion}" default-value="false" * @parameter */ protected boolean stripVersion = false; - + /** * Default location used for mojo unless overridden in ArtifactItem - * + * * @parameter expression="${outputDirectory}" * default-value="${project.build.directory}/dependency" * @optional @@ -62,18 +62,28 @@ /** * Also copy the pom of each artifact. - * + * * @since 2.0 * @parameter expression="${mdep.copyPom}" * default-value="false" * @optional */ protected boolean copyPom = true; - + + /** + * Place each type of file in a separate subdirectory. (example + * /outputDirectory/runtime /outputDirectory/provided etc) + * + * @parameter expression="${mdep.useSubDirectoryPerScope}" default-value="false" + * @optional + * @since 2.2 + */ + protected boolean useSubDirectoryPerScope; + /** * Place each type of file in a separate subdirectory. (example * /outputDirectory/jars /outputDirectory/wars etc) - * + * * @since 2.0-alpha-1 * @parameter expression="${mdep.useSubDirectoryPerType}" default-value="false" * @optional @@ -82,8 +92,8 @@ /** * Place each file in a separate subdirectory. (example - * /outputDirectory/junit-3.8.1-jar) - * + * /outputDirectory/junit-3.8.1-jar) + * * @since 2.0-alpha-1 * @parameter expression="${mdep.useSubDirectoryPerArtifact}" * default-value="false" @@ -93,7 +103,7 @@ /** * This only applies if the classifier parameter is used. - * + * * @since 2.0-alpha-2 * @parameter expression="${mdep.failOnMissingClassifierArtifact}" * default-value="true" @@ -136,6 +146,23 @@ } /** + * @return Returns the useSubDirectoryPerScope + */ + public boolean isUseSubDirectoryPerScope() + { + return this.useSubDirectoryPerScope; + } + + /** + * @param theUseSubDirectoryPerScope + * The useSubDirectoryPerScope to set. + */ + public void setUseSubDirectoryPerScope( boolean theUseSubDirectoryPerScope ) + { + this.useSubDirectoryPerScope = theUseSubDirectoryPerScope; + } + + /** * @return Returns the useSubDirectoryPerType. */ public boolean isUseSubDirectoryPerType() @@ -173,7 +200,7 @@ } /** - * + * * @return true, if dependencies must be planted in a repository layout */ public boolean isUseRepositoryLayout() @@ -182,7 +209,7 @@ } /** - * + * * @param useRepositoryLayout - * true if dependencies must be planted in a repository layout */ @@ -194,14 +221,17 @@ /** * @return true, if the pom of each artifact must be copied */ - public boolean isCopyPom() { + public boolean isCopyPom() + { return this.copyPom; } /** * @param copyPom - true if the pom of each artifact must be copied */ - public void setCopyPom(boolean copyPom) { + public void setCopyPom( boolean copyPom ) + { this.copyPom = copyPom; } + } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -16,11 +16,10 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -34,75 +33,86 @@ /** * @author Brian Fox - * @version $Id: AbstractResolveMojo.java 728546 2008-12-21 22:56:51Z bentmann $ - * + * @version $Id: AbstractResolveMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ + * */ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo { /** * Project builder -- builds a model from a pom.xml - * + * * @component role="org.apache.maven.project.MavenProjectBuilder" * @required * @readonly */ protected MavenProjectBuilder mavenProjectBuilder; + /** * If specified, this parameter will cause the dependencies to be written to the path specified, instead of writing * to the console. - * + * * @parameter expression="${outputFile}" * @since 2.0 */ protected File outputFile; + /** * This method resolves the dependency artifacts from the project. - * + * * @param theProject * The POM. * @return resolved set of dependency artifacts. - * + * * @throws ArtifactResolutionException * @throws ArtifactNotFoundException * @throws InvalidDependencyVersionException */ - protected Set resolveDependencyArtifacts( MavenProject theProject ) + + /** + * Whether to append outputs into the output file or overwrite it. + * + * @parameter expression="${appendOutput}" default-value="false" + * @since 2.2 + */ + protected boolean appendOutput; + + protected Set resolveDependencyArtifacts( MavenProject theProject ) throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException { - Set artifacts = theProject.createArtifacts( this.factory, Artifact.SCOPE_TEST, - new ScopeArtifactFilter( Artifact.SCOPE_TEST ) ); + Set artifacts = + theProject.createArtifacts( this.factory, Artifact.SCOPE_TEST, + new ScopeArtifactFilter( Artifact.SCOPE_TEST ) ); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) i.next(); // resolve the new artifact - this.resolver.resolve( artifact, this.remoteRepos, this.local ); + this.resolver.resolve( artifact, this.remoteRepos, this.getLocal() ); } return artifacts; } /** * This method resolves all transitive dependencies of an artifact. - * + * * @param artifact * the artifact used to retrieve dependencies - * + * * @return resolved set of dependencies - * + * * @throws ArtifactResolutionException * @throws ArtifactNotFoundException * @throws ProjectBuildingException * @throws InvalidDependencyVersionException */ - protected Set resolveArtifactDependencies( Artifact artifact ) + protected Set resolveArtifactDependencies( Artifact artifact ) throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException, InvalidDependencyVersionException { Artifact pomArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact .getVersion(), "", "pom" ); - MavenProject pomProject = mavenProjectBuilder.buildFromRepository( pomArtifact, this.remoteRepos, this.local ); + MavenProject pomProject = mavenProjectBuilder.buildFromRepository( pomArtifact, this.remoteRepos, this.getLocal() ); return resolveDependencyArtifacts( pomProject ); } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDepMgt.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDepMgt.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDepMgt.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDepMgt.java 2011-03-26 18:13:19.000000000 +0000 @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -43,12 +42,12 @@ * to 2.0.6, it was possible to inherit versions that didn't match your * dependencyManagement. See MNG-1577 for more info. - * This mojo is also usefull for just detecting projects that override the + * This mojo is also useful for just detecting projects that override the * dependencyManagement directly. Set ignoreDirect to false to detect these * otherwise normal conditions. - * + * * @author Brian Fox - * @version $Id: AnalyzeDepMgt.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: AnalyzeDepMgt.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @goal analyze-dep-mgt * @requiresDependencyResolution test * @since 2.0-alpha-3 @@ -59,8 +58,8 @@ // fields ----------------------------------------------------------------- /** - * - * + * + * * @parameter expression="${project}" * @required * @readonly @@ -69,14 +68,14 @@ /** * Fail the build if a problem is detected. - * + * * @parameter expression="${mdep.analyze.failBuild}" default-value="false" */ private boolean failBuild = false; /** * Ignore Direct Dependency Overrides of dependencyManagement section. - * + * * @parameter expression="${mdep.analyze.ignore.direct}" default-value="true" */ private boolean ignoreDirect = true; @@ -116,7 +115,7 @@ getLog().info( "Found Resolved Dependency / DependencyManagement mismatches:" ); - List depMgtDependencies = null; + List depMgtDependencies = null; DependencyManagement depMgt = project.getDependencyManagement(); if ( depMgt != null ) @@ -127,12 +126,10 @@ if ( depMgtDependencies != null && !depMgtDependencies.isEmpty() ) { // put all the dependencies from depMgt into a map for quick lookup - Map depMgtMap = new HashMap(); - Map exclusions = new HashMap(); - Iterator iter = depMgtDependencies.iterator(); - while ( iter.hasNext() ) + Map depMgtMap = new HashMap(); + Map exclusions = new HashMap(); + for ( Dependency depMgtDependency : depMgtDependencies ) { - Dependency depMgtDependency = (Dependency) iter.next(); depMgtMap.put( depMgtDependency.getManagementKey(), depMgtDependency ); // now put all the exclusions into a map for quick lookup @@ -140,37 +137,34 @@ } // get dependencies for the project (including transitive) - Set allDependencyArtifacts = new HashSet( project.getArtifacts() ); + Set allDependencyArtifacts = new HashSet( project.getArtifacts() ); // don't warn if a dependency that is directly listed overrides // depMgt. That's ok. if ( this.ignoreDirect ) { getLog().info( "\tIgnoring Direct Dependencies." ); - Set directDependencies = project.getDependencyArtifacts(); + Set directDependencies = project.getDependencyArtifacts(); allDependencyArtifacts.removeAll( directDependencies ); } // log exclusion errors - List exclusionErrors = getExclusionErrors( exclusions, allDependencyArtifacts ); - Iterator exclusionIter = exclusionErrors.iterator(); - while ( exclusionIter.hasNext() ) + List exclusionErrors = getExclusionErrors( exclusions, allDependencyArtifacts ); + for ( Artifact exclusion : exclusionErrors ) { - Artifact exclusion = (Artifact) exclusionIter.next(); getLog().info( - StringUtils.stripEnd( getArtifactManagementKey( exclusion ),":") + " was excluded in DepMgt, but version " - + exclusion.getVersion() + " has been found in the dependency tree." ); + StringUtils.stripEnd( getArtifactManagementKey( exclusion ), ":" ) + + " was excluded in DepMgt, but version " + exclusion.getVersion() + + " has been found in the dependency tree." ); foundError = true; } // find and log version mismatches - Map mismatch = getMismatch( depMgtMap, allDependencyArtifacts ); - Iterator mismatchIter = mismatch.keySet().iterator(); - while ( mismatchIter.hasNext() ) + Map mismatch = getMismatch( depMgtMap, allDependencyArtifacts ); + for ( Map.Entry entry : mismatch.entrySet() ) { - Artifact resolvedArtifact = (Artifact) mismatchIter.next(); - Dependency depMgtDependency = (Dependency) mismatch.get( resolvedArtifact ); - logMismatch( resolvedArtifact, depMgtDependency ); + logMismatch( entry.getKey(), entry.getValue() ); + foundError = true; } if ( !foundError ) { @@ -190,21 +184,19 @@ /** * Returns a map of the exclusions using the Dependency ManagementKey as the * keyset. - * + * * @param exclusionList * to be added to the map. * @return a map of the exclusions using the Dependency ManagementKey as the * keyset. */ - public Map addExclusions( List exclusionList ) + public Map addExclusions( List exclusionList ) { - Map exclusions = new HashMap(); + Map exclusions = new HashMap(); if ( exclusionList != null ) { - Iterator exclusionIter = exclusionList.iterator(); - while ( exclusionIter.hasNext() ) + for ( Exclusion exclusion : exclusionList ) { - Exclusion exclusion = (Exclusion) exclusionIter.next(); exclusions.put( getExclusionKey( exclusion ), exclusion ); } } @@ -214,7 +206,7 @@ /** * Returns a List of the artifacts that should have been excluded, but were * found in the dependency tree. - * + * * @param exclusions * a map of the DependencyManagement exclusions, with the * ManagementKey as the key and Dependency as the value. @@ -222,14 +214,12 @@ * resolved artifacts to be compared. * @return list of artifacts that should have been excluded. */ - public List getExclusionErrors( Map exclusions, Set allDependencyArtifacts ) + public List getExclusionErrors( Map exclusions, Set allDependencyArtifacts ) { - List list = new ArrayList(); + List list = new ArrayList(); - Iterator iter = allDependencyArtifacts.iterator(); - while ( iter.hasNext() ) + for ( Artifact artifact : allDependencyArtifacts ) { - Artifact artifact = (Artifact) iter.next(); if ( exclusions.containsKey( getExclusionKey( artifact ) ) ) { list.add( artifact ); @@ -239,20 +229,20 @@ return list; } - public String getExclusionKey(Artifact artifact) + public String getExclusionKey( Artifact artifact ) { - return artifact.getGroupId()+":"+artifact.getArtifactId(); + return artifact.getGroupId() + ":" + artifact.getArtifactId(); } - - public String getExclusionKey(Exclusion ex) + + public String getExclusionKey( Exclusion ex ) { - return ex.getGroupId()+":"+ex.getArtifactId(); + return ex.getGroupId() + ":" + ex.getArtifactId(); } - + /** * Calculate the mismatches between the DependencyManagement and resolved * artifacts - * + * * @param depMgtMap * contains the Dependency.GetManagementKey as the keyset for * quick lookup. @@ -261,21 +251,19 @@ * @return a map containing the resolved artifact as the key and the listed * dependency as the value. */ - public Map getMismatch( Map depMgtMap, Set allDependencyArtifacts ) + public Map getMismatch( Map depMgtMap, + Set allDependencyArtifacts ) { - Map mismatchMap = new HashMap(); + Map mismatchMap = new HashMap(); - Iterator iter = allDependencyArtifacts.iterator(); - while ( iter.hasNext() ) + for ( Artifact dependencyArtifact : allDependencyArtifacts ) { - Artifact dependencyArtifact = (Artifact) iter.next(); - Dependency depFromDepMgt = (Dependency) depMgtMap.get( getArtifactManagementKey( dependencyArtifact ) ); + Dependency depFromDepMgt = depMgtMap.get( getArtifactManagementKey( dependencyArtifact ) ); if ( depFromDepMgt != null ) { - //workaround for MNG-2961 dependencyArtifact.isSnapshot(); - + if (!depFromDepMgt.getVersion().equals( dependencyArtifact.getBaseVersion()) ) { mismatchMap.put( dependencyArtifact, depFromDepMgt ); @@ -288,7 +276,7 @@ /** * This function displays the log to the screen showing the versions and * information about the artifacts that don't match. - * + * * @param dependencyArtifact * the artifact that was resolved. * @param dependencyFromDepMgt @@ -310,9 +298,8 @@ } /** - * This function returns a string comparable with - * Dependency.GetManagementKey. - * + * This function returns a string comparable with Dependency.GetManagementKey. + * * @param artifact * to gen the key for * @return a string in the form: groupId:ArtifactId:Type[:Classifier] @@ -320,7 +307,7 @@ public String getArtifactManagementKey( Artifact artifact ) { return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() - + (( artifact.getClassifier() !=null ) ? ":" + artifact.getClassifier() : "" ); + + ( ( artifact.getClassifier() != null ) ? ":" + artifact.getClassifier() : "" ); } /** diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDuplicateMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDuplicateMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDuplicateMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeDuplicateMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -0,0 +1,156 @@ +package org.apache.maven.plugin.dependency; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; + +/** + * Analyzes the <dependencies/> and <dependencyManagement/> tags in the + * pom.xml and determines the duplicate declared dependencies. + * + * @author Vincent Siveton + * @version $Id: AnalyzeDuplicateMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ + * @goal analyze-duplicate + * @aggregator false + */ +public class AnalyzeDuplicateMojo + extends AbstractMojo +{ + /** + * The Maven project to analyze. + * + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + + /** {@inheritDoc} */ + public void execute() + throws MojoExecutionException, MojoFailureException + { + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = null; + Reader reader = null; + try + { + reader = ReaderFactory.newXmlReader( project.getFile() ); + model = pomReader.read( reader ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "IOException: " + e.getMessage(), e ); + } + finally + { + IOUtil.close( reader ); + } + + Set duplicateDependencies = new HashSet(); + if ( model.getDependencies() != null ) + { + duplicateDependencies = findDuplicateDependencies( model.getDependencies() ); + } + + Set duplicateDependenciesManagement = new HashSet(); + if ( model.getDependencyManagement() != null && model.getDependencyManagement().getDependencies() != null ) + { + duplicateDependenciesManagement = + findDuplicateDependencies( model.getDependencyManagement().getDependencies() ); + } + + if ( getLog().isInfoEnabled() ) + { + StringBuffer sb = new StringBuffer(); + + if ( !duplicateDependencies.isEmpty() ) + { + sb.append( "List of duplicate dependencies defined in in your pom.xml:\n" ); + for ( Iterator it = duplicateDependencies.iterator(); it.hasNext(); ) + { + String dup = it.next(); + + sb.append( "\to " + dup ); + if ( it.hasNext() ) + { + sb.append( "\n" ); + } + } + } + + if ( !duplicateDependenciesManagement.isEmpty() ) + { + if ( sb.length() > 0 ) + { + sb.append( "\n" ); + } + sb.append( "List of duplicate dependencies defined in in " + + "your pom.xml:\n" ); + for ( Iterator it = duplicateDependenciesManagement.iterator(); it.hasNext(); ) + { + String dup = it.next(); + + sb.append( "\to " + dup ); + if ( it.hasNext() ) + { + sb.append( "\n" ); + } + } + } + + if ( sb.length() > 0 ) + { + getLog().info( sb.toString() ); + } + else + { + getLog().info( "No duplicate dependencies found in or in " ); + } + } + } + + private Set findDuplicateDependencies( List modelDependencies ) + { + List modelDependencies2 = new ArrayList(); + for ( Dependency dep : modelDependencies ) + { + modelDependencies2.add( dep.getManagementKey() ); + } + + return new HashSet( CollectionUtils.disjunction( modelDependencies2, + new HashSet( modelDependencies2 ) ) ); + } +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -20,9 +20,13 @@ */ import java.io.File; +import java.util.HashSet; +import java.util.Iterator; import java.util.Locale; import java.util.ResourceBundle; +import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.project.MavenProject; @@ -33,12 +37,11 @@ import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; /** - * Analyzes the dependencies of this project and produces a report that summarises which are: used and declared; used + * Analyzes the dependencies of this project and produces a report that summarizes which are: used and declared; used * and undeclared; unused and declared. * - * @version $Id: AnalyzeReportMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: AnalyzeReportMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ * @since 2.0-alpha-5 - * * @goal analyze-report * @requiresDependencyResolution test * @execute phase="test-compile" @@ -67,8 +70,6 @@ private ProjectDependencyAnalyzer analyzer; /** - * - * * @component * @required * @readonly @@ -84,6 +85,13 @@ */ private File outputDirectory; + /** + * Ignore Runtime,Provide,Test,System scopes for unused dependency analysis + * + * @parameter expression="${ignoreNonCompile}" default-value="false" + */ + private boolean ignoreNonCompile; + // Mojo methods ----------------------------------------------------------- /* @@ -97,14 +105,14 @@ getLog().info( "Skipping pom project" ); return; } - + if ( outputDirectory == null || !outputDirectory.exists() ) { getLog().info( "Skipping project with no Target directory" ); return; } - // Step 1: Analyse the project + // Step 1: Analyze the project ProjectDependencyAnalysis analysis = null; try { @@ -115,6 +123,26 @@ throw new MavenReportException( "Cannot analyze dependencies", exception ); } + + //remove everything that's not in the compile scope + if ( ignoreNonCompile ) + { + Set filteredUnusedDeclared = new HashSet( analysis.getUnusedDeclaredArtifacts() ); + Iterator iter = filteredUnusedDeclared.iterator(); + while ( iter.hasNext() ) + { + Artifact artifact = iter.next(); + if ( !artifact.getScope().equals( Artifact.SCOPE_COMPILE ) ) + { + iter.remove(); + } + } + + ProjectDependencyAnalysis analysisTemp = new ProjectDependencyAnalysis(analysis.getUsedDeclaredArtifacts(),analysis.getUsedUndeclaredArtifacts(),filteredUnusedDeclared); + analysis = analysisTemp; + } + + // Step 2: Create sink and bundle Sink sink = getSink(); ResourceBundle bundle = getBundle( locale ); @@ -123,7 +151,7 @@ AnalyzeReportView analyzethis = new AnalyzeReportView(); analyzethis.generateReport( analysis, sink, bundle ); } - + // MavenReport methods ---------------------------------------------------- /* @@ -149,7 +177,7 @@ { return getBundle( locale ).getString( "analyze.report.description" ); } - + // AbstractMavenReport methods -------------------------------------------- /* @@ -177,14 +205,11 @@ { return siteRenderer; } - + // protected methods ------------------------------------------------------ /** - * - * - * @param locale - * the current locale + * @param locale the current locale */ protected ResourceBundle getBundle( Locale locale ) { diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/AnalyzeReportView.java 2011-03-13 00:17:39.000000000 +0000 @@ -49,8 +49,6 @@ sink.sectionTitle1(); sink.text( bundle.getString( "analyze.report.mainTitle" ) ); sink.sectionTitle1_(); - sink.section1_(); - sink.lineBreak(); // Generate Used Declared dependencies: sink.section2(); @@ -59,12 +57,14 @@ sink.sectionTitle2_(); if ( analysis.getUsedDeclaredArtifacts().isEmpty() ) { + sink.paragraph(); sink.text( bundle.getString( "analyze.report.noDependency" ) ); + sink.paragraph_(); sink.horizontalRule(); } else { - Iterator iter = analysis.getUsedDeclaredArtifacts().iterator(); + Iterator iter = analysis.getUsedDeclaredArtifacts().iterator(); generateDependenciesTable( sink, iter ); } sink.section2_(); @@ -76,12 +76,14 @@ sink.sectionTitle2_(); if ( analysis.getUsedUndeclaredArtifacts().isEmpty() ) { + sink.paragraph(); sink.text( bundle.getString( "analyze.report.noDependency" ) ); + sink.paragraph_(); sink.horizontalRule(); } else { - Iterator iter = analysis.getUsedUndeclaredArtifacts().iterator(); + Iterator iter = analysis.getUsedUndeclaredArtifacts().iterator(); generateDependenciesTable( sink, iter ); } sink.section2_(); @@ -93,16 +95,20 @@ sink.sectionTitle2_(); if ( analysis.getUnusedDeclaredArtifacts().isEmpty() ) { + sink.paragraph(); sink.text( bundle.getString( "analyze.report.noDependency" ) ); + sink.paragraph_(); sink.horizontalRule(); } else { - Iterator iter = analysis.getUnusedDeclaredArtifacts().iterator(); + Iterator iter = analysis.getUnusedDeclaredArtifacts().iterator(); generateDependenciesTable( sink, iter ); } sink.section2_(); + sink.section1_(); + // Closing the report sink.body_(); sink.flush(); @@ -112,7 +118,7 @@ /** * Generate a table for the given dependencies iterator. */ - public void generateDependenciesTable( Sink sink, Iterator iter ) + public void generateDependenciesTable( Sink sink, Iterator iter ) { sink.table(); @@ -162,7 +168,7 @@ sink.tableRow_(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); sink.tableRow(); sink.tableCell(); diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -16,7 +16,7 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.BufferedReader; @@ -31,32 +31,35 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; /** * This goal will output a classpath string of dependencies from the local repository to a file or log. - * + * * @goal build-classpath * @requiresDependencyResolution test * @phase generate-sources * @author ankostis - * @version $Id: BuildClasspathMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: BuildClasspathMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0-alpha-2 */ public class BuildClasspathMojo extends AbstractDependencyFilterMojo - implements Comparator + implements Comparator { /** * Strip artifact version during copy (only works if prefix is set) - * + * * @parameter expression="${mdep.stripVersion}" default-value="false" * @parameter */ @@ -65,7 +68,7 @@ /** * The prefix to prepend on each dependent artifact. If undefined, the paths refer to the actual files store in the * local repository (the stipVersion parameter does nothing then). - * + * * @parameter expression="${mdep.prefix}" */ private String prefix; @@ -84,10 +87,10 @@ * @parameter expression="${mdep.outputFile}" */ private File outputFile; - + /** * If 'true', it skips the up-to-date-check, and always regenerates the classpath file. - * + * * @parameter default-value="false" expression="${mdep.regenerateFile}" */ private boolean regenerateFile; @@ -96,7 +99,7 @@ * Override the char used between the paths. This field is initialized to contain the first character of the value * of the system property file.separator. On UNIX systems the value of this field is '/'; on Microsoft Windows * systems it is '\'. The default is File.separator - * + * * @since 2.0 * @parameter default-value="" expression="${mdep.fileSeparator}" */ @@ -107,7 +110,7 @@ * initialized to contain the first character of the value of the system property path.separator. This character is * used to separate filenames in a sequence of files given as a path list. On UNIX systems, this character is ':'; * on Microsoft Windows systems it is ';'. - * + * * @since 2.0 * @parameter default-value="" expression="${mdep.pathSeparator}" */ @@ -116,7 +119,7 @@ /** * Replace the absolute path to the local repo with this property. This field is ignored it prefix is declared. The * value will be forced to "${M2_REPO}" if no value is provided AND the attach flag is true. - * + * * @since 2.0 * @parameter default-value="" expression="${mdep.localRepoProperty}" */ @@ -124,15 +127,15 @@ /** * Attach the classpath file to the main artifact so it can be installed and deployed. - * + * * @since 2.0 * @parameter default-value=false */ boolean attach; - + /** * Write out the classpath in a format compatible with filtering (classpath=xxxxx) - * + * * @since 2.0 * @parameter default-value=false expression="${mdep.outputFilterFile}" */ @@ -140,7 +143,7 @@ /** * Maven ProjectHelper - * + * * @component * @readonly */ @@ -152,7 +155,7 @@ /** * Main entry into mojo. Gets the list of dependencies and iterates through calling copyArtifact. - * + * * @throws MojoExecutionException with a message if an error occurs. * @see #getDependencies * @see #copyArtifact(Artifact, boolean) @@ -160,31 +163,16 @@ public void execute() throws MojoExecutionException { - - if (cpFile != null) + + if ( cpFile != null ) { getLog().warn( "The parameter cpFile is deprecated. Use outputFile instead." ); this.outputFile = cpFile; } - - // initialize the separators. - if ( StringUtils.isEmpty( fileSeparator ) ) - { - isFileSepSet = false; - } - else - { - isFileSepSet = true; - } - if ( StringUtils.isEmpty( pathSeparator ) ) - { - isPathSepSet = false; - } - else - { - isPathSepSet = true; - } + // initialize the separators. + isFileSepSet = StringUtils.isNotEmpty( fileSeparator ); + isPathSepSet = StringUtils.isNotEmpty( pathSeparator ); //don't allow them to have absolute paths when they attach. if ( attach && StringUtils.isEmpty( localRepoProperty ) ) @@ -192,21 +180,21 @@ localRepoProperty = "${M2_REPO}"; } - Set artifacts = getResolvedDependencies( true ); + Set artifacts = getResolvedDependencies( true ); if ( artifacts == null || artifacts.isEmpty() ) { getLog().info( "No dependencies found." ); } - List artList = new ArrayList( artifacts ); + List artList = new ArrayList( artifacts ); StringBuffer sb = new StringBuffer(); - Iterator i = artList.iterator(); + Iterator i = artList.iterator(); if ( i.hasNext() ) { - appendArtifactPath( (Artifact) i.next(), sb ); + appendArtifactPath( i.next(), sb ); while ( i.hasNext() ) { @@ -221,23 +209,18 @@ // the file paths that were pulled from the artifacts if ( isFileSepSet ) { - String separator = File.separator; - - // if the file sep is "\" then I need to escape it for the regex - if ( File.separator.equals( "\\" ) ) - { - separator = "\\\\"; - } - - cpString = cpString.replaceAll( separator, fileSeparator ); + // Escape file separators to be used as literal strings + final String pattern = Pattern.quote( File.separator ); + final String replacement = Matcher.quoteReplacement( fileSeparator ); + cpString = cpString.replaceAll( pattern, replacement ); } //make the string valid for filtering - if (outputFilterFile) + if ( outputFilterFile ) { - cpString = "classpath="+ cpString; + cpString = "classpath=" + cpString; } - + if ( outputFile == null ) { getLog().info( "Dependencies classpath:\n" + cpString ); @@ -270,7 +253,7 @@ /** * Appends the artifact path into the specified stringBuffer. - * + * * @param art * @param sb */ @@ -282,7 +265,7 @@ // substitute the property for the local repo path to make the classpath file portable. if ( StringUtils.isNotEmpty( localRepoProperty ) ) { - file = StringUtils.replace( file, local.getBasedir(), localRepoProperty ); + file = StringUtils.replace( file, getLocal().getBasedir(), localRepoProperty ); } sb.append( file ); } @@ -291,13 +274,13 @@ // TODO: add param for prepending groupId and version. sb.append( prefix ); sb.append( File.separator ); - sb.append( DependencyUtil.getFormattedFileName( art, this.stripVersion ) ); + sb.append( DependencyUtil.getFormattedFileName( art, this.stripVersion, this.prependGroupId) ); } } /** * Checks that new classpath differs from that found inside the old classpathFile. - * + * * @param cpString * @return true if the specified classpath equals to that found inside the file, false otherwise (including when * file does not exists but new classpath does). @@ -319,51 +302,39 @@ /** * It stores the specified string into that file. - * + * * @param cpString the string to be written into the file. * @throws MojoExecutionException */ private void storeClasspathFile( String cpString, File out ) throws MojoExecutionException { - //make sure the parent path exists. out.getParentFile().mkdirs(); - + + Writer w = null; try { - - - Writer w = new BufferedWriter( new FileWriter( out ) ); - - try - { - w.write( cpString ); - - getLog().info( "Wrote classpath file '" + out + "'." ); - } - catch ( IOException ex ) - { - throw new MojoExecutionException( "Error while writting to classpath file '" + out + "': " + - ex.toString(), ex ); - } - finally - { - w.close(); - } + w = new BufferedWriter( new FileWriter( out ) ); + w.write( cpString ); + getLog().info( "Wrote classpath file '" + out + "'." ); } catch ( IOException ex ) { - throw new MojoExecutionException( "Error while opening/closing classpath file '" + out + "': " + - ex.toString(), ex ); + throw new MojoExecutionException( "Error while writting to classpath file '" + out + "': " + + ex.toString(), ex ); + } + finally + { + IOUtil.close( w ); } } /** * Reads into a string the file specified by the mojo param 'outputFile'. Assumes, the instance variable 'outputFile' is not * null. - * - * @return the string contained in the classpathFile, if exists, or null ortherwise. + * + * @return the string contained in the classpathFile, if exists, or null otherwise. * @throws MojoExecutionException */ protected String readClasspathFile() @@ -380,10 +351,11 @@ return null; } StringBuffer sb = new StringBuffer(); - BufferedReader r = new BufferedReader( new FileReader( outputFile ) ); + BufferedReader r = null; try { + r = new BufferedReader( new FileReader( outputFile ) ); String l; while ( ( l = r.readLine() ) != null ) { @@ -394,48 +366,38 @@ } finally { - r.close(); + IOUtil.close( r ); } } /** * Compares artifacts lexicographically, using pattern [group_id][artifact_id][version]. - * - * @param arg1 first object - * @param arg2 second object + * + * @param art1 first object + * @param art2 second object * @return the value 0 if the argument string is equal to this string; a value less than * 0 if this string is lexicographically less than the string argument; and a value greater * than 0 if this string is lexicographically greater than the string argument. */ - public int compare( Object arg1, Object arg2 ) + public int compare( Artifact art1, Artifact art2 ) { - if ( arg1 instanceof Artifact && arg2 instanceof Artifact ) + if ( art1 == art2 ) { - if ( arg1 == arg2 ) - { - return 0; - } - else if ( arg1 == null ) - { - return -1; - } - else if ( arg2 == null ) - { - return +1; - } - - Artifact art1 = (Artifact) arg1; - Artifact art2 = (Artifact) arg2; - - String s1 = art1.getGroupId() + art1.getArtifactId() + art1.getVersion(); - String s2 = art2.getGroupId() + art2.getArtifactId() + art2.getVersion(); - - return s1.compareTo( s2 ); + return 0; } - else + else if ( art1 == null ) { - return 0; + return -1; + } + else if ( art2 == null ) + { + return +1; } + + String s1 = art1.getGroupId() + art1.getArtifactId() + art1.getVersion(); + String s2 = art2.getGroupId() + art2.getArtifactId() + art2.getVersion(); + + return s1.compareTo( s2 ); } protected ArtifactsFilter getMarkedArtifactFilter() diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java 2009-01-04 13:11:57.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -16,12 +16,12 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; import java.net.MalformedURLException; -import java.util.Iterator; +import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -29,23 +29,22 @@ import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.dependency.utils.DependencyStatusSets; import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; /** * Goal that copies the project dependencies from the repository to a defined * location. - * + * * @goal copy-dependencies * @requiresDependencyResolution test * @phase process-sources * @author Brian Fox - * @version $Id: CopyDependenciesMojo.java 731252 2009-01-04 13:11:57Z bentmann $ + * @version $Id: CopyDependenciesMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ * @since 1.0 */ public class CopyDependenciesMojo @@ -63,12 +62,17 @@ protected ArtifactRepositoryFactory repositoryFactory; /** + * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" + */ + private Map repositoryLayouts; + + /** * Main entry into mojo. Gets the list of dependencies and iterates through * calling copyArtifact. - * + * * @throws MojoExecutionException * with a message if an error occurs. - * + * * @see #getDependencies * @see #copyArtifact(Artifact, boolean) */ @@ -76,148 +80,167 @@ throws MojoExecutionException { DependencyStatusSets dss = getDependencySets( this.failOnMissingClassifierArtifact ); - Set artifacts = dss.getResolvedDependencies(); + Set artifacts = dss.getResolvedDependencies(); - if ( !useRepositoryLayout ) - { - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - copyArtifact( (Artifact) i.next(), this.stripVersion ); - } - } - else - { - try { - ArtifactRepository targetRepository = repositoryFactory.createDeploymentArtifactRepository( - "local", - outputDirectory.toURL().toExternalForm(), - new DefaultRepositoryLayout(), - false /*uniqueVersion*/ ); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - installArtifact( (Artifact) i.next(), targetRepository ); - } - } - catch ( MalformedURLException e ) - { - throw new MojoExecutionException("Could not create outputDirectory repository", e); - } + if ( !useRepositoryLayout ) + { + for ( Artifact artifact : artifacts ) + { + copyArtifact( artifact, this.stripVersion, this.prependGroupId ); + } + } + else + { + try + { + ArtifactRepository targetRepository = repositoryFactory.createDeploymentArtifactRepository( + "local", + outputDirectory.toURL().toExternalForm(), + (ArtifactRepositoryLayout) repositoryLayouts.get( "default" ), + false /*uniqueVersion*/ ); + for ( Artifact artifact : artifacts ) + { + installArtifact( artifact, targetRepository ); + } + } + catch ( MalformedURLException e ) + { + throw new MojoExecutionException( "Could not create outputDirectory repository", e ); + } } - artifacts = dss.getSkippedDependencies(); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + Set skippedArtifacts = dss.getSkippedDependencies(); + for ( Artifact artifact : skippedArtifacts ) { - Artifact artifact = (Artifact) i.next(); getLog().info( artifact.getFile().getName() + " already exists in destination." ); } + + if ( isCopyPom() ) + { + copyPoms( getOutputDirectory(), artifacts, this.stripVersion ); + copyPoms( getOutputDirectory(), skippedArtifacts, this.stripVersion ); // Artifacts that already exist may not already have poms. + } } - private void installArtifact( Artifact artifact, ArtifactRepository targetRepository) + private void installArtifact( Artifact artifact, ArtifactRepository targetRepository ) { - try - { - if ( "pom".equals( artifact.getType() ) ) - { - installer.install( artifact.getFile(), artifact, targetRepository ); - installBaseSnapshot( artifact, targetRepository ); - } - else - { - installer.install( artifact.getFile(), artifact, targetRepository ); - installBaseSnapshot( artifact, targetRepository ); - - if ( isCopyPom() ) - { - Artifact pomArtifact = getResolvedPomArtifact( artifact ); - if ( pomArtifact.getFile() != null && pomArtifact.getFile().exists() ) - { - installer.install( pomArtifact.getFile(), pomArtifact, targetRepository ); - installBaseSnapshot( pomArtifact, targetRepository ); - } - } - } - } - catch ( ArtifactInstallationException e ) - { - getLog().info( e.getMessage() ); - } - } - - private void installBaseSnapshot( Artifact artifact, ArtifactRepository targetRepository ) - throws ArtifactInstallationException - { - if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) ) - { - Artifact baseArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getBaseVersion(), artifact.getScope(), artifact.getType() ); - installer.install( artifact.getFile(), baseArtifact, targetRepository ); - } - } + try + { + if ( "pom".equals( artifact.getType() ) ) + { + installer.install( artifact.getFile(), artifact, targetRepository ); + installBaseSnapshot( artifact, targetRepository ); + } + else + { + installer.install( artifact.getFile(), artifact, targetRepository ); + installBaseSnapshot( artifact, targetRepository ); - /** + if ( isCopyPom() ) + { + Artifact pomArtifact = getResolvedPomArtifact( artifact ); + if ( pomArtifact.getFile() != null && pomArtifact.getFile().exists() ) + { + installer.install( pomArtifact.getFile(), pomArtifact, targetRepository ); + installBaseSnapshot( pomArtifact, targetRepository ); + } + } + } + } + catch ( ArtifactInstallationException e ) + { + getLog().info( e.getMessage() ); + } + } + + private void installBaseSnapshot( Artifact artifact, ArtifactRepository targetRepository ) + throws ArtifactInstallationException + { + if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) ) + { + Artifact baseArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), + artifact.getBaseVersion(), artifact.getScope(), artifact.getType() ); + installer.install( artifact.getFile(), baseArtifact, targetRepository ); + } + } + + /** * Copies the Artifact after building the destination file name if * overridden. This method also checks if the classifier is set and adds it * to the destination file name if needed. - * + * * @param artifact * representing the object to be copied. * @param removeVersion * specifies if the version should be removed from the file name * when copying. - * + * @param prependGroupId + * specifies if the groupId should be prepend to the file while copying. * @throws MojoExecutionException * with a message if an error occurs. - * + * * @see DependencyUtil#copyFile(File, File, Log) * @see DependencyUtil#getFormattedFileName(Artifact, boolean) */ - protected void copyArtifact( Artifact artifact, boolean removeVersion ) + protected void copyArtifact( Artifact artifact, boolean removeVersion, boolean prependGroupId ) throws MojoExecutionException { - String destFileName = DependencyUtil.getFormattedFileName( artifact, removeVersion ); + String destFileName = DependencyUtil.getFormattedFileName( artifact, removeVersion, prependGroupId); File destDir; - destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerType, useSubDirectoryPerArtifact, + destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact, useRepositoryLayout, stripVersion, outputDirectory, artifact ); File destFile = new File( destDir, destFileName ); copyFile( artifact.getFile(), destFile ); - // Copy POM if asked - if ( isCopyPom() ) + } + + /** + * Copy the pom files associated with the artifacts. + */ + public void copyPoms( File destDir, Set artifacts, boolean removeVersion ) + throws MojoExecutionException + + { + for ( Artifact artifact : artifacts ) { - // Create the pom Artifact pomArtifact = getResolvedPomArtifact( artifact ); - + // Copy the pom if ( pomArtifact.getFile() != null && pomArtifact.getFile().exists() ) { - File pomDestFile = new File( destDir, DependencyUtil.getFormattedFileName( pomArtifact, removeVersion ) ); - copyFile( pomArtifact.getFile(), pomDestFile ); + File pomDestFile = new File( destDir, DependencyUtil.getFormattedFileName( pomArtifact, removeVersion, + prependGroupId) ); + if ( ! pomDestFile.exists() ) + { + copyFile( pomArtifact.getFile(), pomDestFile ); + } } } } - protected Artifact getResolvedPomArtifact( Artifact artifact ) { - Artifact pomArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), "", "pom" ); - // Resolve the pom artifact using repos - try - { - this.resolver.resolve( pomArtifact, this.remoteRepos, this.local ); - } - catch ( Exception e ) - { - getLog().info( e.getMessage() ); - } - return pomArtifact; - } + protected Artifact getResolvedPomArtifact( Artifact artifact ) + { + Artifact pomArtifact = this.factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), + artifact.getVersion(), "", "pom" ); + // Resolve the pom artifact using repos + try + { + this.resolver.resolve( pomArtifact, this.remoteRepos, this.getLocal() ); + } + catch ( Exception e ) + { + getLog().info( e.getMessage() ); + } + return pomArtifact; + } protected ArtifactsFilter getMarkedArtifactFilter() { return new DestFileFilter( this.overWriteReleases, this.overWriteSnapshots, this.overWriteIfNewer, - this.useSubDirectoryPerArtifact, this.useSubDirectoryPerType, + this.useSubDirectoryPerArtifact, this.useSubDirectoryPerType, this.useSubDirectoryPerScope, this.useRepositoryLayout, this.stripVersion, this.outputDirectory ); } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java 2011-11-11 00:42:16.000000000 +0000 @@ -1,26 +1,35 @@ package org.apache.maven.plugin.dependency; /* - * Copyright 2001-2005 The Apache Software Foundation. + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -28,7 +37,6 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.AbstractMojo; @@ -37,67 +45,82 @@ import org.codehaus.plexus.util.StringUtils; /** - * Downloads a single artifact transitively from a specified remote repository. - * + * Downloads a single artifact transitively from the specified remote repositories. Caveat: will always check the + * central repository defined in the super pom. You could use a mirror entry in your settings.xml + * * @goal get * @requiresProject false - * */ public class GetMojo extends AbstractMojo { - + private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" ); + /** * @component * @readonly */ private ArtifactFactory artifactFactory; - + /** * @component * @readonly */ private ArtifactResolver artifactResolver; - + /** * @component * @readonly */ private ArtifactRepositoryFactory artifactRepositoryFactory; - + + /** + * Map that contains the layouts. + * + * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" + */ + private Map repositoryLayouts; + /** * @component * @readonly */ private ArtifactMetadataSource source; - + /** - * + * * @parameter expression="${localRepository}" * @readonly */ private ArtifactRepository localRepository; /** - * The groupId of the artifact to download + * The groupId of the artifact to download. Ignored if {@link #artifact} is used. * @parameter expression="${groupId}" */ private String groupId; /** - * The artifactId of the artifact to download + * The artifactId of the artifact to download. Ignored if {@link #artifact} is used. * @parameter expression="${artifactId}" */ private String artifactId; /** - * The version of the artifact to download + * The version of the artifact to download. Ignored if {@link #artifact} is used. * @parameter expression="${version}" */ private String version; /** - * The packaging of the artifact to download + * The classifier of the artifact to download. Ignored if {@link #artifact} is used. + * @parameter expression="${classifier}" + * @since 2.3 + */ + private String classifier; + + /** + * The packaging of the artifact to download. Ignored if {@link #artifact} is used. * @parameter expression="${packaging}" default-value="jar" */ private String packaging = "jar"; @@ -105,85 +128,124 @@ /** * The id of the repository from which we'll download the artifact * @parameter expression="${repoId}" default-value="temp" + * @deprecated Use remoteRepositories */ private String repositoryId = "temp"; /** - * The url of the repository from which we'll download the artifact + * The url of the repository from which we'll download the artifact. DEPRECATED Use remoteRepositories + * + * @deprecated Use remoteRepositories * @parameter expression="${repoUrl}" - * @required */ private String repositoryUrl; /** + * Repositories in the format id::[layout]::url or just url, separated by comma. + * ie. central::default::http://repo1.maven.apache.org/maven2,myrepo::::http://repo.acme.com,http://repo.acme2.com + * * @parameter expression="${remoteRepositories}" - * @readonly */ private String remoteRepositories; - + /** - * A string of the form groupId:artifactId:version[:packaging]. + * A string of the form groupId:artifactId:version[:packaging][:classifier]. + * * @parameter expression="${artifact}" */ private String artifact; - + /** - * + * The destination file to copy the artifact to, if other than the local repository + * @parameter expression="${dest}" + * @since 2.4 + */ + private String destination; + + /** + * * @parameter expression="${project.remoteArtifactRepositories}" * @required * @readonly */ private List pomRemoteRepositories; - + /** * Download transitively, retrieving the specified artifact and all of its dependencies. - * @parameter expression="{$transitive}" default-value=true + * @parameter expression="${transitive}" default-value=true */ private boolean transitive = true; - + public void execute() throws MojoExecutionException, MojoFailureException - { + { if ( artifactId == null && artifact == null ) + { throw new MojoFailureException( "You must specify an artifact, " + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0" ); - if ( artifactId == null ) + } + if ( artifact != null ) { String[] tokens = StringUtils.split( artifact, ":" ); - if ( tokens.length != 3 && tokens.length != 4 ) - throw new MojoFailureException( "Invalid artifact, you must specify " - + "groupId:artifactId:version[:packaging] " + artifact ); + if ( tokens.length < 3 || tokens.length > 5 ) + { + throw new MojoFailureException( + "Invalid artifact, you must specify groupId:artifactId:version[:packaging][:classifier] " + + artifact ); + } groupId = tokens[0]; artifactId = tokens[1]; version = tokens[2]; - if ( tokens.length == 4 ) + if ( tokens.length >= 4 ) + { packaging = tokens[3]; + } + if ( tokens.length == 5 ) + { + classifier = tokens[4]; + } + else + { + classifier = null; + } } - Artifact toDownload = artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging ); + + Artifact toDownload = classifier == null + ? artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging ) + : artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier ); Artifact dummyOriginatingArtifact = artifactFactory.createBuildArtifact( "org.apache.maven.plugins", "maven-downloader-plugin", "1.0", "jar" ); - ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout(); ArtifactRepositoryPolicy always = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); - ArtifactRepository remoteRepo = - artifactRepositoryFactory.createArtifactRepository( repositoryId, repositoryUrl, repositoryLayout, always, - always ); - if ( pomRemoteRepositories == null ) - pomRemoteRepositories = new ArrayList(); + List repoList = new ArrayList(); - List repoList = new ArrayList( pomRemoteRepositories ); - if ( remoteRepositories != null ) + if ( pomRemoteRepositories != null ) { + repoList.addAll( pomRemoteRepositories ); + } - repoList.addAll( Arrays.asList( StringUtils.split( remoteRepositories, "," ) ) ); - + if ( remoteRepositories != null ) + { + // Use the same format as in the deploy plugin id::layout::url + List repos = Arrays.asList( StringUtils.split( remoteRepositories, "," ) ); + for ( String repo : repos ) + { + repoList.add( parseRepository( repo, always ) ); + } } - repoList.add( remoteRepo ); + if ( repositoryUrl != null ) + { + getLog().warn( "repositoryUrl parameter is deprecated. Use remoteRepositories instead" ); + ArtifactRepository remoteRepo = + artifactRepositoryFactory.createArtifactRepository( repositoryId, repositoryUrl, + getLayout( "default" ), always, always ); + repoList.add( remoteRepo ); + } try { @@ -194,13 +256,72 @@ } else { - artifactResolver.resolve ( toDownload, repoList, localRepository ); + artifactResolver.resolve( toDownload, repoList, localRepository ); } - } catch ( AbstractArtifactResolutionException e ) { throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e ); } + + if ( destination != null ) + { + File src = toDownload.getFile(); + File dest = new File( destination ); + if ( getLog().isInfoEnabled() ) + { + getLog().info( "Copying " + src.getAbsolutePath() + " to " + dest.getAbsolutePath() ); + } + try + { + FileUtils.copyFile( toDownload.getFile(), new File( destination ) ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Couldn't copy downloaded artifact from " + src.getAbsolutePath() + + " to " + dest.getAbsolutePath() + " : " + e.getMessage(), e ); + } + } + } + + ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy ) + throws MojoFailureException + { + // if it's a simple url + String id = repositoryId; + ArtifactRepositoryLayout layout = getLayout( "default" ); + String url = repo; + + // if it's an extended repo URL of the form id::layout::url + if ( repo.indexOf( "::" ) >= 0 ) + { + Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo ); + if ( !matcher.matches() ) + { + throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo, + "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." ); + } + + id = matcher.group( 1 ).trim(); + if ( !StringUtils.isEmpty( matcher.group( 2 ) ) ) + { + layout = getLayout( matcher.group( 2 ).trim() ); + } + url = matcher.group( 3 ).trim(); + } + return artifactRepositoryFactory.createArtifactRepository( id, url, layout, policy, policy ); + } + + private ArtifactRepositoryLayout getLayout( String id ) + throws MojoFailureException + { + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( id ); + + if ( layout == null ) + { + throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id ); + } + + return layout; } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/ListMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -25,12 +25,13 @@ * Displays the list of dependencies for this project. * * @author Mark Hobson - * @version $Id: ListMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ListMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0-alpha-5 * @goal list * @requiresDependencyResolution test */ -public class ListMojo extends ResolveDependenciesMojo +public class ListMojo + extends ResolveDependenciesMojo { // alias for dependency:resolve } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/PropertiesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -0,0 +1,75 @@ +package org.apache.maven.plugin.dependency; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; + +/** + * Goal that sets a property pointing to the artifact file for each project dependency. + * For each dependency (direct and transitive) a project property will be set which follows the + * form groupId:artifactId:type:[classifier] and contains the path to the resolved artifact. + * + * @goal properties + * @requiresDependencyResolution test + * @phase initialize + * @author Paul Gier + * @version $Id: PropertiesMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ + * @since 2.2 + */ +public class PropertiesMojo + extends AbstractMojo +{ + + /** + * The current Maven project + * + * @parameter expression="${project}" + * @readonly + */ + protected MavenProject project; + + /** + * Main entry into mojo. Gets the list of dependencies and iterates through setting a property for each artifact. + * + * @throws MojoExecutionException with a message if an error occurs. + */ + public void execute() + throws MojoExecutionException + { + Set artifacts = getProject().getArtifacts(); + + for ( Artifact artifact : artifacts ) + { + project.getProperties().setProperty( artifact.getDependencyConflictId(), + artifact.getFile().getAbsolutePath() ); + } + } + + public MavenProject getProject() + { + return project; + } + +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/PurgeLocalRepositoryMojo.java 2011-10-28 13:01:39.000000000 +0000 @@ -19,18 +19,6 @@ * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -40,6 +28,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; @@ -48,16 +37,27 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * Remove the project dependencies from the local repository, and optionally * re-resolve them. - * + * * @author jdcasey - * @since 2.0 + * @version $Id: PurgeLocalRepositoryMojo.java 1190290 2011-10-28 13:01:39Z olamy $ * @goal purge-local-repository * @aggregator - * @version $Id: PurgeLocalRepositoryMojo.java 728546 2008-12-21 22:56:51Z bentmann $ - * + * @since 2.0 */ public class PurgeLocalRepositoryMojo extends AbstractMojo @@ -74,27 +74,27 @@ /** * The projects in the current build. Each of these is subject to * refreshing. - * + * * @parameter default-value="${reactorProjects}" * @required * @readonly */ - private List projects; + private List projects; /** * The list of dependencies in the form of groupId:artifactId which should * NOT be deleted/refreshed. This is useful for third-party artifacts. - * + * * @parameter */ - private List excludes; + private List excludes; /** * Comma-separated list of groupId:artifactId entries, which should be used * to exclude artifacts from deletion/refresh. This is a command-line * alternative to the excludes parameter, since List * parameters are not currently compatible with CLI specification. - * + * * @parameter expression="${exclude}" */ private String exclude; @@ -103,14 +103,14 @@ * Whether to re-resolve the artifacts once they have been deleted from the * local repository. If you are running this mojo from the command-line, you * may want to disable this. By default, artifacts will be re-resolved. - * + * * @parameter expression="${reResolve}" default-value="true" */ private boolean reResolve; /** * The local repository, from which to delete artifacts. - * + * * @parameter default-value="${localRepository}" * @required * @readonly @@ -120,14 +120,14 @@ /** * The artifact resolver used to re-resolve dependencies, if that option is * enabled. - * + * * @component */ private ArtifactResolver resolver; /** * The artifact metadata source used to resolve dependencies - * + * * @component */ private ArtifactMetadataSource source; @@ -144,7 +144,7 @@ *
  • groupId - Eliminate all files associated with the artifact's * groupId.
  • * - * + * * @parameter expression="${resolutionFuzziness}" default-value="file" */ private String resolutionFuzziness; @@ -152,45 +152,50 @@ /** * Whether this mojo should act on all transitive dependencies. Default * value is true. - * + * * @parameter expression="${actTransitively}" default-value="true" */ private boolean actTransitively; /** * Used to construct artifacts for deletion/resolution... - * + * * @component */ private ArtifactFactory factory; /** * Whether this plugin should output verbose messages. Default is false. - * + * * @parameter expression="${verbose}" default-value="false" */ private boolean verbose; + /** + * Whether to purge only snapshot artifacts. + * + * @parameter expression="${snapshotsOnly}" default-value="false" + * @since 2.4 + */ + private boolean snapshotsOnly; + + public void execute() throws MojoExecutionException, MojoFailureException { - List exclusionPatterns = buildExclusionPatternsList(); + List exclusionPatterns = buildExclusionPatternsList(); - for ( Iterator it = projects.iterator(); it.hasNext(); ) + for ( MavenProject project : projects ) { - MavenProject project = (MavenProject) it.next(); - try { refreshDependenciesForProject( project, exclusionPatterns ); } catch ( ArtifactResolutionException e ) { - MojoFailureException failure = new MojoFailureException( this, - "Failed to refresh project dependencies for: " - + project.getId(), - "Artifact resolution failed for project: " - + project.getId() ); + MojoFailureException failure = + new MojoFailureException( this, "Failed to refresh project dependencies for: " + project.getId(), + "Artifact resolution failed for project: " + project.getId() ); failure.initCause( e ); throw failure; @@ -198,9 +203,9 @@ } } - private List buildExclusionPatternsList() + private List buildExclusionPatternsList() { - List patterns = new ArrayList(); + List patterns = new ArrayList(); if ( exclude != null ) { @@ -216,25 +221,28 @@ return patterns; } - private Map createArtifactMap( MavenProject project ) + private Map createArtifactMap( MavenProject project ) { - Map artifactMap = Collections.EMPTY_MAP; + Map artifactMap = Collections.emptyMap(); - List dependencies = project.getDependencies(); + List dependencies = project.getDependencies(); - List remoteRepositories = Collections.EMPTY_LIST; + List remoteRepositories = Collections.emptyList(); - Set dependencyArtifacts = new HashSet(); + Set dependencyArtifacts = new HashSet(); - for ( Iterator it = dependencies.iterator(); it.hasNext(); ) + for ( Dependency dependency : dependencies ) { - Dependency dependency = (Dependency) it.next(); - VersionRange vr = VersionRange.createFromVersion( dependency.getVersion() ); - Artifact artifact = factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), - vr, dependency.getType(), dependency.getClassifier(), - dependency.getScope() ); + Artifact artifact = + factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), vr, + dependency.getType(), dependency.getClassifier(), + dependency.getScope() ); + if ( snapshotsOnly && !artifact.isSnapshot() ) + { + continue; + } dependencyArtifacts.add( artifact ); } @@ -242,8 +250,25 @@ { try { - ArtifactResolutionResult result = resolver.resolveTransitively( dependencyArtifacts, project - .getArtifact(), remoteRepositories, localRepository, source ); + ArtifactResolutionResult result; + + if ( snapshotsOnly ) + { + result = resolver.resolveTransitively( dependencyArtifacts, project.getArtifact(), localRepository, + remoteRepositories, source, new ArtifactFilter() + { + public boolean include( Artifact artifact ) + { + return artifact.isSnapshot(); + } + } ); + } + else + { + result = + resolver.resolveTransitively( dependencyArtifacts, project.getArtifact(), remoteRepositories, + localRepository, source ); + } artifactMap = ArtifactUtils.artifactMapByVersionlessId( result.getArtifacts() ); } @@ -258,11 +283,9 @@ } else { - artifactMap = new HashMap(); - for ( Iterator it = dependencyArtifacts.iterator(); it.hasNext(); ) + artifactMap = new HashMap(); + for ( Artifact artifact : dependencyArtifacts ) { - Artifact artifact = (Artifact) it.next(); - try { resolver.resolve( artifact, remoteRepositories, localRepository ); @@ -291,10 +314,10 @@ } } - private void refreshDependenciesForProject( MavenProject project, List exclusionPatterns ) + private void refreshDependenciesForProject( MavenProject project, List exclusionPatterns ) throws ArtifactResolutionException, MojoFailureException { - Map deps = createArtifactMap( project ); + Map deps = createArtifactMap( project ); if ( deps.isEmpty() ) { @@ -304,24 +327,41 @@ if ( !exclusionPatterns.isEmpty() ) { - for ( Iterator it = exclusionPatterns.iterator(); it.hasNext(); ) + for ( String excludedKey : exclusionPatterns ) { - String excludedKey = (String) it.next(); + if ( GROUP_ID_FUZZINESS.equals( resolutionFuzziness ) ) + { + verbose( "Excluding groupId: " + excludedKey + " from refresh operation for project: " + + project.getId() ); - verbose( "Excluding: " + excludedKey + " from refresh operation for project: " + project.getId() ); + for ( Iterator> deps_it = deps.entrySet().iterator(); + deps_it.hasNext(); ) + { + Map.Entry dependency = deps_it.next(); + + Artifact artifact = dependency.getValue(); + + if ( artifact.getGroupId().equals( excludedKey ) ) + { + deps_it.remove(); + } + } + } + else + { + verbose( "Excluding: " + excludedKey + " from refresh operation for project: " + project.getId() ); - deps.remove( excludedKey ); + deps.remove( excludedKey ); + } } } verbose( "Processing dependencies for project: " + project.getId() ); - List missingArtifacts = new ArrayList(); - for ( Iterator it = deps.entrySet().iterator(); it.hasNext(); ) + List missingArtifacts = new ArrayList(); + for ( Map.Entry entry : deps.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - - Artifact artifact = (Artifact) entry.getValue(); + Artifact artifact = entry.getValue(); verbose( "Processing artifact: " + artifact.getId() ); @@ -372,15 +412,14 @@ if ( missingArtifacts.size() > 0 ) { String message = "required artifacts missing:\n"; - for ( Iterator i = missingArtifacts.iterator(); i.hasNext(); ) + for ( Artifact missingArtifact : missingArtifacts ) { - Artifact missingArtifact = (Artifact) i.next(); message += " " + missingArtifact.getId() + "\n"; } message += "\nfor the artifact:"; - throw new ArtifactResolutionException( message, project.getArtifact(), project - .getRemoteArtifactRepositories() ); + throw new ArtifactResolutionException( message, project.getArtifact(), + project.getRemoteArtifactRepositories() ); } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/TreeMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -16,15 +16,15 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; import java.io.IOException; import java.io.StringWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -42,6 +42,9 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.dependency.utils.DependencyUtil; +import org.apache.maven.plugin.dependency.treeSerializers.GraphmlDependencyNodeVisitor; +import org.apache.maven.plugin.dependency.treeSerializers.TGFDependencyNodeVisitor; +import org.apache.maven.plugin.dependency.treeSerializers.DOTDependencyNodeVisitor; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter; @@ -62,9 +65,9 @@ /** * Displays the dependency tree for this project. - * + * * @author Mark Hobson - * @version $Id: TreeMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: TreeMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0-alpha-5 * @goal tree * @requiresDependencyResolution test @@ -75,7 +78,7 @@ /** * The Maven project. - * + * * @parameter expression="${project}" * @required * @readonly @@ -84,7 +87,7 @@ /** * The artifact repository to use. - * + * * @parameter expression="${localRepository}" * @required * @readonly @@ -93,7 +96,7 @@ /** * The artifact factory to use. - * + * * @component * @required * @readonly @@ -102,7 +105,7 @@ /** * The artifact metadata source to use. - * + * * @component * @required * @readonly @@ -111,7 +114,7 @@ /** * The artifact collector to use. - * + * * @component * @required * @readonly @@ -120,7 +123,7 @@ /** * The dependency tree builder to use. - * + * * @component * @required * @readonly @@ -142,23 +145,35 @@ * @since 2.0-alpha-5 */ private File outputFile; - + + /** + * If specified, this parameter will cause the dependency tree to be written using the specified format. Currently + * supported format are text, dot, graphml and tgf. + * + * These formats can be plotted to image files. An example of how to plot a dot file using + * pygraphviz can be found here + * + * @parameter expression="${outputType}" default-value="text" + * @since 2.1 + */ + private String outputType; + /** * The scope to filter by when resolving the dependency tree, or null to include dependencies from * all scopes. Note that this feature does not currently work due to MNG-3236. - * + * * @since 2.0-alpha-5 * @see MNG-3236 - * + * * @parameter expression="${scope}" */ private String scope; /** * Whether to include omitted nodes in the serialized dependency tree. - * + * * @since 2.0-alpha-6 - * + * * @parameter expression="${verbose}" default-value="false" */ private boolean verbose; @@ -167,9 +182,9 @@ * The token set name to use when outputting the dependency tree. Possible values are whitespace, * standard or extended, which use whitespace, standard or extended ASCII sets * respectively. - * + * * @since 2.0-alpha-6 - * + * * @parameter expression="${tokens}" default-value="standard" */ private String tokens; @@ -177,10 +192,10 @@ /** * A comma-separated list of artifacts to filter the serialized dependency tree by, or null not to * filter the dependency tree. The artifact syntax is defined by StrictPatternIncludesArtifactFilter. - * + * * @see StrictPatternIncludesArtifactFilter * @since 2.0-alpha-6 - * + * * @parameter expression="${includes}" */ private String includes; @@ -189,10 +204,10 @@ * A comma-separated list of artifacts to filter from the serialized dependency tree, or null not to * filter any artifacts from the dependency tree. The artifact syntax is defined by * StrictPatternExcludesArtifactFilter. - * + * * @see StrictPatternExcludesArtifactFilter * @since 2.0-alpha-6 - * + * * @parameter expression="${excludes}" */ private String excludes; @@ -203,20 +218,29 @@ * @component role="org.apache.maven.execution.RuntimeInformation" */ private RuntimeInformation rti; - + /** * The computed dependency tree root node of the Maven project. */ private DependencyNode rootNode; - + + /** + * Whether to append outputs into the output file or overwrite it. + * + * @parameter expression="${appendOutput}" default-value="false" + * @since 2.2 + */ + private boolean appendOutput; + // Mojo methods ----------------------------------------------------------- /* * @see org.apache.maven.plugin.Mojo#execute() */ - public void execute() throws MojoExecutionException, MojoFailureException + public void execute() + throws MojoExecutionException, MojoFailureException { - + ArtifactVersion detectedMavenVersion = rti.getApplicationVersion(); VersionRange vr; try @@ -225,21 +249,21 @@ if ( !containsVersion( vr, detectedMavenVersion ) ) { getLog().warn( - "The tree mojo requires at least Maven 2.0.8 to function properly. You may get eroneous results on earlier versions" ); + "The tree mojo requires at least Maven 2.0.8 to function properly. You may get erroneous results on earlier versions" ); } } catch ( InvalidVersionSpecificationException e ) { - throw new MojoExecutionException(e.getLocalizedMessage()); + throw new MojoExecutionException( e.getLocalizedMessage(), e ); } - - if (output != null) + + if ( output != null ) { getLog().warn( "The parameter output is deprecated. Use outputFile instead." ); this.outputFile = output; } - + ArtifactFilter artifactFilter = createResolvingArtifactFilter(); try @@ -250,11 +274,11 @@ dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory, artifactMetadataSource, artifactFilter, artifactCollector ); - String dependencyTreeString = serialiseDependencyTree( rootNode ); + String dependencyTreeString = serializeDependencyTree( rootNode ); if ( outputFile != null ) { - DependencyUtil.write( dependencyTreeString, outputFile, getLog() ); + DependencyUtil.write( dependencyTreeString, outputFile, this.appendOutput ,getLog() ); getLog().info( "Wrote dependency tree to: " + outputFile ); } @@ -277,7 +301,7 @@ /** * Gets the Maven project used by this mojo. - * + * * @return the Maven project */ public MavenProject getProject() @@ -287,7 +311,7 @@ /** * Gets the computed dependency tree root node for the Maven project. - * + * * @return the dependency tree root node */ public DependencyNode getDependencyTree() @@ -299,7 +323,7 @@ /** * Gets the artifact filter to use when resolving the dependency tree. - * + * * @return the artifact filter */ private ArtifactFilter createResolvingArtifactFilter() @@ -322,18 +346,17 @@ } /** - * Serialises the specified dependency tree to a string. - * + * Serializes the specified dependency tree to a string. + * * @param rootNode - * the dependency tree root node to serialise - * @return the serialised dependency tree + * the dependency tree root node to serialize + * @return the serialized dependency tree */ - private String serialiseDependencyTree( DependencyNode rootNode ) + private String serializeDependencyTree( DependencyNode rootNode ) { StringWriter writer = new StringWriter(); - TreeTokens treeTokens = toTreeTokens( tokens ); - DependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor( writer, treeTokens ); + DependencyNodeVisitor visitor = getSerializingDependencyNodeVisitor( writer ); // TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only visitor = new BuildingDependencyNodeVisitor( visitor ); @@ -355,9 +378,29 @@ return writer.toString(); } + public DependencyNodeVisitor getSerializingDependencyNodeVisitor( Writer writer ) + { + if ( "graphml".equals( outputType ) ) + { + return new GraphmlDependencyNodeVisitor( writer ); + } + else if ( "tgf".equals( outputType ) ) + { + return new TGFDependencyNodeVisitor( writer ); + } + else if ( "dot".equals( outputType ) ) + { + return new DOTDependencyNodeVisitor( writer ) ; + } + else + { + return new SerializingDependencyNodeVisitor( writer, toTreeTokens( tokens ) ); + } + } + /** * Gets the tree tokens instance for the specified name. - * + * * @param tokens * the tree tokens name * @return the TreeTokens instance @@ -388,12 +431,12 @@ /** * Gets the dependency node filter to use when serializing the dependency tree. - * + * * @return the dependency node filter, or null if none required */ private DependencyNodeFilter createDependencyNodeFilter() { - List filters = new ArrayList(); + List filters = new ArrayList(); // filter node states if ( !verbose ) @@ -406,7 +449,7 @@ // filter includes if ( includes != null ) { - List patterns = Arrays.asList( includes.split( "," ) ); + List patterns = Arrays.asList( includes.split( "," ) ); getLog().debug( "+ Filtering dependency tree by artifact include patterns: " + patterns ); @@ -417,7 +460,7 @@ // filter excludes if ( excludes != null ) { - List patterns = Arrays.asList( excludes.split( "," ) ); + List patterns = Arrays.asList( excludes.split( "," ) ); getLog().debug( "+ Filtering dependency tree by artifact exclude patterns: " + patterns ); @@ -428,43 +471,37 @@ return filters.isEmpty() ? null : new AndDependencyNodeFilter( filters ); } - //following is required because the version handling in maven code + //following is required because the version handling in maven code //doesn't work properly. I ripped it out of the enforcer rules. - + /** * Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently the default * containsVersion method assumes a singular version means allow everything. This method assumes that "2.0.4" == * "[2.0.4,)" - * + * * @param allowedRange range of allowed versions. * @param theVersion the version to be checked. * @return true if the version is contained by the range. */ public static boolean containsVersion( VersionRange allowedRange, ArtifactVersion theVersion ) { - boolean matched = false; ArtifactVersion recommendedVersion = allowedRange.getRecommendedVersion(); if ( recommendedVersion == null ) { - - for ( Iterator i = allowedRange.getRestrictions().iterator(); i.hasNext() && !matched; ) + List restrictions = allowedRange.getRestrictions(); + for ( Restriction restriction : restrictions ) { - Restriction restriction = (Restriction) i.next(); if ( restriction.containsVersion( theVersion ) ) { - matched = true; + return true; } } } - else - { - // only singular versions ever have a recommendedVersion - int compareTo = recommendedVersion.compareTo( theVersion ); - matched = ( compareTo <= 0 ); - } - return matched; + + // only singular versions ever have a recommendedVersion + return recommendedVersion.compareTo( theVersion ) <= 0; } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/UnpackDependenciesMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -16,12 +16,10 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; -import java.util.Iterator; -import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; @@ -29,27 +27,27 @@ import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import org.codehaus.plexus.archiver.manager.ArchiverManager; /** * Goal that unpacks the project dependencies from the repository to a defined * location. - * + * * @goal unpack-dependencies * @requiresDependencyResolution test * @phase process-sources * @author Brian Fox - * @version $Id: UnpackDependenciesMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: UnpackDependenciesMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 1.0 */ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo { - /** + /** * A comma separated list of file patterns to include when unpacking the - * artifact. i.e. **\/*.xml,**\/*.properties NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name );) + * artifact. i.e. **\/*.xml,**\/*.properties + * NOTE: Excludes patterns override the includes. + * (component code = return isIncluded( name ) AND !isExcluded( name );) * @since 2.0 * @parameter expression="${mdep.unpack.includes}" */ @@ -57,19 +55,21 @@ /** * A comma separated list of file patterns to exclude when unpacking the - * artifact. i.e. **\/*.xml,**\/*.properties. NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name );) + * artifact. i.e. **\/*.xml,**\/*.properties + * NOTE: Excludes patterns override the includes. + * (component code = return isIncluded( name ) AND !isExcluded( name );) * @since 2.0 * @parameter expression="${mdep.unpack.excludes}" */ private String excludes; - + /** * Main entry into mojo. This method gets the dependencies and iterates * through each one passing it to DependencyUtil.unpackFile(). - * + * * @throws MojoExecutionException * with a message if an error occurs. - * + * * @see #getDependencies * @see DependencyUtil#unpackFile(Artifact, File, File, ArchiverManager, * Log) @@ -78,24 +78,20 @@ throws MojoExecutionException { DependencyStatusSets dss = getDependencySets( this.failOnMissingClassifierArtifact ); - Set artifacts = dss.getResolvedDependencies(); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : dss.getResolvedDependencies() ) { - Artifact artifact = (Artifact) i.next(); File destDir; - destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerType, useSubDirectoryPerArtifact, + destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact, useRepositoryLayout, stripVersion, outputDirectory, artifact ); unpack( artifact.getFile(), destDir, getIncludes(), getExcludes() ); DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory ); handler.setMarker(); } - - artifacts = dss.getSkippedDependencies(); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + + for ( Artifact artifact : dss.getSkippedDependencies() ) { - Artifact artifact = (Artifact) i.next(); getLog().info( artifact.getFile().getName() + " already exists in destination." ); } } @@ -105,39 +101,39 @@ return new MarkerFileFilter( this.overWriteReleases, this.overWriteSnapshots, this.overWriteIfNewer, new DefaultFileMarkerHandler( this.markersDirectory ) ); } - + /** * @return Returns a comma separated list of excluded items */ - public String getExcludes () + public String getExcludes() { - return this.excludes; + return DependencyUtil.cleanToBeTokenizedString( this.excludes ); } - + /** - * @param excludes - * A comma separated list of items to exclude - * i.e. **\/*.xml, **\/*.properties + * @param excludes + * A comma separated list of items to exclude + * i.e. **\/*.xml, **\/*.properties */ - public void setExcludes ( String excludes ) + public void setExcludes( String excludes ) { this.excludes = excludes; } - + /** - * @return Returns a comma seperated list of included items + * @return Returns a comma separated list of included items */ public String getIncludes() { - return this.includes; + return DependencyUtil.cleanToBeTokenizedString( this.includes ); } /** * @param includes - * A comma seperated list of items to inmclude - * i.e. **\/*.xml, **\/*.properties + * A comma separated list of items to include + * i.e. **\/*.xml, **\/*.properties */ - public void setIncludes ( String includes ) + public void setIncludes( String includes ) { this.includes = includes; } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java 2011-07-05 12:54:20.000000000 +0000 @@ -1,6 +1,6 @@ package org.apache.maven.plugin.dependency.fromConfiguration; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,15 +16,18 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; +import java.util.Collections; import java.util.List; +import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -34,27 +37,35 @@ import org.apache.maven.plugin.dependency.AbstractDependencyMojo; import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter; +import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; +import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; /** - * Abstract Parent class used by mojos that get Artifact information from the - * plugin configuration as an ArrayList of ArtifactItems + * Abstract Parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of + * ArtifactItems * * @see ArtifactItem * @author Brian Fox - * @version $Id: AbstractFromConfigurationMojo.java 728546 2008-12-21 22:56:51Z bentmann $ - * + * @version $Id: AbstractFromConfigurationMojo.java 1143035 2011-07-05 12:54:20Z stephenc $ */ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMojo { + /** + * Skip the execution + * + * @optional + * @since 2.2 + * @parameter expression="${mdep.skip}" default-value="false" + */ + private boolean skip; /** * Default location used for mojo unless overridden in ArtifactItem * - * @parameter expression="${outputDirectory}" - * default-value="${project.build.directory}/dependency" + * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/dependency" * @optional * @since 1.0 */ @@ -88,33 +99,58 @@ private boolean overWriteIfNewer; /** - * Collection of ArtifactItems to work on. (ArtifactItem contains groupId, - * artifactId, version, type, classifier, location, destFile, markerFile and overwrite.) - * See "Usage" and "Javadoc" for details. + * To search for artifacts within the reactor and ensure consistent behaviour between Maven 2 and Maven 3. + * + * @parameter expression="${reactorProjects}" + * @required + * @readonly + */ + protected List reactorProjects; + + /** + * Collection of ArtifactItems to work on. (ArtifactItem contains groupId, artifactId, version, type, classifier, + * location, destFileName, markerFile and overwrite.) See Usage for details. * * @parameter * @required * @since 1.0 */ - private ArrayList artifactItems; + private List artifactItems; + + /** + * To look up ArtifactRepository implementation + * + * @component + * @readonly + */ + private ArtifactRepositoryFactory artifactRepositoryManager; + + /** + * Path to override default local repository during plugin's execution. To remove all downloaded artifacts as part + * of the build, set this value to a location under your project's target directory + * + * @parameter + * @since 2.2 + */ + private File localRepositoryDirectory; + + /** + * To host and cache localRepositoryDirectory + */ + private ArtifactRepository overrideLocalRepository; abstract ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item ); /** - * Preprocesses the list of ArtifactItems. This method defaults the - * outputDirectory if not set and creates the output Directory if it doesn't - * exist. + * Preprocesses the list of ArtifactItems. This method defaults the outputDirectory if not set and creates the + * output Directory if it doesn't exist. * - * @param removeVersion - * remove the version from the filename. + * @param removeVersion remove the version from the filename. * @return An ArrayList of preprocessed ArtifactItems - * - * @throws MojoExecutionException - * with a message if an error occurs. - * + * @throws MojoExecutionException with a message if an error occurs. * @see ArtifactItem */ - protected ArrayList getProcessedArtifactItems( boolean removeVersion ) + protected List getProcessedArtifactItems( boolean removeVersion ) throws MojoExecutionException { if ( artifactItems == null || artifactItems.size() < 1 ) @@ -122,10 +158,8 @@ throw new MojoExecutionException( "There are no artifactItems configured." ); } - Iterator iter = artifactItems.iterator(); - while ( iter.hasNext() ) + for ( ArtifactItem artifactItem : artifactItems ) { - ArtifactItem artifactItem = (ArtifactItem) iter.next(); this.getLog().info( "Configured Artifact: " + artifactItem.toString() ); if ( artifactItem.getOutputDirectory() == null ) @@ -154,7 +188,7 @@ } catch ( ArtifactFilterException e ) { - throw new MojoExecutionException (e.getMessage(),e); + throw new MojoExecutionException( e.getMessage(), e ); } } return artifactItems; @@ -177,18 +211,12 @@ } /** - * Resolves the Artifact from the remote repository if nessessary. If no - * version is specified, it will be retrieved from the dependency list or - * from the DependencyManagement section of the pom. - * - * @param artifactItem - * containing information about artifact from plugin - * configuration. - * @return Artifact object representing the specified file. + * Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved + * from the dependency list or from the DependencyManagement section of the pom. * - * @throws MojoExecutionException - * with a message if the version can't be found in - * DependencyManagement. + * @param artifactItem containing information about artifact from plugin configuration. + * @return Artifact object representing the specified file. + * @throws MojoExecutionException with a message if the version can't be found in DependencyManagement. */ protected Artifact getArtifact( ArtifactItem artifactItem ) throws MojoExecutionException @@ -211,35 +239,38 @@ if ( StringUtils.isEmpty( artifactItem.getClassifier() ) ) { - artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr, - artifactItem.getType(), null, Artifact.SCOPE_COMPILE ); + artifact = + factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr, + artifactItem.getType(), null, Artifact.SCOPE_COMPILE ); } else { - artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr, - artifactItem.getType(), artifactItem.getClassifier(), - Artifact.SCOPE_COMPILE ); + artifact = + factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr, + artifactItem.getType(), artifactItem.getClassifier(), + Artifact.SCOPE_COMPILE ); } + // Maven 3 will search the reactor for the artifact but Maven 2 does not + // to keep consistent behaviour, we search the reactor ourselves. + Artifact result = getArtifactFomReactor( artifact ); + if ( result != null ) + { + return result; + } try { - // mdep-50 - rolledback for now because it's breaking some - // functionality. + // mdep-50 - rolledback for now because it's breaking some functionality. /* - * List listeners = new ArrayList(); - * - * Set theSet = new HashSet(); theSet.add( artifact ); - * ArtifactResolutionResult artifactResolutionResult = - * artifactCollector.collect( theSet, project .getArtifact(), - * managedVersions, this.local, - * project.getRemoteArtifactRepositories(), artifactMetadataSource, - * null, listeners ); Iterator iter = - * artifactResolutionResult.getArtifactResolutionNodes().iterator(); - * while ( iter.hasNext() ) { ResolutionNode node = (ResolutionNode) - * iter.next(); artifact = node.getArtifact(); } + * List listeners = new ArrayList(); Set theSet = new HashSet(); theSet.add( artifact ); + * ArtifactResolutionResult artifactResolutionResult = artifactCollector.collect( theSet, project + * .getArtifact(), managedVersions, this.local, project.getRemoteArtifactRepositories(), + * artifactMetadataSource, null, listeners ); Iterator iter = + * artifactResolutionResult.getArtifactResolutionNodes().iterator(); while ( iter.hasNext() ) { + * ResolutionNode node = (ResolutionNode) iter.next(); artifact = node.getArtifact(); } */ - resolver.resolve( artifact, remoteRepos, local ); + resolver.resolve( artifact, remoteRepos, getLocal() ); } catch ( ArtifactResolutionException e ) { @@ -254,24 +285,90 @@ } /** - * Tries to find missing version from dependancy list and dependency - * management. If found, the artifact is updated with the correct version. + * Checks to see if the specified artifact is available from the reactor. + * @param artifact The artifact we are looking for. + * @return The resolved artifact that is the same as the one we were looking for or null if one could + * not be found. + */ + private Artifact getArtifactFomReactor( Artifact artifact ) + { + // check project dependencies first off + for ( Artifact a : (Set) project.getArtifacts() ) + { + if ( equals( artifact, a ) && hasFile( a ) ) + { + return a; + } + } + // check reactor projects + for ( MavenProject p : reactorProjects == null ? Collections.emptyList() : reactorProjects ) + { + // check the main artifact + if ( equals( artifact, p.getArtifact() ) && hasFile( p.getArtifact() ) ) + { + return p.getArtifact(); + } + // check any side artifacts + for ( Artifact a : (List) p.getAttachedArtifacts() ) + { + if ( equals( artifact, a ) && hasFile( a ) ) + { + return a; + } + } + } + // not available + return null; + } + + /** + * Returns true if the artifact has a file. + * @param artifact the artifact (may be null) + * @return true if and only if the artifact is non-null and has a file. + */ + private static boolean hasFile( Artifact artifact ) + { + return artifact != null && artifact.getFile() != null && artifact.getFile().isFile(); + } + + /** + * Null-safe compare of two artifacts based on groupId, artifactId, version, type and classifier. + * @param a the first artifact. + * @param b the second artifact. + * @return true if and only if the two artifacts have the same groupId, artifactId, version, + * type and classifier. + */ + private static boolean equals( Artifact a, Artifact b ) + { + return a == b + || !( a == null || b == null ) + && StringUtils.equals( a.getGroupId(), b.getGroupId() ) + && StringUtils.equals( a.getArtifactId(), b.getArtifactId() ) + && StringUtils.equals( a.getVersion(), b.getVersion() ) + && StringUtils.equals( a.getType(), b.getType() ) + && StringUtils.equals( a.getClassifier(), b.getClassifier() ); + } + + /** + * Tries to find missing version from dependency list and dependency management. If found, the artifact is updated + * with the correct version. It will first look for an exact match on artifactId/groupId/classifier/type and if it + * doesn't find a match, it will try again looking for artifactId and groupId only. * - * It will first look for an exact match on artifactId/groupId/classifier/type and if it doesn't find - * a match, it will try again looking for artifactId and groupId only. - * @param artifact - * representing configured file. + * @param artifact representing configured file. * @throws MojoExecutionException */ private void fillMissingArtifactVersion( ArtifactItem artifact ) throws MojoExecutionException { - if ( !findDependencyVersion( artifact, project.getDependencies(), false ) - && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, project - .getDependencyManagement().getDependencies(), false ) ) - && !findDependencyVersion( artifact, project.getDependencies(), true ) - && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, project - .getDependencyManagement().getDependencies(), true ) ) ) + List deps = project.getDependencies(); + List depMngt = project.getDependencyManagement() == null + ? Collections.emptyList() + : project.getDependencyManagement().getDependencies(); + + if ( !findDependencyVersion( artifact, deps, false ) + && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, false ) ) + && !findDependencyVersion( artifact, deps, true ) + && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, true ) ) ) { throw new MojoExecutionException( "Unable to find artifact version of " + artifact.getGroupId() + ":" + artifact.getArtifactId() + " in either dependency list or in project's dependency management." ); @@ -279,87 +376,88 @@ } /** - * Tries to find missing version from a list of dependencies. If found, the - * artifact is updated with the correct version. + * Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct + * version. * - * @param artifact - * representing configured file. - * @param list - * list of dependencies to search. - * @param looseMatch - * only look at artifactId and groupId + * @param artifact representing configured file. + * @param dependencies list of dependencies to search. + * @param looseMatch only look at artifactId and groupId * @return the found dependency */ - private boolean findDependencyVersion( ArtifactItem artifact, List list, boolean looseMatch ) + private boolean findDependencyVersion( ArtifactItem artifact, List dependencies, boolean looseMatch ) { - boolean result = false; - - for ( int i = 0; i < list.size(); i++ ) + for ( Dependency dependency : dependencies ) { - Dependency dependency = (Dependency) list.get( i ); if ( StringUtils.equals( dependency.getArtifactId(), artifact.getArtifactId() ) && StringUtils.equals( dependency.getGroupId(), artifact.getGroupId() ) && ( looseMatch || StringUtils.equals( dependency.getClassifier(), artifact.getClassifier() ) ) && ( looseMatch || StringUtils.equals( dependency.getType(), artifact.getType() ) ) ) { - artifact.setVersion( dependency.getVersion() ); - result = true; - break; + return true; } } - return result; + return false; } - /* private Map createManagedVersionMap( ArtifactFactory artifactFactory, String projectId, - DependencyManagement dependencyManagement ) - throws MojoExecutionException + /* + * private Map createManagedVersionMap( ArtifactFactory artifactFactory, String projectId, DependencyManagement + * dependencyManagement ) throws MojoExecutionException { Map map; if ( dependencyManagement != null && + * dependencyManagement.getDependencies() != null ) { map = new HashMap(); for ( Iterator i = + * dependencyManagement.getDependencies().iterator(); i.hasNext(); ) { Dependency d = (Dependency) i.next(); try { + * VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); Artifact artifact = + * artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d + * .getClassifier(), d.getScope(), d .isOptional() ); map.put( d.getManagementKey(), artifact ); } catch ( + * InvalidVersionSpecificationException e ) { throw new MojoExecutionException( "Unable to parse version", e ); } } + * } else { map = Collections.EMPTY_MAP; } return map; } + */ + + /** + * Override the base to + * + * @return Returns the local. + */ + protected ArtifactRepository getLocal() { - Map map; - if ( dependencyManagement != null && dependencyManagement.getDependencies() != null ) + if ( this.overrideLocalRepository != null ) { - map = new HashMap(); - for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); ) - { - Dependency d = (Dependency) i.next(); + return this.overrideLocalRepository; + } - try - { - VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); - Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), - versionRange, d.getType(), d - .getClassifier(), d.getScope(), d - .isOptional() ); - map.put( d.getManagementKey(), artifact ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( "Unable to parse version", e ); - } - } + ArtifactRepository local = super.getLocal(); + + if ( this.localRepositoryDirectory != null ) + { + // create a new local repo using existing layout, snapshots, and releases policy + String url = "file://" + this.localRepositoryDirectory.getAbsolutePath(); + this.overrideLocalRepository = + artifactRepositoryManager.createArtifactRepository( local.getId(), url, local.getLayout(), + local.getSnapshots(), local.getReleases() ); + + this.getLog().debug( "Execution local repository is at: " + this.overrideLocalRepository.getBasedir() ); } else { - map = Collections.EMPTY_MAP; + this.overrideLocalRepository = local; } - return map; - }*/ + + return this.overrideLocalRepository; + } /** * @return Returns the artifactItems. */ - public ArrayList getArtifactItems() + public List getArtifactItems() { return this.artifactItems; } /** - * @param theArtifactItems - * The artifactItems to set. + * @param theArtifactItems The artifactItems to set. */ - public void setArtifactItems( ArrayList theArtifactItems ) + public void setArtifactItems( List theArtifactItems ) { this.artifactItems = theArtifactItems; } @@ -373,8 +471,7 @@ } /** - * @param theOutputDirectory - * The outputDirectory to set. + * @param theOutputDirectory The outputDirectory to set. */ public void setOutputDirectory( File theOutputDirectory ) { @@ -390,8 +487,7 @@ } /** - * @param theOverWriteIfNewer - * The overWriteIfNewer to set. + * @param theOverWriteIfNewer The overWriteIfNewer to set. */ public void setOverWriteIfNewer( boolean theOverWriteIfNewer ) { @@ -407,8 +503,7 @@ } /** - * @param theOverWriteReleases - * The overWriteReleases to set. + * @param theOverWriteReleases The overWriteReleases to set. */ public void setOverWriteReleases( boolean theOverWriteReleases ) { @@ -424,11 +519,25 @@ } /** - * @param theOverWriteSnapshots - * The overWriteSnapshots to set. + * @param theOverWriteSnapshots The overWriteSnapshots to set. */ public void setOverWriteSnapshots( boolean theOverWriteSnapshots ) { this.overWriteSnapshots = theOverWriteSnapshots; } + + public void setLocalRepositoryDirectory( File localRepositoryDirectory ) + { + this.localRepositoryDirectory = localRepositoryDirectory; + } + + public boolean isSkip() + { + return skip; + } + + public void setSkip( boolean skip ) + { + this.skip = skip; + } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ArtifactItem.java 2011-03-26 18:13:19.000000000 +0000 @@ -1,6 +1,6 @@ package org.apache.maven.plugin.dependency.fromConfiguration; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,27 +16,28 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.codehaus.plexus.util.StringUtils; /** * ArtifactItem represents information specified in the plugin configuration * section for each artifact. - * + * * @since 1.0 * @author Brian Fox - * @version $Id: ArtifactItem.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ArtifactItem.java 1085777 2011-03-26 18:13:19Z hboutemy $ */ public class ArtifactItem { /** * Group Id of Artifact - * + * * @parameter * @required */ @@ -44,7 +45,7 @@ /** * Name of Artifact - * + * * @parameter * @required */ @@ -52,14 +53,14 @@ /** * Version of Artifact - * + * * @parameter */ private String version = null; /** * Type of Artifact (War,Jar,etc) - * + * * @parameter * @required */ @@ -67,21 +68,21 @@ /** * Classifier for Artifact (tests,sources,etc) - * + * * @parameter */ private String classifier; /** * Location to use for this Artifact. Overrides default location. - * + * * @parameter */ private File outputDirectory; /** * Provides ability to change destination file name - * + * * @parameter */ private String destFileName; @@ -100,7 +101,7 @@ * Artifact Item */ private Artifact artifact; - + /** * A comma separated list of file patterns to include when unpacking the * artifact. @@ -130,14 +131,11 @@ private String filterEmptyString( String in ) { - if ( in == null || in.equals( "" ) ) + if ( "".equals( in ) ) { return null; } - else - { - return in; - } + return in; } /** @@ -322,37 +320,37 @@ { this.artifact = artifact; } - + /** * @return Returns a comma separated list of excluded items */ public String getExcludes () { - return this.excludes; + return DependencyUtil.cleanToBeTokenizedString( this.excludes ); } - + /** - * @param excludes - * A comma seperated list of items to exclude - * i.e. **\/*.xml, **\/*.properties + * @param excludes + * A comma separated list of items to exclude + * i.e. **\/*.xml, **\/*.properties */ public void setExcludes ( String excludes ) { this.excludes = excludes; } - + /** - * @return Returns a comma seperated list of included items + * @return Returns a comma separated list of included items */ public String getIncludes() { - return this.includes; + return DependencyUtil.cleanToBeTokenizedString( this.includes ); } /** * @param includes - * A comma seperated list of items to inmclude - * i.e. **\/*.xml, **\/*.properties + * A comma separated list of items to include + * i.e. **\/*.xml, **\/*.properties */ public void setIncludes ( String includes ) { diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/CopyMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -1,6 +1,6 @@ package org.apache.maven.plugin.dependency.fromConfiguration; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,29 +16,24 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; +import java.util.List; -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter; -import org.apache.maven.plugin.logging.Log; /** - * Goal that copies a list of artifacts from the repository to defined - * locations. + * Goal that copies a list of artifacts from the repository to defined locations. * * @goal copy * @since 1.0 * @phase process-sources * @author Brian Fox - * @version $Id: CopyMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: CopyMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ */ public class CopyMojo extends AbstractFromConfigurationMojo @@ -53,12 +48,10 @@ private boolean stripVersion = false; /** - * Main entry into mojo. This method gets the ArtifactItems and iterates - * through each one passing it to copyArtifact. - * - * @throws MojoExecutionException - * with a message if an error occurs. + * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to + * copyArtifact. * + * @throws MojoExecutionException with a message if an error occurs. * @see ArtifactItem * @see #getArtifactItems * @see #copyArtifact(ArtifactItem) @@ -66,11 +59,14 @@ public void execute() throws MojoExecutionException { - ArrayList theArtifactItems = getProcessedArtifactItems( this.stripVersion ); - Iterator iter = theArtifactItems.iterator(); - while ( iter.hasNext() ) + if ( isSkip() ) + { + return; + } + + List theArtifactItems = getProcessedArtifactItems( this.stripVersion ); + for ( ArtifactItem artifactItem : theArtifactItems ) { - ArtifactItem artifactItem = (ArtifactItem) iter.next(); if ( artifactItem.isNeedsProcessing() ) { copyArtifact( artifactItem ); @@ -83,14 +79,10 @@ } /** - * Resolves the artifact from the repository and copies it to the specified - * location. - * - * @param artifactItem - * containing the information about the Artifact to copy. - * @throws MojoExecutionException - * with a message if an error occurs. + * Resolves the artifact from the repository and copies it to the specified location. * + * @param artifactItem containing the information about the Artifact to copy. + * @throws MojoExecutionException with a message if an error occurs. * @see DependencyUtil#copyFile(File, File, Log) * @see DependencyUtil#getFormattedFileName(Artifact, boolean) */ @@ -104,9 +96,9 @@ protected ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item ) { - ArtifactItemFilter destinationNameOverrideFilter = new DestFileFilter( this.isOverWriteReleases(), this - .isOverWriteSnapshots(), this.isOverWriteIfNewer(), false, false, false, this.stripVersion, item - .getOutputDirectory() ); + ArtifactItemFilter destinationNameOverrideFilter = + new DestFileFilter( this.isOverWriteReleases(), this.isOverWriteSnapshots(), this.isOverWriteIfNewer(), + false, false, false, false, this.stripVersion, item.getOutputDirectory() ); return destinationNameOverrideFilter; } @@ -119,8 +111,7 @@ } /** - * @param stripVersion - * The stripVersion to set. + * @param stripVersion The stripVersion to set. */ public void setStripVersion( boolean stripVersion ) { diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java 2011-03-27 16:03:41.000000000 +0000 @@ -1,6 +1,6 @@ package org.apache.maven.plugin.dependency.fromConfiguration; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,33 +16,27 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; +import java.util.List; -import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.dependency.utils.DependencyUtil; import org.apache.maven.plugin.dependency.utils.filters.ArtifactItemFilter; import org.apache.maven.plugin.dependency.utils.filters.MarkerFileFilter; import org.apache.maven.plugin.dependency.utils.markers.MarkerHandler; import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler; -import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.util.StringUtils; /** - * Goal that retrieves a list of artifacts from the repository and unpacks them - * in a defined location. + * Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location. * * @since 1.0 * @goal unpack * @phase process-sources * @author Brian Fox - * @version $Id: UnpackMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: UnpackMojo.java 1085975 2011-03-27 16:03:41Z hboutemy $ */ public final class UnpackMojo extends AbstractFromConfigurationMojo @@ -54,30 +48,32 @@ * @parameter expression="${project.build.directory}/dependency-maven-plugin-markers" */ private File markersDirectory; - + /** - * A comma separated list of file patterns to include when unpacking the - * artifact. i.e. **\/*.xml,**\/*.properties NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name );) - * @since 2.0-alpha-5 + * A comma separated list of file patterns to include when unpacking the artifact. i.e. **\/*.xml,**\/*.properties + * NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name + * );) + * + * @since 2.0-alpha-5 * @parameter expression="${mdep.unpack.includes}" */ private String includes; /** - * A comma separated list of file patterns to exclude when unpacking the - * artifact. i.e. **\/*.xml,**\/*.properties NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name );) + * A comma separated list of file patterns to exclude when unpacking the artifact. i.e. **\/*.xml,**\/*.properties + * NOTE: Excludes patterns override the includes. (component code = return isIncluded( name ) AND !isExcluded( name + * );) + * * @since 2.0-alpha-5 * @parameter expression="${mdep.unpack.excludes}" */ private String excludes; /** - * Main entry into mojo. This method gets the ArtifactItems and iterates - * through each one passing it to unpackArtifact. - * - * @throws MojoExecutionException - * with a message if an error occurs. + * Main entry into mojo. This method gets the ArtifactItems and iterates through each one passing it to + * unpackArtifact. * + * @throws MojoExecutionException with a message if an error occurs. * @see ArtifactItem * @see #getArtifactItems * @see #unpackArtifact(ArtifactItem) @@ -85,11 +81,14 @@ public void execute() throws MojoExecutionException { - ArrayList processedItems = getProcessedArtifactItems( false ); - Iterator iter = processedItems.iterator(); - while ( iter.hasNext() ) + if ( isSkip() ) + { + return; + } + + List processedItems = getProcessedArtifactItems( false ); + for ( ArtifactItem artifactItem : processedItems ) { - ArtifactItem artifactItem = (ArtifactItem) iter.next(); if ( artifactItem.isNeedsProcessing() ) { unpackArtifact( artifactItem ); @@ -104,24 +103,19 @@ /** * This method gets the Artifact object and calls DependencyUtil.unpackFile. * - * @param artifactItem - * containing the information about the Artifact to unpack. - * - * @throws MojoExecutionException - * with a message if an error occurs. - * + * @param artifactItem containing the information about the Artifact to unpack. + * @throws MojoExecutionException with a message if an error occurs. * @see #getArtifact - * @see DependencyUtil#unpackFile(Artifact, File, File, ArchiverManager, - * Log) + * @see DependencyUtil#unpackFile(Artifact, File, File, ArchiverManager, Log) */ private void unpackArtifact( ArtifactItem artifactItem ) throws MojoExecutionException { MarkerHandler handler = new UnpackFileMarkerHandler( artifactItem, this.markersDirectory ); - - unpack( artifactItem.getArtifact().getFile(), artifactItem.getOutputDirectory(), artifactItem.getIncludes(), artifactItem.getExcludes() ); - handler.setMarker(); + unpack( artifactItem.getArtifact().getFile(), artifactItem.getOutputDirectory(), artifactItem.getIncludes(), + artifactItem.getExcludes() ); + handler.setMarker(); } ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item ) @@ -131,25 +125,23 @@ return new MarkerFileFilter( this.isOverWriteReleases(), this.isOverWriteSnapshots(), this.isOverWriteIfNewer(), handler ); } - - protected ArrayList getProcessedArtifactItems(boolean removeVersion) - throws MojoExecutionException - { - ArrayList items = super.getProcessedArtifactItems( removeVersion ); - Iterator iter = items.iterator(); - while ( iter.hasNext() ) + + protected List getProcessedArtifactItems( boolean removeVersion ) + throws MojoExecutionException + { + List items = super.getProcessedArtifactItems( removeVersion ); + for ( ArtifactItem artifactItem : items ) { - ArtifactItem artifactItem = (ArtifactItem) iter.next(); - if ( StringUtils.isEmpty(artifactItem.getIncludes()) ) + if ( StringUtils.isEmpty( artifactItem.getIncludes() ) ) { artifactItem.setIncludes( getIncludes() ); } - if ( StringUtils.isEmpty(artifactItem.getExcludes()) ) + if ( StringUtils.isEmpty( artifactItem.getExcludes() ) ) { artifactItem.setExcludes( getExcludes() ); } } - return items; + return items; } /** @@ -161,47 +153,41 @@ } /** - * @param theMarkersDirectory - * The markersDirectory to set. + * @param theMarkersDirectory The markersDirectory to set. */ public void setMarkersDirectory( File theMarkersDirectory ) { this.markersDirectory = theMarkersDirectory; } - - + /** * @return Returns a comma separated list of excluded items */ - public String getExcludes () + public String getExcludes() { return this.excludes; } - + /** - * @param excludes - * A comma separated list of items to exclude - * i.e. **\/*.xml, **\/*.properties + * @param excludes A comma separated list of items to exclude i.e. **\/*.xml, **\/*.properties */ - public void setExcludes ( String excludes ) + public void setExcludes( String excludes ) { this.excludes = excludes; } - + /** * @return Returns a comma separated list of included items */ public String getIncludes() { - return this.includes; + return this.includes; } /** - * @param includes - * A comma separated list of items to include - * i.e. **\/*.xml, **\/*.properties + * @param includes A comma separated list of items to include i.e. **\/*.xml, **\/*.properties */ - public void setIncludes ( String includes ) + public void setIncludes( String includes ) { this.includes = includes; } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/GoOfflineMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -19,7 +19,6 @@ * under the License. */ -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -36,7 +35,7 @@ * @execute goal=resolve-plugins * @requiresDependencyResolution test * @author Brian Fox - * @version $Id: GoOfflineMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: GoOfflineMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0 */ public class GoOfflineMojo @@ -54,20 +53,19 @@ public void execute() throws MojoExecutionException { - Set artifacts = project.getArtifacts(); + Set artifacts = project.getArtifacts(); if ( !silent ) { - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : artifacts ) { - this.getLog().info( "Resolved: " + DependencyUtil.getFormattedFileName( (Artifact) i.next(), false ) ); + this.getLog().info( "Resolved: " + DependencyUtil.getFormattedFileName( artifact, false ) ); } } } protected ArtifactsFilter getMarkedArtifactFilter() { - // TODO Auto-generated method stub return null; } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -0,0 +1,81 @@ +package org.apache.maven.plugin.dependency.resolvers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.artifact.resolver.ResolutionNode; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.dependency.AbstractDependencyMojo; +import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter; + +/** + * Goal that resolves all project dependencies and then lists the repositories + * used by the build and by the transitive dependencies + * + * @goal list-repositories + * @requiresDependencyResolution test + * @author Brian Fox + * @version $Id: GoOfflineMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @since 2.2 + */ +public class ListRepositoriesMojo + extends AbstractDependencyMojo +{ + /** + * Displays a list of the repositories used by this build. + * @throws MojoExecutionException + * with a message if an error occurs. + * + */ + public void execute() + throws MojoExecutionException + { + try + { + ArtifactResolutionResult result = + this.artifactCollector.collect( project.getArtifacts(), project.getArtifact(), this.getLocal(), + this.remoteRepos, this.artifactMetadataSource, + new ScopeArtifactFilter( Artifact.SCOPE_TEST ), new ArrayList() ); + Set repos = new HashSet(); + Set nodes = result.getArtifactResolutionNodes(); + for ( ResolutionNode node : nodes ) + { + repos.addAll( node.getRemoteRepositories() ); + } + + this.getLog().info( "Repositories Used by this build:" ); + for ( Iterator i = repos.iterator(); i.hasNext(); ) + { + this.getLog().info( i.next().toString() ); + } + } + catch ( ArtifactResolutionException e ) + { + throw new MojoExecutionException( "Unable to resolve artifacts", e ); + } + } +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java 2010-11-04 21:04:45.000000000 +0000 @@ -16,7 +16,7 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.IOException; @@ -31,12 +31,12 @@ /** * Goal that resolves the project dependencies from the repository. - * + * * @goal resolve * @requiresDependencyResolution test * @phase generate-sources * @author Brian Fox - * @version $Id: ResolveDependenciesMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ResolveDependenciesMojo.java 1031245 2010-11-04 21:04:45Z brianf $ * @since 2.0 */ public class ResolveDependenciesMojo @@ -45,7 +45,7 @@ /** * If we should display the scope when resolving - * + * * @parameter expression="${mdep.outputScope}" default-value="true" * @since 2.0-alpha-2 */ @@ -58,7 +58,7 @@ /** * Main entry into mojo. Gets the list of dependencies and iterates through displaying the resolved version. - * + * * @throws MojoExecutionException with a message if an error occurs. */ public void execute() @@ -76,12 +76,12 @@ } else { - DependencyUtil.write( output, outputFile, getLog() ); + DependencyUtil.write( output, outputFile, appendOutput, getLog() ); } } catch ( IOException e ) { - throw new MojoExecutionException(e.getMessage(),e); + throw new MojoExecutionException( e.getMessage(), e ); } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependencySourcesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,6 +1,6 @@ package org.apache.maven.plugin.dependency.resolvers; -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,11 +16,10 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.IOException; -import java.util.Iterator; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; @@ -33,12 +32,12 @@ /** * Goal that resolves the project source dependencies from the repository. - * + * * @goal sources * @phase generate-sources * @requiresDependencyResolution test * @author Brian Fox - * @version $Id: ResolveDependencySourcesMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ResolveDependencySourcesMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ * @since 2.0-alpha2 */ public class ResolveDependencySourcesMojo @@ -53,14 +52,14 @@ * Only used to store results for integration test validation */ DependencyStatusSets results; - + /** * Main entry into mojo. Gets the list of dependencies and iterates through * resolving the source jars. - * + * * @throws MojoExecutionException * with a message if an error occurs. - * + * */ public void execute() throws MojoExecutionException @@ -69,23 +68,19 @@ this.type = SOURCE_TYPE; // get sets of dependencies results = this.getDependencySets( false ); - - SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler(this.markersDirectory); + + SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler( this.markersDirectory ); handler.setResolved( true ); - - Iterator iter = results.getResolvedDependencies().iterator(); - while (iter.hasNext()) + + for ( Artifact artifact : results.getResolvedDependencies() ) { - Artifact artifact = (Artifact) iter.next(); handler.setArtifact( artifact ); handler.setMarker(); } - + handler.setResolved( false ); - iter = results.getUnResolvedDependencies().iterator(); - while (iter.hasNext()) + for ( Artifact artifact : results.getUnResolvedDependencies() ) { - Artifact artifact = (Artifact) iter.next(); handler.setArtifact( artifact ); handler.setMarker(); } @@ -99,12 +94,12 @@ } else { - DependencyUtil.write( output, outputFile, getLog() ); + DependencyUtil.write( output, outputFile, appendOutput, getLog() ); } } catch ( IOException e ) { - throw new MojoExecutionException(e.getMessage(),e); + throw new MojoExecutionException( e.getMessage(), e ); } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java 2011-03-26 18:13:19.000000000 +0000 @@ -1,26 +1,24 @@ package org.apache.maven.plugin.dependency.resolvers; -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -33,6 +31,7 @@ import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; +import org.codehaus.plexus.util.IOUtil; /** * Goal that resolves all project plugins and reports and their dependencies. @@ -40,7 +39,7 @@ * @goal resolve-plugins * @phase generate-sources * @author Brian Fox - * @version $Id: ResolvePluginsMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ResolvePluginsMojo.java 1085777 2011-03-26 18:13:19Z hboutemy $ * @since 2.0 */ public class ResolvePluginsMojo @@ -74,32 +73,58 @@ public void execute() throws MojoExecutionException { + Writer outputWriter = null; + try { - Set plugins = resolvePluginArtifacts(); - for ( Iterator i = plugins.iterator(); i.hasNext(); ) + Set plugins = resolvePluginArtifacts(); + + if ( this.outputFile != null ) + { + outputFile.getParentFile().mkdirs(); + + outputWriter = new FileWriter( outputFile ); + } + + for ( Artifact plugin : plugins ) { - Artifact plugin = (Artifact) i.next(); + String logStr = "Plugin Resolved: " + DependencyUtil.getFormattedFileName( plugin, false ); if ( !silent ) { - this.getLog().info( "Plugin Resolved: " + DependencyUtil.getFormattedFileName( plugin, false ) ); + this.getLog().info( logStr ); + } + + if ( outputWriter != null ) + { + outputWriter.write( logStr ); + outputWriter.write( "\n" ); } + if ( !excludeTransitive ) { - Set transitiveDependencies = this.resolveArtifactDependencies( plugin ); - if ( !silent ) + for ( Artifact artifact : resolveArtifactDependencies( plugin ) ) { - for ( Iterator transIter = transitiveDependencies.iterator(); transIter.hasNext(); ) + logStr = + " Plugin Dependency Resolved: " + DependencyUtil.getFormattedFileName( artifact, false ); + + if ( !silent ) + { + this.getLog().info( logStr ); + } + + if ( outputWriter != null ) { - this.getLog().info( - " Plugin Dependency Resolved: " - + DependencyUtil.getFormattedFileName( (Artifact) transIter.next(), - false ) ); + outputWriter.write( logStr ); + outputWriter.write( "\n" ); } } } } } + catch ( IOException e ) + { + throw new MojoExecutionException( "Nested:", e ); + } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException( "Nested:", e ); @@ -116,6 +141,10 @@ { throw new MojoExecutionException( "Nested:", e ); } + finally + { + IOUtil.close( outputWriter ); + } } @@ -138,28 +167,26 @@ * @throws ArtifactResolutionException * @throws ArtifactNotFoundException */ - protected Set resolvePluginArtifacts() + protected Set resolvePluginArtifacts() throws ArtifactResolutionException, ArtifactNotFoundException { - Set plugins = project.getPluginArtifacts(); - Set reports = project.getReportArtifacts(); + Set plugins = project.getPluginArtifacts(); + Set reports = project.getReportArtifacts(); - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); artifacts.addAll( reports ); artifacts.addAll( plugins ); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) i.next(); // resolve the new artifact - this.resolver.resolve( artifact, this.remotePluginRepositories, this.local ); + this.resolver.resolve( artifact, this.remotePluginRepositories, this.getLocal() ); } return artifacts; } protected ArtifactsFilter getMarkedArtifactFilter() { - // TODO Auto-generated method stub return null; } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/AbstractSerializingVisitor.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/AbstractSerializingVisitor.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/AbstractSerializingVisitor.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/AbstractSerializingVisitor.java 2009-02-16 13:38:32.000000000 +0000 @@ -0,0 +1,57 @@ +package org.apache.maven.plugin.dependency.treeSerializers ; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.PrintWriter; +import java.io.Writer; + +/** + * Abstract class for visitors performing serialization. + * + * @author Jerome Creignou + */ +public abstract class AbstractSerializingVisitor +{ + + /** + * The writer to serialize to. + */ + protected final PrintWriter writer; + + /** + * Constructor. + *

    + * Build a new AbstractSerializingDependencyNodeVisitor with the writer to serialize to. + *

    + * + * @param writer the writer to serialize to. + */ + public AbstractSerializingVisitor( Writer writer ) + { + if ( writer instanceof PrintWriter ) + { + this.writer = (PrintWriter) writer; + } + else + { + this.writer = new PrintWriter( writer, true ); + } + } +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/DOTDependencyNodeVisitor.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/DOTDependencyNodeVisitor.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/DOTDependencyNodeVisitor.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/DOTDependencyNodeVisitor.java 2011-03-13 00:17:39.000000000 +0000 @@ -0,0 +1,89 @@ +package org.apache.maven.plugin.dependency.treeSerializers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor; +import org.apache.maven.shared.dependency.tree.DependencyNode; + +import java.io.Writer; +import java.util.List; + +/** + * A dependency node visitor that serializes visited nodes to DOT format + * http://en.wikipedia.org/wiki/DOT_language + * + * @author Pi Song + * @since 2.1 + */ +public class DOTDependencyNodeVisitor extends AbstractSerializingVisitor + implements DependencyNodeVisitor { + + /** + * Constructor. + * + * @param writer the writer to write to. + */ + public DOTDependencyNodeVisitor( Writer writer) + { + super( writer ); + } + + + /** + * {@inheritDoc} + */ + public boolean visit( DependencyNode node ) + { + if ( node.getParent() == null || node.getParent() == node ) + { + writer.write( "digraph \"" + node.toNodeString() + "\" { \n" ); + } + + // Generate "currentNode -> Child" lines + + List children = node.getChildren(); + + for ( DependencyNode child : children ) + { + StringBuffer sb = new StringBuffer(); + sb.append( "\t\"" ); + sb.append( node.toNodeString() ); + sb.append( "\" -> \"" ); + sb.append( child.toNodeString() ); + sb.append( "\" ; " ); + writer.println( sb.toString() ); + } + + return true; + } + + /** + * {@inheritDoc} + */ + public boolean endVisit( DependencyNode node ) + { + if ( node.getParent() == null || node.getParent() == node ) + { + writer.write( " } " ); + } + return true; + } + +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/GraphmlDependencyNodeVisitor.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/GraphmlDependencyNodeVisitor.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/GraphmlDependencyNodeVisitor.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/GraphmlDependencyNodeVisitor.java 2011-03-26 18:13:19.000000000 +0000 @@ -0,0 +1,122 @@ +package org.apache.maven.plugin.dependency.treeSerializers ; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.Writer; + +import org.apache.maven.shared.dependency.tree.DependencyNode; +import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor; + +/** + * A dependency node visitor that serializes visited nodes to a writer using the graphml format. + * {@link http://graphml.graphdrawing.org/} + * + * @author Jerome Creignou + * @since 2.1 + */ +public class GraphmlDependencyNodeVisitor extends AbstractSerializingVisitor + implements DependencyNodeVisitor +{ + + /** + * Graphml xml file header. Define Schema and root element. We also define 2 key as meta data. + */ + private static final String GRAPHML_HEADER = + " " + + "\n" + + " \n" + + " \n" + + "\n"; + + /** + * Graphml xml file footer. + */ + private static final String GRAPHML_FOOTER = ""; + + /** + * Constructor. + * + * @param writer the writer to write to. + */ + public GraphmlDependencyNodeVisitor( Writer writer ) + { + super( writer ); + } + + /** + * {@inheritDoc} + */ + public boolean endVisit( DependencyNode node ) + { + if ( node.getParent() == null || node.getParent() == node ) + { + writer.write( GRAPHML_FOOTER ); + } + else + { + DependencyNode p = node.getParent(); + writer.print( "" ); + if ( node.getArtifact().getScope() != null ) + { + // add Edge label + writer.print( "" + node.getArtifact().getScope() + + "" ); + } + writer.println( "" ); + } + return true; + } + + /** + * {@inheritDoc} + */ + public boolean visit( DependencyNode node ) + { + if ( node.getParent() == null || node.getParent() == node ) + { + writer.write( GRAPHML_HEADER ); + } + // write node + writer.print( "" ); + // add node label + writer.print( "" + node.toNodeString() + + "" ); + writer.println( "" ); + return true; + } + + /** + * Generate a unique id from a DependencyNode. + *

    + * Current implementation is rather simple and uses hashcode. + *

    + * + * @param node the DependencyNode to use. + * @return the unique id. + */ + private static String generateId( DependencyNode node ) + { + return String.valueOf( node.hashCode() ); + } +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/TGFDependencyNodeVisitor.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/TGFDependencyNodeVisitor.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/TGFDependencyNodeVisitor.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/treeSerializers/TGFDependencyNodeVisitor.java 2011-03-13 00:17:39.000000000 +0000 @@ -0,0 +1,157 @@ +package org.apache.maven.plugin.dependency.treeSerializers ; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.shared.dependency.tree.DependencyNode; +import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor; + +/** + * A dependency node visitor that serializes visited nodes to a writer using the TGF format. + * + * http://en.wikipedia.org/wiki/Trivial_Graph_Format + * + * @author Jerome Creignou + * @since 2.1 + */ +public class TGFDependencyNodeVisitor extends AbstractSerializingVisitor + implements DependencyNodeVisitor +{ + + /** + * Utiity class to write an Edge. + * + * @author Jerome Creignou + */ + final static class EdgeAppender + { + /** + * Edge start. + */ + private DependencyNode from; + + /** + * Edge end. + */ + private DependencyNode to; + + /** + * Edge label. (optional) + */ + private String label; + + /** + * Build a new EdgeAppender. + * + * @param from edge start. + * @param to edge end + * @param label optional label. + */ + public EdgeAppender( DependencyNode from, DependencyNode to, String label ) + { + super(); + this.from = from; + this.to = to; + this.label = label; + } + + /** + * build a string representing the edge. + */ + public String toString() + { + StringBuffer result = new StringBuffer( generateId( from ) ); + result.append( ' ' ).append( generateId( to ) ); + if ( label != null ) + { + result.append( ' ' ).append( label ); + } + return result.toString(); + } + + } + + /** + * List of edges. + */ + private List edges = new ArrayList(); + + /** + * Constructor. + * + * @param writer the writer to write to. + */ + public TGFDependencyNodeVisitor( Writer writer ) + { + super( writer ); + } + + /** + * {@inheritDoc} + */ + public boolean endVisit( DependencyNode node ) + { + if ( node.getParent() == null || node.getParent() == node ) + { + // dump edges on last node endVisit + writer.println( "#" ); + for ( EdgeAppender edge : edges ) + { + writer.println( edge.toString() ); + } + } + else + { + DependencyNode p = node.getParent(); + // using scope as edge label. + edges.add( new EdgeAppender( p, node, node.getArtifact().getScope() ) ); + } + return true; + } + + /** + * {@inheritDoc} + */ + public boolean visit( DependencyNode node ) + { + // write node + writer.write( generateId( node ) ); + writer.write( " " ); + writer.println( node.toNodeString() ); + return true; + } + + /** + * Generate a unique id from a DependencyNode. + *

    + * Current implementation is rather simple and uses hashcode. + *

    + * + * @param node the DependencyNode to use. + * @return the unique id. + */ + private static String generateId( DependencyNode node ) + { + return String.valueOf( node.hashCode() ); + } +} diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencySilentLog.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencySilentLog.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencySilentLog.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencySilentLog.java 2011-03-26 21:15:52.000000000 +0000 @@ -23,171 +23,305 @@ import org.codehaus.plexus.logging.Logger; /** + * This logger implements both types of logs currently in use and turns off logs. + * * @author Brian Fox - * @version $Id: DependencySilentLog.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DependencySilentLog.java 1085803 2011-03-26 21:15:52Z hboutemy $ */ public class DependencySilentLog implements Log, Logger { - + /** + * @return false + * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() + */ public boolean isDebugEnabled() { return false; } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence) + */ public void debug( CharSequence content ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable) + */ public void debug( CharSequence content, Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable) + */ public void debug( Throwable error ) { + // nop } + /** + * @return false + * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() + */ public boolean isInfoEnabled() { return false; } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence) + */ public void info( CharSequence content ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable) + */ public void info( CharSequence content, Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable) + */ public void info( Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() + */ public boolean isWarnEnabled() { + // nop return false; } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence) + */ public void warn( CharSequence content ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable) + */ public void warn( CharSequence content, Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable) + */ public void warn( Throwable error ) { + // nop } + /** + * @return false + * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() + */ public boolean isErrorEnabled() { return false; } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence) + */ public void error( CharSequence content ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable) + */ public void error( CharSequence content, Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) + */ public void error( Throwable error ) { + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#debug(java.lang.String) + */ public void debug( String message ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#debug(java.lang.String, java.lang.Throwable) + */ public void debug( String message, Throwable throwable ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#info(java.lang.String) + */ public void info( String message ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#info(java.lang.String, java.lang.Throwable) + */ public void info( String message, Throwable throwable ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#warn(java.lang.String) + */ public void warn( String message ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#warn(java.lang.String, java.lang.Throwable) + */ public void warn( String message, Throwable throwable ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#error(java.lang.String) + */ public void error( String message ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#error(java.lang.String, java.lang.Throwable) + */ public void error( String message, Throwable throwable ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String) + */ public void fatalError( String message ) { - // TODO Auto-generated method stub - + // nop } + /** + * By default, do nothing. + * + * @see org.codehaus.plexus.logging.Logger#fatalError(java.lang.String, java.lang.Throwable) + */ public void fatalError( String message, Throwable throwable ) { - // TODO Auto-generated method stub - + // nop } + /** + * @return false + * @see org.codehaus.plexus.logging.Logger#isFatalErrorEnabled() + */ public boolean isFatalErrorEnabled() { - // TODO Auto-generated method stub return false; } + /** + * @return null + * @see org.codehaus.plexus.logging.Logger#getChildLogger(java.lang.String) + */ public Logger getChildLogger( String name ) { - // TODO Auto-generated method stub return null; } + /** + * @return 0 + * @see org.codehaus.plexus.logging.Logger#getThreshold() + */ public int getThreshold() { - // TODO Auto-generated method stub return 0; } + /** + * @return null + * @see org.codehaus.plexus.logging.Logger#getName() + */ public String getName() { - // TODO Auto-generated method stub return null; } - - /* (non-Javadoc) - * @see org.codehaus.plexus.logging.Logger#setThreshold(int) - */ - public void setThreshold( int theThreshold ) - { - // TODO Auto-generated method stub - - } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyStatusSets.java 2011-03-13 00:17:39.000000000 +0000 @@ -16,58 +16,56 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ /** - * + * */ -import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import org.apache.maven.artifact.Artifact; /** * @author Brian Fox - * @version $Id: DependencyStatusSets.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DependencyStatusSets.java 1081021 2011-03-13 00:17:39Z hboutemy $ */ public class DependencyStatusSets { - TreeSet resolvedDependencies = null; + Set resolvedDependencies = null; - TreeSet unResolvedDependencies = null; + Set unResolvedDependencies = null; - TreeSet skippedDependencies = null; + Set skippedDependencies = null; public DependencyStatusSets() { } - public DependencyStatusSets( Set resolved, Set unResolved, Set skipped ) + public DependencyStatusSets( Set resolved, Set unResolved, Set skipped ) { if ( resolved != null ) { - this.resolvedDependencies = new TreeSet( resolved ); + this.resolvedDependencies = new LinkedHashSet( resolved ); } if ( unResolved != null ) { - this.unResolvedDependencies = new TreeSet( unResolved ); + this.unResolvedDependencies = new LinkedHashSet( unResolved ); } if ( skipped != null ) { - this.skippedDependencies = new TreeSet( skipped ); + this.skippedDependencies = new LinkedHashSet( skipped ); } } /** * @return Returns the resolvedDependencies. */ - public Set getResolvedDependencies() + public Set getResolvedDependencies() { return this.resolvedDependencies; } @@ -76,11 +74,11 @@ * @param resolvedDependencies * The resolvedDependencies to set. */ - public void setResolvedDependencies( Set resolvedDependencies ) + public void setResolvedDependencies( Set resolvedDependencies ) { if ( resolvedDependencies != null ) { - this.resolvedDependencies = new TreeSet( resolvedDependencies ); + this.resolvedDependencies = new LinkedHashSet( resolvedDependencies ); } else { @@ -91,7 +89,7 @@ /** * @return Returns the skippedDependencies. */ - public Set getSkippedDependencies() + public Set getSkippedDependencies() { return this.skippedDependencies; } @@ -100,11 +98,11 @@ * @param skippedDependencies * The skippedDependencies to set. */ - public void setSkippedDependencies( Set skippedDependencies ) + public void setSkippedDependencies( Set skippedDependencies ) { if ( skippedDependencies != null ) { - this.skippedDependencies = new TreeSet( skippedDependencies ); + this.skippedDependencies = new LinkedHashSet( skippedDependencies ); } else { @@ -115,7 +113,7 @@ /** * @return Returns the unResolvedDependencies. */ - public Set getUnResolvedDependencies() + public Set getUnResolvedDependencies() { return this.unResolvedDependencies; } @@ -124,11 +122,11 @@ * @param unResolvedDependencies * The unResolvedDependencies to set. */ - public void setUnResolvedDependencies( Set unResolvedDependencies ) + public void setUnResolvedDependencies( Set unResolvedDependencies ) { if ( unResolvedDependencies != null ) { - this.unResolvedDependencies = new TreeSet( unResolvedDependencies ); + this.unResolvedDependencies = new LinkedHashSet( unResolvedDependencies ); } else { @@ -136,12 +134,12 @@ } } - public String getOutput(boolean outputAbsoluteArtifactFilename ) + public String getOutput( boolean outputAbsoluteArtifactFilename ) { - return getOutput(outputAbsoluteArtifactFilename, true ); + return getOutput( outputAbsoluteArtifactFilename, true ); } - public String getOutput(boolean outputAbsoluteArtifactFilename, boolean outputScope ) + public String getOutput( boolean outputAbsoluteArtifactFilename, boolean outputScope ) { StringBuffer sb = new StringBuffer(); sb.append( "\n" ); @@ -152,9 +150,8 @@ } else { - for ( Iterator i = resolvedDependencies.iterator(); i.hasNext(); ) + for ( Artifact artifact : resolvedDependencies ) { - Artifact artifact = (Artifact) i.next(); String artifactFilename = null; if ( outputAbsoluteArtifactFilename ) { @@ -169,10 +166,10 @@ artifactFilename = null; } } - + String id = outputScope ? artifact.toString() : artifact.getId(); - - sb.append( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) +"\n"); + + sb.append( " " + id + ( outputAbsoluteArtifactFilename ? ":" + artifactFilename : "" ) + "\n" ); } } @@ -180,11 +177,11 @@ { sb.append( "\n" ); sb.append( "The following files were skipped:\n" ); - SortedSet sortedSkippedDependencies = new TreeSet(); - sortedSkippedDependencies.addAll( this.skippedDependencies ); - for ( Iterator i = sortedSkippedDependencies.iterator(); i.hasNext(); ) + Set skippedDependencies = new LinkedHashSet(); + skippedDependencies.addAll( this.skippedDependencies ); + for ( Artifact artifact : skippedDependencies ) { - sb.append( " " + ( (Artifact) i.next() ).getId()+"\n" ); + sb.append( " " + artifact.getId() + "\n" ); } } @@ -192,14 +189,14 @@ { sb.append( "\n" ); sb.append( "The following files have NOT been resolved:\n" ); - SortedSet sortedUnResolvedDependencies = new TreeSet(); - sortedUnResolvedDependencies.addAll( this.unResolvedDependencies ); - for ( Iterator i = sortedUnResolvedDependencies.iterator(); i.hasNext(); ) + Set unResolvedDependencies = new LinkedHashSet(); + unResolvedDependencies.addAll( this.unResolvedDependencies ); + for ( Artifact artifact : unResolvedDependencies ) { - sb.append( " " + ( (Artifact) i.next() ).getId()+"\n" ); + sb.append( " " + artifact.getId() + "\n" ); } } - sb.append("\n"); + sb.append( "\n" ); return sb.toString(); } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/DependencyUtil.java 2011-11-10 03:05:47.000000000 +0000 @@ -16,7 +16,7 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.BufferedReader; @@ -27,87 +27,94 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; +import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; /** * Utility class with static helper methods * * @author Brian Fox - * @version $Id: DependencyUtil.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DependencyUtil.java 1200108 2011-11-10 03:05:47Z carlos $ */ public final class DependencyUtil { /** + * Builds the file name. If removeVersion is set, then the file name must be reconstructed from the artifactId, + * Classifier (if used) and Type. Otherwise, this method returns the artifact file name. + * + * @param artifact File to be formatted. + * @param removeVersion Specifies if the version should be removed from the file name. + * @return Formatted file name in the format artifactId-[version]-[classifier].[type] + * @see {@link #getFormattedFileName(Artifact, boolean, boolean)}. + */ + public static String getFormattedFileName( Artifact artifact, boolean removeVersion ) + { + return getFormattedFileName( artifact, removeVersion, false ); + } + + /** * Builds the file name. If removeVersion is set, then the file name must be - * reconstructed from the artifactId, Classifier (if used) and Type. + * reconstructed from the groupId (if prependGroupId is true) artifactId, + * Classifier (if used) and Type. * Otherwise, this method returns the artifact file name. * * @param artifact * File to be formatted. * @param removeVersion * Specifies if the version should be removed from the file name. + * @param prependGroupId + * Specifies if the groupId should be prepended to the file name. * @return Formatted file name in the format - * artifactId-[version]-[classifier].[type] + * [groupId].artifactId-[version]-[classifier].[type] */ - public static String getFormattedFileName( Artifact artifact, boolean removeVersion ) + public static String getFormattedFileName( Artifact artifact, boolean removeVersion, boolean prependGroupId ) { - String destFileName = null; - - // if there is a file and we aren't stripping the version, just get the - // name directly - if ( artifact.getFile() != null && !removeVersion ) + StringBuffer destFileName = new StringBuffer(); + + if ( prependGroupId ) + { + destFileName.append( artifact.getGroupId() ).append( "." ); + } + + String versionString = null; + if ( !removeVersion ) { - destFileName = artifact.getFile().getName(); + versionString = "-" + artifact.getVersion(); } else - // if offline { - String versionString = null; - if ( !removeVersion ) - { - versionString = "-" + artifact.getVersion(); - } - else - { - versionString = ""; - } + versionString = ""; + } - String classifierString = ""; + String classifierString = ""; - if ( StringUtils.isNotEmpty( artifact.getClassifier() ) ) - { - classifierString = "-" + artifact.getClassifier(); - } - - destFileName = artifact.getArtifactId() + versionString + classifierString + "." - + artifact.getArtifactHandler().getExtension(); + if ( StringUtils.isNotEmpty( artifact.getClassifier() ) ) + { + classifierString = "-" + artifact.getClassifier(); } - return destFileName; + destFileName.append( artifact.getArtifactId() ).append( versionString ); + destFileName.append( classifierString ).append( "." ); + destFileName.append( artifact.getArtifactHandler().getExtension() ); + + return destFileName.toString(); } /** * Formats the outputDirectory based on type. * - * @param useSubdirsPerType - * if a new sub directory should be used for each type. - * @param useSubdirPerArtifact - * if a new sub directory should be used for each artifact. - * @param useRepositoryLayout - * if dependendies must be moved into a Maven repository layout, if - * set, other settings will be ignored. - * @param removeVersion - * if the version must not be mentioned in the filename - * @param outputDirectory - * base outputDirectory. - * @param artifact - * information about the artifact. - * + * @param useSubdirsPerType if a new sub directory should be used for each type. + * @param useSubdirPerArtifact if a new sub directory should be used for each artifact. + * @param useRepositoryLayout if dependencies must be moved into a Maven repository layout, if set, other settings + * will be ignored. + * @param removeVersion if the version must not be mentioned in the filename + * @param outputDirectory base outputDirectory. + * @param artifact information about the artifact. * @return a formatted File object to use for output. */ - public static File getFormattedOutputDirectory( boolean useSubdirsPerType, boolean useSubdirPerArtifact, - boolean useRepositoryLayout, boolean removeVersion, - File outputDirectory, Artifact artifact ) + public static File getFormattedOutputDirectory( boolean useSubdirsPerScope, boolean useSubdirsPerType, + boolean useSubdirPerArtifact, boolean useRepositoryLayout, + boolean removeVersion, File outputDirectory, Artifact artifact ) { StringBuffer sb = new StringBuffer( 128 ); if ( useRepositoryLayout ) @@ -121,6 +128,10 @@ } else { + if ( useSubdirsPerScope ) + { + sb.append( artifact.getScope() ).append( File.separatorChar ); + } if ( useSubdirsPerType ) { sb.append( artifact.getType() ).append( "s" ).append( File.separatorChar ); @@ -166,18 +177,16 @@ } return sb.toString(); } - + /** * Writes the specified string to the specified file. * - * @param string - * the string to write - * @param file - * the file to write to - * @throws IOException - * if an I/O error occurs + * @param string the string to write + * @param file the file to write to + * @throws IOException if an I/O error occurs */ - public synchronized static void write( String string, File file, Log log ) throws IOException + public static synchronized void write( String string, File file, boolean append, Log log ) + throws IOException { file.getParentFile().mkdirs(); @@ -185,35 +194,24 @@ try { - writer = new FileWriter( file ); + writer = new FileWriter( file, append ); writer.write( string ); } finally { - if ( writer != null ) - { - try - { - writer.close(); - } - catch ( IOException exception ) - { - log.error( "Cannot close file", exception ); - } - } + IOUtil.close( writer ); } } - + /** * Writes the specified string to the log at info level. * - * @param string - * the string to write - * @throws IOException - * if an I/O error occurs + * @param string the string to write + * @throws IOException if an I/O error occurs */ - public synchronized static void log( String string, Log log ) throws IOException + public static synchronized void log( String string, Log log ) + throws IOException { BufferedReader reader = new BufferedReader( new StringReader( string ) ); @@ -226,4 +224,27 @@ reader.close(); } + + // + // mainly used to parse excludes,includes configuration + // + public static String[] tokenizer( String str ) + { + return StringUtils.split( cleanToBeTokenizedString( str ), "," ); + } + + // + // clean up configuration string before it can be tokenized + // + public static String cleanToBeTokenizedString( String str ) + { + String ret = ""; + if ( !StringUtils.isEmpty( str ) ) + { + // remove initial and ending spaces, plus all spaces next to commas + ret = str.trim().replaceAll( "[\\s]*,[\\s]*", "," ); + } + + return ret; + } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactItemFilter.java 2010-11-06 12:21:39.000000000 +0000 @@ -19,16 +19,12 @@ * under the License. */ -/** - * - */ - import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; /** * @author Brian Fox - * @version $Id: ArtifactItemFilter.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ArtifactItemFilter.java 1032021 2010-11-06 12:21:39Z bentmann $ */ public interface ArtifactItemFilter { diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/DestFileFilter.java 2011-03-27 15:51:44.000000000 +0000 @@ -19,13 +19,8 @@ * under the License. */ -/** - * - */ - import java.io.File; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -37,28 +32,29 @@ /** * @author Brian Fox - * @version $Id: DestFileFilter.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DestFileFilter.java 1085967 2011-03-27 15:51:44Z hboutemy $ */ public class DestFileFilter extends AbstractArtifactsFilter implements ArtifactItemFilter { + private boolean overWriteReleases; - boolean overWriteReleases; + private boolean overWriteSnapshots; - boolean overWriteSnapshots; + private boolean overWriteIfNewer; - boolean overWriteIfNewer; + private boolean useSubDirectoryPerArtifact; - boolean useSubDirectoryPerArtifact; + private boolean useSubDirectoryPerType; - boolean useSubDirectoryPerType; + private boolean useSubDirectoryPerScope; - boolean useRepositoryLayout; + private boolean useRepositoryLayout; - boolean removeVersion; + private boolean removeVersion; - File outputFileDirectory; + private File outputFileDirectory; public DestFileFilter( File outputFileDirectory ) { @@ -68,11 +64,12 @@ overWriteSnapshots = false; useSubDirectoryPerArtifact = false; useSubDirectoryPerType = false; + useSubDirectoryPerScope = false; removeVersion = false; } public DestFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer, - boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType, + boolean useSubDirectoryPerArtifact, boolean useSubDirectoryPerType, boolean useSubDirectoryPerScope, boolean useRepositoryLayout, boolean removeVersion, File outputFileDirectory ) { this.overWriteReleases = overWriteReleases; @@ -80,6 +77,7 @@ this.overWriteIfNewer = overWriteIfNewer; this.useSubDirectoryPerArtifact = useSubDirectoryPerArtifact; this.useSubDirectoryPerType = useSubDirectoryPerType; + this.useSubDirectoryPerScope = useSubDirectoryPerScope; this.useRepositoryLayout = useRepositoryLayout; this.removeVersion = removeVersion; this.outputFileDirectory = outputFileDirectory; @@ -94,13 +92,11 @@ public Set filter( Set artifacts ) throws ArtifactFilterException { - Set result = new HashSet(); - - Iterator iter = artifacts.iterator(); + Set artifacts_ = artifacts; + Set result = new HashSet(); - while ( iter.hasNext() ) + for( Artifact artifact : artifacts_ ) { - Artifact artifact = (Artifact) iter.next(); if ( isArtifactIncluded( new ArtifactItem( artifact ) ) ) { result.add( artifact ); @@ -249,20 +245,16 @@ public boolean isArtifactIncluded( ArtifactItem item ) { - boolean overWrite = false; - boolean result = false; Artifact artifact = item.getArtifact(); - if ( ( artifact.isSnapshot() && this.overWriteSnapshots ) - || ( !artifact.isSnapshot() && this.overWriteReleases ) ) - { - overWrite = true; - } + boolean overWrite = + ( artifact.isSnapshot() && this.overWriteSnapshots ) + || ( !artifact.isSnapshot() && this.overWriteReleases ); File destFolder = item.getOutputDirectory(); if ( destFolder == null ) { - destFolder = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerType, + destFolder = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact, useRepositoryLayout, removeVersion, this.outputFileDirectory, artifact ); } @@ -277,12 +269,7 @@ destFile = new File( destFolder, item.getDestFileName() ); } - if ( overWrite - || ( !destFile.exists() || ( overWriteIfNewer && artifact.getFile().lastModified() > destFile - .lastModified() ) ) ) - { - result = true; - } - return result; + return overWrite || !destFile.exists() + || ( overWriteIfNewer && artifact.getFile().lastModified() > destFile.lastModified() ); } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/MarkerFileFilter.java 2011-03-27 15:51:44.000000000 +0000 @@ -16,15 +16,10 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. - */ - -/** - * + * under the License. */ import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -36,20 +31,20 @@ /** * @author Brian Fox - * @version $Id: MarkerFileFilter.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: MarkerFileFilter.java 1085967 2011-03-27 15:51:44Z hboutemy $ */ public class MarkerFileFilter extends AbstractArtifactsFilter implements ArtifactItemFilter { - boolean overWriteReleases; + private boolean overWriteReleases; - boolean overWriteSnapshots; + private boolean overWriteSnapshots; - boolean overWriteIfNewer; + private boolean overWriteIfNewer; - MarkerHandler handler; + protected final MarkerHandler handler; public MarkerFileFilter( boolean overWriteReleases, boolean overWriteSnapshots, boolean overWriteIfNewer, MarkerHandler handler ) @@ -62,20 +57,18 @@ /* * (non-Javadoc) - * + * * @see org.apache.mojo.dependency.utils.filters.ArtifactsFilter#filter(java.util.Set, * org.apache.maven.plugin.logging.Log) */ public Set filter( Set artifacts ) throws ArtifactFilterException { - Set result = new HashSet(); - - Iterator iter = artifacts.iterator(); - - while ( iter.hasNext() ) + Set artifacts_ = artifacts; + Set result = new HashSet(); + + for( Artifact artifact : artifacts_ ) { - Artifact artifact = (Artifact) iter.next(); if ( isArtifactIncluded( new ArtifactItem( artifact ) ) ) { result.add( artifact ); @@ -88,29 +81,20 @@ throws ArtifactFilterException { Artifact artifact = item.getArtifact(); - boolean overWrite = false; - boolean result = false; - if ( ( artifact.isSnapshot() && this.overWriteSnapshots ) - || ( !artifact.isSnapshot() && this.overWriteReleases ) ) - { - overWrite = true; - } + + boolean overWrite = ( artifact.isSnapshot() && this.overWriteSnapshots ) + || ( !artifact.isSnapshot() && this.overWriteReleases ); handler.setArtifact( artifact ); try { - if ( overWrite || ( !handler.isMarkerSet() || ( overWriteIfNewer && handler.isMarkerOlder( artifact ) ) ) ) - { - result = true; - } + return overWrite || !handler.isMarkerSet() || ( overWriteIfNewer && handler.isMarkerOlder( artifact ) ); } catch ( MojoExecutionException e ) { - throw new ArtifactFilterException (e.getMessage(),e); + throw new ArtifactFilterException( e.getMessage(), e ); } - - return result; } /** diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ResolveFileFilter.java 2011-03-27 15:51:44.000000000 +0000 @@ -19,10 +19,6 @@ * under the License. */ -/** - * - */ - import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugin.dependency.utils.markers.MarkerHandler; @@ -30,7 +26,7 @@ /** * @author Brian Fox - * @version $Id: ResolveFileFilter.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ResolveFileFilter.java 1085967 2011-03-27 15:51:44Z hboutemy $ */ public class ResolveFileFilter extends MarkerFileFilter @@ -41,7 +37,8 @@ super( true, true, true, handler ); } - public boolean isArtifactIncluded( ArtifactItem item ) throws ArtifactFilterException + public boolean isArtifactIncluded( ArtifactItem item ) + throws ArtifactFilterException { handler.setArtifact( item.getArtifact() ); try @@ -50,7 +47,7 @@ } catch ( MojoExecutionException e ) { - throw new ArtifactFilterException( e.getMessage(),e); + throw new ArtifactFilterException( e.getMessage(), e ); } } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/DefaultFileMarkerHandler.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/DefaultFileMarkerHandler.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/DefaultFileMarkerHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/DefaultFileMarkerHandler.java 2011-03-27 16:03:41.000000000 +0000 @@ -19,10 +19,6 @@ * under the License. */ -/** - * - */ - import java.io.File; import java.io.IOException; @@ -31,7 +27,7 @@ /** * @author Brian Fox - * @version $Id: DefaultFileMarkerHandler.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DefaultFileMarkerHandler.java 1085975 2011-03-27 16:03:41Z hboutemy $ */ public class DefaultFileMarkerHandler implements MarkerHandler @@ -83,15 +79,23 @@ public boolean isMarkerOlder( Artifact artifact1 ) throws MojoExecutionException { + // temporary debug to find out why this intermittent failure on Sonatype grid Windows + System.out.println( "> isMarkerOlder:" ); File marker = getMarkerFile(); + System.out.println( " artifact1 = " + artifact1.getFile().getPath() ); + System.out.println( " marker = " + marker.getPath() ); if ( marker.exists() ) { + System.out.println( " artifact1 lastModified: " + artifact1.getFile().lastModified() ); + System.out.println( " marker lastModified: " + marker.lastModified() ); + System.out.println( "< " + ( artifact1.getFile().lastModified() > marker.lastModified() ) + " = marker older than artifact?" ); return artifact1.getFile().lastModified() > marker.lastModified(); } else { + System.out.println( "< true : marker does not exist" ); // if the marker doesn't exist, we want to copy so assume it is - // infinately older + // infinitely older return true; } } @@ -117,7 +121,25 @@ { throw new MojoExecutionException( "Unable to create Marker: " + marker.getAbsolutePath(), e ); } - + + // update marker file timestamp + try + { + long ts; + if ( this.artifact != null && this.artifact.getFile() != null ) + { + ts = this.artifact.getFile().lastModified(); + } + else + { + ts = System.currentTimeMillis(); + } + marker.setLastModified( ts ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Unable to update Marker timestamp: " + marker.getAbsolutePath(), e ); + } } /** diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/MarkerHandler.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/MarkerHandler.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/MarkerHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/MarkerHandler.java 2010-11-06 12:21:39.000000000 +0000 @@ -19,16 +19,12 @@ * under the License. */ -/** - * - */ - import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; /** * @author Brian Fox - * @version $Id: MarkerHandler.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: MarkerHandler.java 1032021 2010-11-06 12:21:39Z bentmann $ */ public interface MarkerHandler { diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/SourcesFileMarkerHandler.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/SourcesFileMarkerHandler.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/SourcesFileMarkerHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/SourcesFileMarkerHandler.java 2011-03-26 18:13:19.000000000 +0000 @@ -19,10 +19,6 @@ * under the License. */ -/** - * - */ - import java.io.File; import java.io.IOException; @@ -31,7 +27,7 @@ /** * @author Brian Fox - * @version $Id: SourcesFileMarkerHandler.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: SourcesFileMarkerHandler.java 1085777 2011-03-26 18:13:19Z hboutemy $ */ public class SourcesFileMarkerHandler extends DefaultFileMarkerHandler @@ -122,7 +118,7 @@ else { // if the marker doesn't exist, we want to copy so assume it is - // infinately older + // infinitely older return true; } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/markers/UnpackFileMarkerHandler.java 2010-03-13 16:34:09.000000000 +0000 @@ -16,7 +16,7 @@ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ import java.io.File; @@ -26,70 +26,70 @@ /** * @author Damian Bradicich - * @version $Id: UnpackFileMarkerHandler.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: UnpackFileMarkerHandler.java 922597 2010-03-13 16:34:09Z hboutemy $ */ -public class UnpackFileMarkerHandler extends DefaultFileMarkerHandler +public class UnpackFileMarkerHandler extends DefaultFileMarkerHandler { - protected ArtifactItem artifactItem; - - public UnpackFileMarkerHandler( File markerFilesDirectory ) + protected ArtifactItem artifactItem; + + public UnpackFileMarkerHandler( File markerFilesDirectory ) { super( markerFilesDirectory ); } - - public UnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory ) - { - this( markerFilesDirectory ); - setArtifactItem( artifactItem ); - } - - protected File getMarkerFile() - { - /** - * Build a hash of all include/exclude strings, to determine - * if an artifactItem has been unpacked using the include/exclude - * parameters, this will allow an artifact to be included multiple - * times with different include/exclude parameters - */ - File markerFile = null; - if ( this.artifactItem == null - || ( StringUtils.isEmpty( this.artifactItem.getIncludes() ) - && StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) ) - { - markerFile = super.getMarkerFile(); - } - else - { - int includeExcludeHash = 0; - - if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) ) - { - includeExcludeHash += this.artifactItem.getIncludes().hashCode(); - } - - if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) ) - { - includeExcludeHash += this.artifactItem.getExcludes().hashCode(); - } - - markerFile = new File( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash ); - } - - return markerFile; - } - - public void setArtifactItem( ArtifactItem artifactItem ) - { - this.artifactItem = artifactItem; - - if (this.artifactItem != null) - { - setArtifact( this.artifactItem.getArtifact() ); - } - } - - public ArtifactItem getArtifactItem( ) - { - return this.artifactItem; - } + + public UnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory ) + { + this( markerFilesDirectory ); + setArtifactItem( artifactItem ); + } + + protected File getMarkerFile() + { + /** + * Build a hash of all include/exclude strings, to determine + * if an artifactItem has been unpacked using the include/exclude + * parameters, this will allow an artifact to be included multiple + * times with different include/exclude parameters + */ + File markerFile = null; + if ( this.artifactItem == null + || ( StringUtils.isEmpty( this.artifactItem.getIncludes() ) + && StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) ) + { + markerFile = super.getMarkerFile(); + } + else + { + int includeExcludeHash = 0; + + if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) ) + { + includeExcludeHash += this.artifactItem.getIncludes().hashCode(); + } + + if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) ) + { + includeExcludeHash += this.artifactItem.getExcludes().hashCode(); + } + + markerFile = new File( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash ); + } + + return markerFile; + } + + public void setArtifactItem( ArtifactItem artifactItem ) + { + this.artifactItem = artifactItem; + + if ( this.artifactItem != null ) + { + setArtifact( this.artifactItem.getArtifact() ); + } + } + + public ArtifactItem getArtifactItem( ) + { + return this.artifactItem; + } } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/ArtifactsResolver.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/ArtifactsResolver.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/ArtifactsResolver.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/ArtifactsResolver.java 2011-03-13 00:17:39.000000000 +0000 @@ -19,21 +19,18 @@ * under the License. */ -/** - * - */ - import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; /** * @author Brian Fox - * @version $Id: ArtifactsResolver.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ArtifactsResolver.java 1081021 2011-03-13 00:17:39Z hboutemy $ */ public interface ArtifactsResolver { - Set resolve( Set artifacts, Log log ) + Set resolve( Set artifacts, Log log ) throws MojoExecutionException; } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java 2011-03-26 18:13:19.000000000 +0000 @@ -19,13 +19,7 @@ * under the License. */ -/** - * - * - */ - import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -39,7 +33,7 @@ /** * @author Brian Fox - * @version $Id: DefaultArtifactsResolver.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DefaultArtifactsResolver.java 1085777 2011-03-26 18:13:19Z hboutemy $ */ public class DefaultArtifactsResolver implements ArtifactsResolver @@ -48,12 +42,12 @@ ArtifactRepository local; - List remoteRepositories; + List remoteRepositories; boolean stopOnFailure; public DefaultArtifactsResolver( ArtifactResolver theResolver, ArtifactRepository theLocal, - List theRemoteRepositories, boolean theStopOnFailure ) + List theRemoteRepositories, boolean theStopOnFailure ) { this.resolver = theResolver; this.local = theLocal; @@ -67,15 +61,13 @@ * @see org.apache.mojo.dependency.utils.resolvers.ArtifactsResolver#resolve(java.util.Set, * org.apache.maven.plugin.logging.Log) */ - public Set resolve( Set artifacts, Log log ) + public Set resolve( Set artifacts, Log log ) throws MojoExecutionException { - Set resolvedArtifacts = new HashSet(); - Iterator iter = artifacts.iterator(); - while ( iter.hasNext() ) + Set resolvedArtifacts = new HashSet(); + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iter.next(); try { resolver.resolve( artifact, remoteRepositories, local ); diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ArtifactTranslator.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ArtifactTranslator.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ArtifactTranslator.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ArtifactTranslator.java 2011-03-13 00:17:39.000000000 +0000 @@ -19,20 +19,16 @@ * under the License. */ -/** - * - * - */ - import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; /** * @author Brian Fox - * @version $Id: ArtifactTranslator.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ArtifactTranslator.java 1081021 2011-03-13 00:17:39Z hboutemy $ */ public interface ArtifactTranslator { - Set translate( Set artifacts, Log log ); + Set translate( Set artifacts, Log log ); } diff -Nru maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java --- maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java 2011-03-13 00:17:39.000000000 +0000 @@ -19,12 +19,7 @@ * under the License. */ -/** - * - */ - import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.apache.maven.artifact.Artifact; @@ -34,7 +29,7 @@ /** * @author Brian Fox - * @version $Id: ClassifierTypeTranslator.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: ClassifierTypeTranslator.java 1081021 2011-03-13 00:17:39Z hboutemy $ */ public class ClassifierTypeTranslator implements ArtifactTranslator @@ -59,16 +54,14 @@ * @see org.apache.mojo.dependency.utils.translators.ArtifactTranslator#translate(java.util.Set, * org.apache.maven.plugin.logging.Log) */ - public Set translate( Set artifacts, Log log ) + public Set translate( Set artifacts, Log log ) { - Set results = artifacts; + Set results = artifacts; log.debug( "Translating Artifacts using Classifier: " + this.classifier + " and Type: " + this.type ); - results = new HashSet(); - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + results = new HashSet(); + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) i.next(); - // this translator must pass both type and classifier here so we // will use the // base artifact value if null comes in diff -Nru maven-dependency-plugin-2.1/src/main/resources/META-INF/plexus/components.xml maven-dependency-plugin-2.4/src/main/resources/META-INF/plexus/components.xml --- maven-dependency-plugin-2.1/src/main/resources/META-INF/plexus/components.xml 2008-11-03 23:16:50.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/resources/META-INF/plexus/components.xml 2009-04-08 21:35:18.000000000 +0000 @@ -1,6 +1,24 @@ - - + + + org.codehaus.plexus.archiver.UnArchiver zip @@ -34,21 +52,21 @@ org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + org.codehaus.plexus.archiver.UnArchiver nar org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + org.codehaus.plexus.archiver.UnArchiver esb org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + org.codehaus.plexus.archiver.UnArchiver sar @@ -62,14 +80,14 @@ org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + org.codehaus.plexus.archiver.UnArchiver par org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + org.codehaus.plexus.archiver.UnArchiver rar @@ -77,6 +95,6 @@ org.codehaus.plexus.archiver.zip.ZipUnArchiver per-lookup - + diff -Nru maven-dependency-plugin-2.1/src/main/resources/analyze-report.properties maven-dependency-plugin-2.4/src/main/resources/analyze-report.properties --- maven-dependency-plugin-2.1/src/main/resources/analyze-report.properties 2008-01-15 22:55:37.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/resources/analyze-report.properties 2009-04-08 21:35:18.000000000 +0000 @@ -1,18 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at # -# Copyright 2001-2006 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. analyze.report.name=Dependency Analysis analyze.report.description=Dependency analysis of the project (used declared, used undeclared, unused declared) diff -Nru maven-dependency-plugin-2.1/src/main/resources/analyze-report_de.properties maven-dependency-plugin-2.4/src/main/resources/analyze-report_de.properties --- maven-dependency-plugin-2.1/src/main/resources/analyze-report_de.properties 2008-01-15 22:55:37.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/resources/analyze-report_de.properties 2009-04-08 21:35:18.000000000 +0000 @@ -1,18 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at # -# Copyright 2001-2006 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. analyze.report.name=Abhängigkeitsanalyse analyze.report.description=Eine Analysebericht der Projektabhängigkeiten (verwendet und deklariert, verwendet aber nicht deklariert, unverwendet aber deklariert) diff -Nru maven-dependency-plugin-2.1/src/main/resources/analyze-report_pt_BR.properties maven-dependency-plugin-2.4/src/main/resources/analyze-report_pt_BR.properties --- maven-dependency-plugin-2.1/src/main/resources/analyze-report_pt_BR.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/resources/analyze-report_pt_BR.properties 2011-06-21 13:02:10.000000000 +0000 @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +analyze.report.name=An\u00e1lise de Depend\u00eancias +analyze.report.description=An\u00e1lise de Depend\u00eancias do projeto (usadas e declaradas, usadas e n\u00e3o declaradas, n\u00e3o usadas e declaradas) +analyze.report.header=Relat\u00f3rio de Depend\u00eancias +analyze.report.mainTitle=An\u00e1lise de Depend\u00eancias +analyze.report.noDependency=Nenhuma +analyze.report.UsedDeclaredDependencies=Depend\u00eancias usadas e declaradas +analyze.report.UsedUndeclaredDependencies=Depend\u00eancias usadas mas n\u00e3o declaradas +analyze.report.UnusedDeclaredDependencies=Depend\u00eancias n\u00e3o usadas mas declaradas diff -Nru maven-dependency-plugin-2.1/src/main/resources/analyze-report_sv.properties maven-dependency-plugin-2.4/src/main/resources/analyze-report_sv.properties --- maven-dependency-plugin-2.1/src/main/resources/analyze-report_sv.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/main/resources/analyze-report_sv.properties 2010-01-05 14:52:16.000000000 +0000 @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +analyze.report.name=Beroendeanalys +analyze.report.description=Beroendeanalys av projektet (anv\u00e4nda deklarerade, anv\u00e4nda odeklarerade, oanv\u00e4nda deklarerade) +analyze.report.header=Beroenderapport +analyze.report.mainTitle=Beroendeanalys +analyze.report.noDependency=Inga +analyze.report.UsedDeclaredDependencies=Anv\u00e4nda och deklarerade beroenden +analyze.report.UsedUndeclaredDependencies=Anv\u00e4nda men odeklarerade beroenden +analyze.report.UnusedDeclaredDependencies=Oanv\u00e4nda men deklarerade beroenden diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/copying-artifacts.apt maven-dependency-plugin-2.4/src/site/apt/examples/copying-artifacts.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/copying-artifacts.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/copying-artifacts.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Copying specific artifacts - ------ - Allan Ramirez - Brian Fox - ------ - Mar 2007 - ------ - -Copying specific artifacts - - In copying specific artifacts, you need to bind the <<>> - mojo to a lifecycle, configure the plugin and specify the artifacts you - want to copy. See the following example: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - package - - copy - - - - - junit - junit - 3.8.1 - jar - false - ${project.build.directory}/alternateLocation - optional-new-name.jar - - - ${project.build.directory}/wars - false - true - - - - - - - [...] - -+---+ - - Then after executing <<>> the artifact (junit) is copied to the - given alternateLocation. - - The <<>> goal can also be used to copy the just built - artifact to a custom location if desired. It must be bound after the - install phase so that the artifact exists in the repository. The following - configuration shows how: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-installed - install - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - - - some-other-place - - - - - - - [...] - -+---+ - -{Copying from the command line}: - - If you intend to configure this mojo for execution on the command line using: - -+---+ -mvn dependency:copy -+---+ - - you must not put the configuration inside the tag. Your configuration should look like this: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - [ groupId ] - [ artifactId ] - [ version ] - [ packaging ] - [ true or false ] - [ output directory ] - [ filename ] - - - - - - - - [...] - -+---+ diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/copying-artifacts.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/copying-artifacts.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/copying-artifacts.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/copying-artifacts.apt.vm 2011-07-05 12:54:20.000000000 +0000 @@ -0,0 +1,265 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Copying specific artifacts + ------ + Allan Ramirez + Brian Fox + Stephen Connolly + ------ + Jul 2011 + ------ + +Copying specific artifacts + + In copying specific artifacts, you need to bind the <<>> + mojo to a lifecycle, configure the plugin and specify the artifacts you + want to copy. See the following example: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy + package + + copy + + + + + junit + junit + 3.8.1 + jar + false + \${project.build.directory}/alternateLocation + optional-new-name.jar + + + \${project.build.directory}/wars + false + true + + + + + + + [...] + ++---+ + + Then after executing <<>> the artifact (junit) is copied to the + given alternateLocation. + + Artifacts are resolved from the following sources in order: + + * The current reactor, + + * The local repository, + + * The configured remote repositories. + + [] + + If the artifact cannot be resolved from the above sources then the build + + If the artifact is also listed as a dependency, the <<>> of the <<>> will default to + the version from the <<>> or <<>>, e.g. + ++---+ + + [...] + + + junit + junit + 3.8.1 + test + + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy + package + + copy + + + + + junit + junit + false + \${project.build.directory}/alternateLocation + optional-new-name.jar + + + \${project.build.directory}/wars + false + true + + + + + + + [...] + ++---+ + + The <<>> goal can also be used to copy the just built + artifact to a custom location if desired. It must be bound after the + to any phase after the package phase so that the artifact exists in the + repository. The following configuration shows how (binding to the + install phase in this case): + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy-installed + install + + copy + + + + + \${project.groupId} + \${project.artifactId} + \${project.version} + \${project.packaging} + + + some-other-place + + + + + + + [...] + ++---+ + +{Using an alternate local repository}: + + <> always downloads artifacts to default local repository first, and then + copy the artifacts to the desired locations. For large size unique snapshot artifacts, the downloads can quickly + fill up default local repository, and therefore local disk, after many executions. + To clean up the downloaded artifacts as part the build, set 's value + to a location in your project's target directory. + + This use case also applies to <> goal. + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy-with-alternalte-repo + install + + copy + + + + + [...] + + [...] + + \${project.build.directory}/localrepo + + + + + + + [...] + ++---+ + +{Copying from the command line}: + + If you intend to configure this mojo for execution on the command line using: + ++---+ +mvn dependency:copy ++---+ + + you must not put the configuration inside the tag. Your configuration should look like this: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + + [ groupId ] + [ artifactId ] + [ version ] + [ packaging ] + [ true or false ] + [ output directory ] + [ filename ] + + + + + + + + [...] + ++---+ diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/copying-project-dependencies.apt maven-dependency-plugin-2.4/src/site/apt/examples/copying-project-dependencies.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/copying-project-dependencies.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/copying-project-dependencies.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Copying project dependencies - ------ - Allan Ramirez - Brian Fox - ------ - Nov 2006 - ------ - -Copying project dependencies - - Project dependencies are the dependencies declared in your pom. To copy them with their transitive dependencies, use the - <<>> mojo and configure the plugin like - the sample below: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/alternateLocation - false - false - true - - - - - - - [...] - -+---+ - -* Excluding transitive dependencies - - As mentioned, {{{http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html}transitive dependencies}} are copied by default. However, they - can also be excluded by setting the <<>> property to - <>. - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/alternateLocation - false - true - true - - - - - - - [...] - -+---+ \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/copying-project-dependencies.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/copying-project-dependencies.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/copying-project-dependencies.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/copying-project-dependencies.apt.vm 2009-08-05 13:09:01.000000000 +0000 @@ -0,0 +1,99 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Copying project dependencies + ------ + Allan Ramirez + Brian Fox + ------ + Nov 2006 + ------ + +Copying project dependencies + + Project dependencies are the dependencies declared in your pom. To copy them with their transitive dependencies, use the + <<>> mojo and configure the plugin like + the sample below: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy-dependencies + package + + copy-dependencies + + + \${project.build.directory}/alternateLocation + false + false + true + + + + + + + [...] + ++---+ + +* Excluding transitive dependencies + + As mentioned, {{{http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html}transitive dependencies}} are copied by default. However, they + can also be excluded by setting the <<>> property to + <>. + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy-dependencies + package + + copy-dependencies + + + \${project.build.directory}/alternateLocation + false + true + true + + + + + + + [...] + ++---+ \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt maven-dependency-plugin-2.4/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt 2007-09-21 16:01:53.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Failing the build on dependency analysis warnings - ------ - Mark Hobson - ------ - Sep 2007 - ------ - -Failing the build on dependency analysis warnings - - A project's dependencies can be analyzed as part of the build process by binding the <<>> - goal to the lifecycle. By default, the analysis will be performed during the <<>> lifecycle phase. The - plugin can then be configured to fail the build if any dependency analysis warnings are encountered by setting the - <<>> parameter. See the following POM configuration for an example: - -+---+ - - ... - - - - org.apache.maven.plugins - maven-dependency-plugin - - - analyze - - analyze-only - - - true - - - - - - - ... - -+---+ - - Note that the <<>> goal is used in preference to <<>> since it doesn't - force a further compilation of the project, but uses the compiled classes produced from the earlier - <<>> phase in the lifecycle. - - The project's dependencies will then be automatically analyzed during the <<>> lifecycle phase, which can be - executed explicitly as follows: - -+---+ -mvn verify -+---+ diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/failing-the-build-on-dependency-analysis-warnings.apt.vm 2009-08-05 13:09:01.000000000 +0000 @@ -0,0 +1,69 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Failing the build on dependency analysis warnings + ------ + Mark Hobson + ------ + Sep 2007 + ------ + +Failing the build on dependency analysis warnings + + A project's dependencies can be analyzed as part of the build process by binding the <<>> + goal to the lifecycle. By default, the analysis will be performed during the <<>> lifecycle phase. The + plugin can then be configured to fail the build if any dependency analysis warnings are encountered by setting the + <<>> parameter. See the following POM configuration for an example: + ++---+ + + ... + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + analyze + + analyze-only + + + true + + + + + + + ... + ++---+ + + Note that the <<>> goal is used in preference to <<>> since it doesn't + force a further compilation of the project, but uses the compiled classes produced from the earlier + <<>> phase in the lifecycle. + + The project's dependencies will then be automatically analyzed during the <<>> lifecycle phase, which can be + executed explicitly as follows: + ++---+ +mvn verify ++---+ diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/preparing-dependencies.apt maven-dependency-plugin-2.4/src/site/apt/examples/preparing-dependencies.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/preparing-dependencies.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/preparing-dependencies.apt 2009-12-30 08:06:02.000000000 +0000 @@ -13,8 +13,8 @@ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations -~~ under the License. - +~~ under the License. + ------ Fixing Dependency Problems ------ @@ -24,9 +24,9 @@ ------ How to prepare your dependencies before updating to Maven 2.0.6: - + If you have dependencies in dependencyManagement that conflict with transitive dependencies, the fix for MNG-1577 may alter the version you get when running a build with 2.0.6. To ensure a smooth transition, there is a tool to detect these conditions. - + In your project, run "mvn dependency:analyze" (be sure to use 2.0.5 or the plugin won't detect mismatches) This will display output similar to below: +---+ @@ -58,7 +58,7 @@ [INFO] DepMgt : 2.3 [INFO] Resolved: 2.4 [WARNING] Potential problems found in Dependency Management -+---+ ++---+ In the sample above, you can see that I am actually getting versions different than what I'm asking for. In 2.0.6, I would suddenly be downgraded to commons-lang 1.0 from 2.3, commons-digester 1.6 from 1.7 and servlet-api 2.3 from 2.4. Depending on the jars and your project, this may manifest as compile errors or runtime errors. When you see these mismatches, the suggested approach is to adjust your dependencyManagement section to have the version you are actually getting (in this case, 2.3,1.7 and 2.4 respectively). Then when you upgrade to 2.0.6, you will be getting the same versions in your build that you currently get in 2.0.5. @@ -71,13 +71,11 @@ After upgrading to 2.0.6, you may want to remove workarounds to MNG-1577 that you have put in place. These usually would have been the introduction of a dependency to your pom that wasn't nessessary simply to override a transitive version. If you have workarounds in your pom, they will show up as Unused declared dependencies. Note that currently the test and runtime dependencies are excluded from the usage analysis. Read more here: - - * {{{analyze-mojo.html}Analyze Mojo}} - * {{{analyze-dep-mgt-mojo.html}Analyze-dep-mgt Mojo}} + * {{{../analyze-mojo.html}Analyze Mojo}} - * {{{usage.html}Usage}} - - [] + * {{{../analyze-dep-mgt-mojo.html}Analyze-dep-mgt Mojo}} + * {{{../usage.html}Usage}} + [] diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-artifacts.apt maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-artifacts.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-artifacts.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-artifacts.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Unpacking specific artifacts - ------ - Allan Ramirez - Brian Fox - ------ - Nov 2006 - ------ - -Unpacking specific artifacts - - This is pretty similar to the {{{copying-artifacts.html}Copying Specific Artifacts}} - example. The difference is that instead of copying the artifacts, they are unpacked. - To unpack the copied artifacts, use the <<>> mojo and - configure the plugin into something like the sample below: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack - package - - unpack - - - - - junit - junit - 3.8.1 - jar - false - ${project.build.directory}/alternateLocation - optional-new-name.jar - **/*.class,**/*.xml - **/*test.class - - - **/*.java - **/*.properties - ${project.build.directory}/wars - false - true - - - - - - - [...] - -+---+ - - And after invoking <<>>, the artifacts are unpacked. Because checking the existence of an unpacked archive - is difficult to do reliably, marker files are used instead. The location of the marker files is controlled by the {{{unpack-dependencies-mojo.html#markersDirectory}markersDirectory}} parameter. - -{Unpacking from the command line}: - - If you intend to configure this mojo for execution on the command line using: - -+---+ -mvn dependency:unpack -+---+ - - you must not put the configuration inside the tag. Your configuration should look like this: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - [ groupId ] - [ artifactId ] - [ version ] - [ packaging ] - [classifier - optional] - [ true or false ] - [ output directory ] - [ filename ] - [ comma separated list of file filters ] - [ comma separated list of file filters ] - - - - - - - - [...] - -+---+ - - - - - - diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-artifacts.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-artifacts.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-artifacts.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-artifacts.apt.vm 2009-08-05 13:09:01.000000000 +0000 @@ -0,0 +1,129 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Unpacking specific artifacts + ------ + Allan Ramirez + Brian Fox + ------ + Nov 2006 + ------ + +Unpacking specific artifacts + + This is pretty similar to the {{{copying-artifacts.html}Copying Specific Artifacts}} + example. The difference is that instead of copying the artifacts, they are unpacked. + To unpack the copied artifacts, use the <<>> mojo and + configure the plugin into something like the sample below: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + unpack + package + + unpack + + + + + junit + junit + 3.8.1 + jar + false + \${project.build.directory}/alternateLocation + optional-new-name.jar + **/*.class,**/*.xml + **/*test.class + + + **/*.java + **/*.properties + \${project.build.directory}/wars + false + true + + + + + + + [...] + ++---+ + + And after invoking <<>>, the artifacts are unpacked. Because checking the existence of an unpacked archive + is difficult to do reliably, marker files are used instead. The location of the marker files is controlled by the {{{unpack-dependencies-mojo.html#markersDirectory}markersDirectory}} parameter. + +{Unpacking from the command line}: + + If you intend to configure this mojo for execution on the command line using: + ++---+ +mvn dependency:unpack ++---+ + + you must not put the configuration inside the tag. Your configuration should look like this: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + + [ groupId ] + [ artifactId ] + [ version ] + [ packaging ] + [classifier - optional] + [ true or false ] + [ output directory ] + [ filename ] + [ comma separated list of file filters ] + [ comma separated list of file filters ] + + + + + + + + [...] + ++---+ + + + + + + diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-project-dependencies.apt maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-project-dependencies.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-project-dependencies.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-project-dependencies.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Unpacking project dependencies - ------ - Allan Ramirez - Brian Fox - ------ - Nov 2006 - ------ - -Unpacking project dependencies - - This is pretty similar to the {{{copying-project-dependencies.html}Copying direct dependencies}} - example. The difference is that the direct dependencies are unpacked, - including the transitive dependencies. To unpack the artifacts, use the - <<>> mojo and configure the dependency plugin - to something like the sample below: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack-dependencies - package - - unpack-dependencies - - - **/*.class - **/*.properties - ${project.build.directory}/alternateLocation - false - true - - - - - - - [...] - -+---+ - - - - diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-project-dependencies.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-project-dependencies.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/unpacking-project-dependencies.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/unpacking-project-dependencies.apt.vm 2009-08-05 13:09:01.000000000 +0000 @@ -0,0 +1,69 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Unpacking project dependencies + ------ + Allan Ramirez + Brian Fox + ------ + Nov 2006 + ------ + +Unpacking project dependencies + + This is pretty similar to the {{{copying-project-dependencies.html}Copying direct dependencies}} + example. The difference is that the direct dependencies are unpacked, + including the transitive dependencies. To unpack the artifacts, use the + <<>> mojo and configure the dependency plugin + to something like the sample below: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + unpack-dependencies + package + + unpack-dependencies + + + **/*.class + **/*.properties + \${project.build.directory}/alternateLocation + false + true + + + + + + + [...] + ++---+ + + + + diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/using-dependencies-sources.apt maven-dependency-plugin-2.4/src/site/apt/examples/using-dependencies-sources.apt --- maven-dependency-plugin-2.1/src/site/apt/examples/using-dependencies-sources.apt 2008-08-05 11:27:25.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/using-dependencies-sources.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Unpacking project dependencies - ------ - Carlos Sanchez - ------ - Oct 2007 - ------ - -Using project dependencies' sources - - This is pretty similar to the {{{copying-project-dependencies.html}Copying project dependencies}} - or {{{unpacking-project-dependencies.html}Unpacking project dependencies}} - examples. - - Instead of using the project dependencies it uses their sources. Use the goal - <<>> to just copy the sources jars to a directory or - <<>> to extract them. - See the sample below: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - src-dependencies - package - - - unpack-dependencies - - - sources - false - ${project.build.directory}/sources - - - - - - - [...] - -+---+ - - - - diff -Nru maven-dependency-plugin-2.1/src/site/apt/examples/using-dependencies-sources.apt.vm maven-dependency-plugin-2.4/src/site/apt/examples/using-dependencies-sources.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/examples/using-dependencies-sources.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/examples/using-dependencies-sources.apt.vm 2009-08-05 13:09:01.000000000 +0000 @@ -0,0 +1,70 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Unpacking project dependencies + ------ + Carlos Sanchez + ------ + Oct 2007 + ------ + +Using project dependencies' sources + + This is pretty similar to the {{{copying-project-dependencies.html}Copying project dependencies}} + or {{{unpacking-project-dependencies.html}Unpacking project dependencies}} + examples. + + Instead of using the project dependencies it uses their sources. Use the goal + <<>> to just copy the sources jars to a directory or + <<>> to extract them. + See the sample below: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + src-dependencies + package + + + unpack-dependencies + + + sources + false + \${project.build.directory}/sources + + + + + + + [...] + ++---+ + + + + diff -Nru maven-dependency-plugin-2.1/src/site/apt/index.apt maven-dependency-plugin-2.4/src/site/apt/index.apt --- maven-dependency-plugin-2.1/src/site/apt/index.apt 2008-08-29 13:27:05.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/index.apt 2011-07-05 12:54:20.000000000 +0000 @@ -13,15 +13,15 @@ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations -~~ under the License. - +~~ under the License. + ------ Introduction ------ Allan Ramirez Brian Fox ------ - Mar 2007 + 2009-04-08 ------ Maven Dependency Plugin @@ -34,87 +34,95 @@ The Dependency plugin has several goals: - *{{{copy-mojo.html}dependency:copy}} takes a list of artifacts defined in - the plugin configuration section and copies them to a specified location, - renaming them or stripping the version if desired. This goal can resolve - the artifacts from remote repositories if they don't exist in local. - - *{{{copy-dependencies-mojo.html}dependency:copy-dependencies}} takes the - list of project direct dependencies and optionally transitive dependencies and - copies them to a specified location, stripping the version if desired. + *{{{./analyze-mojo.html}dependency:analyze}} analyzes the dependencies of this project and determines which are: used + and declared; used and undeclared; unused and declared. + + *{{{./analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes your projects dependencies and lists mismatches + between resolved dependencies and those listed in your dependencyManagement section. + + *{{{./analyze-only-mojo.html}dependency:analyze-only}} is the same as analyze, but is meant to be bound in a pom. It + does not fork the build and execute test-compile. + + *{{{./analyze-report-mojo.html}dependency:analyze-report}} analyzes the dependencies of this project and produces a report + that summarises which are: used and declared; used and undeclared; unused and declared. + + *{{{./analyze-duplicate-mojo.html}dependency:analyze-duplicate}} analyzes the and + tags in the pom.xml and determines the duplicate declared dependencies. + + *{{{./build-classpath-mojo.html}dependency:build-classpath}} tells + Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. + The classpath file may also be attached and installed/deployed along with the main artifact. + + *{{{./copy-mojo.html}dependency:copy}} takes a list of artifacts defined in the plugin configuration section and + copies them to a specified location, renaming them or stripping the version if desired. This goal can resolve + the artifacts from remote repositories if they don't exist in either the local repository or the reactor. + + *{{{./copy-dependencies-mojo.html}dependency:copy-dependencies}} takes the list of project direct dependencies and + optionally transitive dependencies and copies them to a specified location, stripping the version if desired. This goal can also be run from the command line. - *{{{unpack-mojo.html}dependency:unpack}} like copy but unpacks. + *{{{./get-mojo.html}dependency:get}} downloads a single artifact transitively from a specified remote repository. - *{{{unpack-dependencies-mojo.html}dependency:unpack-dependencies}} like - copy-dependencies but unpacks. + *{{{./go-offline-mojo.html}dependency:go-offline}} tells Maven to resolve everything this project is dependent on + (dependencies, plugins, reports) in preparation for going offline. + + *{{{./list-mojo.html}dependency:list}} alias for resolve that lists the dependencies for this project. - *{{{resolve-mojo.html}dependency:resolve}} tells Maven to resolve all dependencies and displays the version. - - *{{{resolve-mojo.html}dependency:list}} is an alias for dependency:resolve + *{{{./properties-mojo.html}dependency:properties}} set a property for each project dependency containing the + to the artifact on the file system. - *{{{sources-mojo.html}dependency:sources}} tells Maven to resolve all dependencies and their source attachments, and displays the version. + *{{{./purge-local-repository-mojo.html}dependency:purge-local-repository}} tells Maven to clear all dependency-artifact + files out of the local repository, and optionally re-resolve them. - *{{{resolve-plugins-mojo.html}dependency:resolve-plugins}} Tells Maven to - resolve plugins and their dependencies. + *{{{./resolve-mojo.html}dependency:resolve}} tells Maven to resolve all dependencies and displays the version. - *{{{list-mojo.html}dependency:list}} alias for resolve that lists the dependencies for this project. + *{{{./resolve-plugins-mojo.html}dependency:resolve-plugins}} Tells Maven to resolve plugins and their dependencies. - *{{{go-offline-mojo.html}dependency:go-offline}} tells Maven to resolve - everything this project is dependent on (dependencies, plugins, reports) - in preparation for going offline. + *{{{./sources-mojo.html}dependency:sources}} tells Maven to resolve all dependencies and their source attachments, + and displays the version. - *{{{purge-local-repository-mojo.html}dependency:purge-local-repository}} tells - Maven to clear all dependency-artifact files out of the local repository, - and optionally re-resolve them. + *{{{./tree-mojo.html}dependency:tree}} displays the dependency tree for this project. - *{{{build-classpath-mojo.html}dependency:build-classpath}} tells - Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. The - classpath file may also be attached and installed/deployed along with the main artifact. + *{{{./unpack-mojo.html}dependency:unpack}} like copy but unpacks. - *{{{analyze-mojo.html}dependency:analyze}} analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared. - - *{{{analyze-only-mojo.html}dependency:analyze-only}} is the same as analyze, but is meant to be bound in a pom. It does not fork the build and execute test-compile. - - *{{{analyze-dep-mgt-mojo.html}dependency:analyze-dep-mgt}} analyzes your projects dependencies and lists mismatches between resolved dependencies and those listed in your dependencyManagement section. + *{{{./unpack-dependencies-mojo.html}dependency:unpack-dependencies}} like + copy-dependencies but unpacks. - *{{{tree-mojo.html}dependency:tree}} displays the dependency tree for this project. - [] * Usage - General instructions on how to use the Dependency Plugin can be found on the {{{usage.html}usage page}}. Some more + General instructions on how to use the Dependency Plugin can be found on the {{{./usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Dependency+Plugin}plugin's wiki page}}. - In case you still have questions regarding the plugin's usage, please have a look at the {{{faq.html}FAQ}} and feel - free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could + In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel + free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching - the {{{mail-lists.html}mail archive}}. + the {{{./mail-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our - {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your + {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our - {{{source-repository.html}source repository}} and will find supplementary information in the + {{{./source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples The following examples show how to use the dependency plugin in more advanced use-cases: - - * {{{examples/preparing-dependencies.html}Instructions on how to prepare your dependencies for upgrade to Maven 2.0.6 / 2.1}}. - * {{{examples/copying-artifacts.html}Copying Specific Artifacts}} + * {{{./examples/preparing-dependencies.html}Instructions on how to prepare your dependencies for upgrade to Maven 2.0.6 / 2.1}}. + + * {{{./examples/copying-artifacts.html}Copying Specific Artifacts}} - * {{{examples/copying-project-dependencies.html}Copying Project Dependencies}} + * {{{./examples/copying-project-dependencies.html}Copying Project Dependencies}} - * {{{examples/unpacking-artifacts.html}Unpacking Specific Artifacts}} + * {{{./examples/unpacking-artifacts.html}Unpacking Specific Artifacts}} - * {{{examples/copying-project-dependencies.html}Unpacking the Project Dependencies}} + * {{{./examples/unpacking-project-dependencies.html}Unpacking the Project Dependencies}} [] @@ -126,6 +134,3 @@ * {{{http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html}Dependency Mechanism}} [] - - - diff -Nru maven-dependency-plugin-2.1/src/site/apt/usage.apt maven-dependency-plugin-2.4/src/site/apt/usage.apt --- maven-dependency-plugin-2.1/src/site/apt/usage.apt 2008-08-05 11:44:22.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/usage.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,621 +0,0 @@ -~~ Licensed to the Apache Software Foundation (ASF) under one -~~ or more contributor license agreements. See the NOTICE file -~~ distributed with this work for additional information -~~ regarding copyright ownership. The ASF licenses this file -~~ to you under the Apache License, Version 2.0 (the -~~ "License"); you may not use this file except in compliance -~~ with the License. You may obtain a copy of the License at -~~ -~~ http://www.apache.org/licenses/LICENSE-2.0 -~~ -~~ Unless required by applicable law or agreed to in writing, -~~ software distributed under the License is distributed on an -~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -~~ KIND, either express or implied. See the License for the -~~ specific language governing permissions and limitations -~~ under the License. - - ------ - Usage - ------ - Allan Ramirez - Brian Fox - ------ - Jan 2008 - ------ - -Usage - - Brief examples on how to use the dependency goals. - -* Generic Plugin configuration information - - See the following links for information about including and configuring plugins in your project: - - *{{{http://maven.apache.org/guides/mini/guide-configuring-plugins.html}Configuring Plugins}} - - *{{{http://maven.apache.org/guides/plugin/guide-java-plugin-development.html}Plugin Development}} - - *{{{http://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html}Plugin Prefix}} - -* The <<>> mojo - - This goal is meant to be bound to a lifecycle phase and configured in your - <<>>. It will resolve the artifact from the repository and place a copy - in the specified location. Multiple artifacts can be defined in a single - execution. A default output directory is specified but can be overriden for - each ArtifactItem by setting the optional outputDirectory field. An - optional new name can be set to rename or the version stripped while copying. - - The artifact version is optional. If not set, the plugin will attempt to resolve it from the - project dependencies and then the dependencyManagement section. - - See the {{#Overwrite Rules}} section for rules about how overwriting is handled. - - [] - - Configure the plugin something like this if you intend to bind it to execute along with your build: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - package - - copy - - - - - [ groupId ] - [ artifactId ] - [ version ] - [ packaging ] - [classifier - optional] - [ true or false ] - [ output directory ] - [ filename ] - - - - - - - - - - [...] - -+---+ - - If you intend to configure this mojo for execution on the command line using: - -+---+ -mvn dependency:copy -+---+ - - you must not put the configuration inside the tag. Your configuration should look like this: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - [ groupId ] - [ artifactId ] - [ version ] - [ packaging ] - [classifier - optional] - [ true or false ] - [ output directory ] - [ filename ] - - - - - - - - [...] - -+---+ - -* The <<>> mojo - - This goal can be bound to a lifecycle phase and configured in your <<>>. - It will resolve the dependencies (including transitive dependencies) from - the repository and place a copy in the specified location. - - The artifacts can be placed in subfolders based on type. For example: - - \outputDirectory - - \outputDirectory\jars - - \outputDirectory\wars - - The artifacts can be placed in a subfolder per artifact. For example: - \outputDirectory\junit-junit-3.8.1\ - This feature also works with the subfolders per type. For example: - \outputDirectory\jars\junit-junit-3.8.1\ - - Artifacts can also be resolved by specifying the classifer and optionally - type. Type is only used with the classifier and defaults to java-sources. - When the classifier is set, the list of dependencies is used as the base to - resolve artifacts with the classifer and type. For example: - <<>> will try to find - the sources for all dependencies and copy them. - - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. - - <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. - - See the {{#Overwrite Rules}} section for rules about how overwriting is handled. - - - The goal can also be launched from the command line like: - <<>> - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - package - - copy-dependencies - - - - - - - - - - [...] - -+---+ - - -* The <<>> mojo - - This goal is meant to be bound to a lifecycle and configured in your pom.xml. - It will resolve the artifact from the repository and place a copy in the - specified location. Multiple artifacts can be defined in a single execution. - A default outputDirectory is specified but can be overriden for each - ArtifactItem by setting the optional outputDirectory field. - - A single artifact can be unpacked multiple times if different include/exclude parameters - are defined for each artifactItem - - See the {{#Overwrite Rules}} section for rules about how overwriting is handled. - - The artifact version is optional. If not set, the plugin will attempt to resolve it from the - project dependencies and then the dependencyManagement section. - - Configure the plugin something like this if you intend to bind it to execute along with your build: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack - package - - unpack - - - - - - - - - - [...] - -+---+ - - If you intend to configure this mojo for execution on the command line using: - -+---+ -mvn dependency:unpack -+---+ - - you must not put the configuration inside the tag. Your configuration should look like this: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - - [ groupId ] - [ artifactId ] - [ version ] - [ packaging ] - [classifier - optional] - [ true or false ] - [ output directory ] - [ filename ] - [ comma separated list of file filters ] - [ comma separated list of file filters ] - - - - - - - - [...] - -+---+ - - -* The <<>> mojo - - This goal can be bound to a lifecycle and configured in your pom.xml. - It will resolve the dependencies (including transitive dependencies) from - the repository and unpack them to the specified location. - - Unpack-dependencies includes transitive dependencies by default. To include - only direct dependencies, set the excludeTransitive parameter to true. - - Dependencies can be included or excluded by a list of types. See - {{{unpack-dependencies-mojo.html}unpack-dependencies}} for details. - - The artifacts can be unpacked in subfolders based on type. For example: - - \outputDirectory - - \outputDirectory\jars - - \outputDirectory\wars - - The artifacts can be placed in a subfolder per artifact. For example: - \outputDirectory\junit-junit-3.8.1\ - This feature also works with the subfolders per type. For example: - \outputDirectory\jars\junit-junit-3.8.1\ - - Artifacts can also be resolved by specifying the classifer and optionally - type. Type is only used with the classifier and defaults to java-sources. - When the classifier is set, the list of dependencies is used as the base to - resolve artifacts with the classifer and type. For example: - <<>> will try to find - the sources for all dependencies and unpack them. - - Filters can be applied to include or exclude certain file or filesets as necessary - - Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. - - <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. - - See the {{#Overwrite Rules}} section for rules about how overwriting is handled. - - The goal can also be launched from the command line like: - <<>> - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack-dependencies - package - - unpack-dependencies - - - - - - - - - - [...] - -+---+ - -* {Overwrite Rules} - - Artifacts are copied or unpacked using the following rules: - - * If the artifact doesn't exist in the destination, then copy/unpack it. - - Otherwise: - - * For copy/unpack mojo only: if <<>> or <<>> is true, then it will force an overwrite. - - * Releases check the <<>> value (default = false). If true, then it will force an overwrite. - - * Snapshots check the <<>> value (default = false). If true, then it will force an overwrite. - - * If none of the above is set to true, then it defaults to the <<>> value (default = true). This value, if true, causes - the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the <<>> path. - To avoid unexpected behavior after <<>>, this path should normally be contained within the <<>> hierarchy.) - - Examples: - - * Using the default settings (<<>> = false, <<>> = false, <<>> = true), then a release or snapshot artifact will - only over write the destination if the source is newer than the destination (or marker file if unpacking). - - * If <<>> = true, then a release artifact (ie <<>>) will always overwrite. - - * If <<>> = true, then a snapshot artifact (ie <<>>) will always overwrite. - - * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<>> if unpacking). - - - -* The <<>> mojo - - Resolve is intended to be used from the command line like: - <<>> - - This goal simply tells maven to resolve all test scope (includes compile) - dependencies and then displays the resolved versions. This is intended to - help ensure all dependencies are downloaded to the local repository. This is - usefull when troubleshooting or during intermittent remote repository - failures when repeatedly building multiproject modules is undersirable and - the build is failing on dependency resolution. It can also be used to quickly - determine how versions are being resolved. - - Artifacts can also be resolved by specifying the classifer and optionally - type. Type is only used with the classifier and defaults to java-sources. - When the classifier is set, the list of dependencies is used as the base to - resolve artifacts with the classifer and type. For example: - <<>> will try to find the - test-jar for all dependencies resolve them to the local repository. - -* The <<>> mojo - - Sources is intended to be used from the command line like: - <<>> - - This is the same as the resolve goal except it includes the source - attachments if they exist. This is useful when you want the source - attachments downloaded to your local repository and - you don't want to use the eclipse plugin to do this since the eclipse plugin - creates/overwrites the eclipse files. - - You can also define the <<>> either in the pom or settings - to be a common location for all projects. This allows the system to resolve sources faster for dependencies that don't - have the sources published. The plugin will store a marker file to describe if the sources were resolved or not. By placing - them in a common location, multiple attempts to resolve non-existent sources will be avoided. - -* The <<>> mojo - - Resolve-plugins is intended to be used from the command line like: - <<>> - - This is the same as the resolve goal except it resolves plugins and - optionally their dependencies. - -* The <<>> mojo - - This goal is exactly the same as calling - <<>>. - -* The <<>> mojo - - This goal is meant to delete all of the dependencies for the current project - (or projects, in the case of a multimodule build) from the local repository. - Purges can be run with a variety of limiting parameters, including artifact - exclusions, limiting to direct dependencies only, and different levels of - depth for deletion. By default, deleted artifacts can be re-resolved - afterwards; you can disable this by specifying <<<-DreResolve=false>>>. - - In its simplest form, the mojo can be called like this: - -+---+ -mvn dependency:purge-local-repository -+---+ - - To add the restriction that the <<>> - artifact not be deleted, we can modify the command to this: - -+---+ -mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-api -+---+ - - <> The <<>> parameter is a comma-delimited list of - groupId:artifactId pairs. It has a corresponding List-based parameter - - <<>> - for convenient use inside the POM. - - Another handy aspect of this mojo is the ability to wipe out artifacts at - varying depths. These depths are: - - * <> - Delete just the artifact's file. - - * <> - Delete the version directory containing this artifact. Amounts to - <<>>. - - * <> - Delete the artifactId directory containing this artifact. - Amounts to <<>>. - - * <> - Delete the groupId directory structure containing this artifact. - - At a minimum, this amounts to <<>>. - However, if the groupId contains multiple parts, the mojo will prune all groupId-part - directories that contain only the files associated with this artifact. Again, note that - the exception to this pruning algorithm is the lowest groupId part, which will always - be pruned. - - [] - - To prune dependency artifacts back to their associated artifactId directories - (in order to verify proper artifact resolution, for example), simply use this - command: - -+---+ -mvn dependency:purge-local-repository -DresolutionFuzziness=artifactId -+---+ - - Finally, it's possible to bind this mojo to the build lifecycle. One reason for this - might be to clean out all dependencies when the build is initialized, to verify - correct resolution. - - -* The <<>> mojo - - Since: 2.0-alpha-2 - - This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this: - -+---+ -/home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ .... -+---+ - - The resulting file could then be used like this: - -+---+ -java -cp `cat resultFile` MyClass -+---+ - - In its simplest form, to output the classpath to the log, the mojo can be called like this: - -+---+ -mvn dependency:build-classpath -+---+ - - or to write the classpath to cp.txt.: - -+---+ -mvn dependency:build-classpath -Dmaven.dep.cpFile=cp.txt -+---+ - - The goal can also be bound to a lifecycle phase with the following configuration: - -+---+ - - [...] - - - - org.apache.maven.plugins - maven-dependency-plugin - - - build-classpath - generate-sources - - build-classpath - - - - - - - - - - [...] - -+---+ - -* The <<>> mojo - - This mojo performs byte code analysis to determine missing or unused dependencies. This goal is meant to be launched from the command line. It will fork the build and execute test-compile so there are class files to analyze. - If you want to bind analyze in your pom, use the <<>> mojo instead. - - This mojo can be executed from the command line: - -+---+ -mvn dependency:analyze -+---+ - - Sample output: - -+---+ -[INFO] [dependency:analyze] -[WARNING] Used undeclared dependencies found: -[WARNING] classworlds:classworlds:jar:1.1-alpha-2:compile -[WARNING] org.apache.maven.shared:maven-invoker:jar:2.0.7-SNAPSHOT:test -+---+ - -* The <<>> mojo - - This mojo looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. - In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See {{{http://jira.codehaus.org/browse/MNG-1577}MNG-1577}} for more info. - - If this mojo detects issues, you should attempt to resolve the discrepancies before upgrading to 2.0.6 to avoid any surprises. This can be done by upgrading or downgrading the version in dependencyManagement to match what is actually - being included at runtime, or you can specify a dependency in your project to override what is being included. You can check the results by rerunning this mojo. - If you decide to override by using a dependency, be sure to note it so you can remove it later after upgrading to 2.0.6. You could also use the dependency:analyze mojo to uncover this unused direct dependency. - - This mojo is also usefull for just detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions. - - This mojo can be executed from the command line: - -+---+ -mvn dependency:analyze-dep-mgt -+---+ - - Sample output: - -+---+ -[INFO] Found Resolved Dependency / DependencyManagement mismatches: -[INFO] Dependency: commons-lang:commons-lang:jar -[INFO] DepMgt : 1.0 -[INFO] Resolved: 2.3 -[INFO] Dependency: commons-digester:commons-digester:jar -[INFO] DepMgt : 1.6 -[INFO] Resolved: 1.7 -[INFO] Dependency: javax.servlet:servlet-api:jar -[INFO] DepMgt : 2.3 -[INFO] Resolved: 2.4 -[WARNING] Potential problems found in Dependency Management -+---+ - -* The <<>> Mojo - - This mojo is used to view the dependency hierarchy of the project currently being built. - It will output the resolved tree of dependencies that the Maven build process actually uses. - - This mojo can be executed from the command line: - -+-----+ -mvn dependency:tree -+-----+ - - Optionally, the <<>> parameter can be specified to divert the output to a file: - -+-----+ -mvn dependency:tree -Doutput=/path/to/file -+-----+ diff -Nru maven-dependency-plugin-2.1/src/site/apt/usage.apt.vm maven-dependency-plugin-2.4/src/site/apt/usage.apt.vm --- maven-dependency-plugin-2.1/src/site/apt/usage.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/apt/usage.apt.vm 2011-10-26 17:17:12.000000000 +0000 @@ -0,0 +1,678 @@ +~~ Licensed to the Apache Software Foundation (ASF) under one +~~ or more contributor license agreements. See the NOTICE file +~~ distributed with this work for additional information +~~ regarding copyright ownership. The ASF licenses this file +~~ to you under the Apache License, Version 2.0 (the +~~ "License"); you may not use this file except in compliance +~~ with the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, +~~ software distributed under the License is distributed on an +~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~~ KIND, either express or implied. See the License for the +~~ specific language governing permissions and limitations +~~ under the License. + + ------ + Usage + ------ + Allan Ramirez + Brian Fox + ------ + May 2010 + ------ + +Usage + + Brief examples on how to use the dependency goals. + +* Generic Plugin configuration information + + See the following links for information about including and configuring plugins in your project: + + *{{{http://maven.apache.org/guides/mini/guide-configuring-plugins.html}Configuring Plugins}} + + *{{{http://maven.apache.org/guides/plugin/guide-java-plugin-development.html}Plugin Development}} + + *{{{http://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html}Plugin Prefix}} + +* The <<>> mojo + + This goal is meant to be bound to a lifecycle phase and configured in your + <<>>. It will resolve the artifact from the repository and place a copy + in the specified location. Multiple artifacts can be defined in a single + execution. A default output directory is specified but can be overriden for + each ArtifactItem by setting the optional outputDirectory field. An + optional new name can be set to rename or the version stripped while copying. + + The artifact version is optional. If not set, the plugin will attempt to resolve it from the + project dependencies and then the dependencyManagement section. + + See the {{#Overwrite Rules}} section for rules about how overwriting is handled. + + [] + + Configure the plugin something like this if you intend to bind it to execute along with your build: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy + package + + copy + + + + + [ groupId ] + [ artifactId ] + [ version ] + [ packaging ] + [classifier - optional] + [ true or false ] + [ output directory ] + [ filename ] + + + + + + + + + + [...] + ++---+ + + If you intend to configure this mojo for execution on the command line using: + ++---+ +mvn dependency:copy ++---+ + + you must not put the configuration inside the tag. Your configuration should look like this: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + + [ groupId ] + [ artifactId ] + [ version ] + [ packaging ] + [classifier - optional] + [ true or false ] + [ output directory ] + [ filename ] + + + + + + + + [...] + ++---+ + + + + * By default, artifacts are copied into using + Maven artifact file name convention ( ie ). + Use the following rules to override the default convention: + + * Use to override the default file name. + + * Use to remove from default file name. + This field is ignored when is set. + + * Use to override the plugin's configuration + per . + + [] + + [] + +* The <<>> mojo + + This goal can be bound to a lifecycle phase and configured in your <<>>. + It will resolve the dependencies (including transitive dependencies) from + the repository and place a copy in the specified location. + + The artifacts can be placed in subfolders based on type. For example: + + \outputDirectory + + \outputDirectory\jars + + \outputDirectory\wars + + The artifacts can be placed in a subfolder per artifact. For example: + \outputDirectory\junit-junit-3.8.1\ + This feature also works with the subfolders per type. For example: + \outputDirectory\jars\junit-junit-3.8.1\ + + Artifacts can also be resolved by specifying the classifer and optionally + type. Type is only used with the classifier and defaults to java-sources. + When the classifier is set, the list of dependencies is used as the base to + resolve artifacts with the classifer and type. For example: + <<>> will try to find + the sources for all dependencies and copy them. + + Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + + <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. + + See the {{#Overwrite Rules}} section for rules about how overwriting is handled. + + + The goal can also be launched from the command line like: + <<>> + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + copy-dependencies + package + + copy-dependencies + + + + + + + + + + [...] + ++---+ + + +* The <<>> mojo + + This goal is meant to be bound to a lifecycle and configured in your pom.xml. + It will resolve the artifact from the repository and place a copy in the + specified location. Multiple artifacts can be defined in a single execution. + A default outputDirectory is specified but can be overriden for each + ArtifactItem by setting the optional outputDirectory field. + + A single artifact can be unpacked multiple times if different include/exclude parameters + are defined for each artifactItem + + See the {{#Overwrite Rules}} section for rules about how overwriting is handled. + + The artifact version is optional. If not set, the plugin will attempt to resolve it from the + project dependencies and then the dependencyManagement section. + + Configure the plugin something like this if you intend to bind it to execute along with your build: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + unpack + package + + unpack + + + + + + + + + + [...] + ++---+ + + If you intend to configure this mojo for execution on the command line using: + ++---+ +mvn dependency:unpack ++---+ + + you must not put the configuration inside the tag. Your configuration should look like this: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + + [ groupId ] + [ artifactId ] + [ version ] + [ packaging ] + [classifier - optional] + [ true or false ] + [ output directory ] + [ comma separated list of file filters ] + [ comma separated list of file filters ] + + + + + + + + [...] + ++---+ + + +* The <<>> mojo + + This goal can be bound to a lifecycle and configured in your pom.xml. + It will resolve the dependencies (including transitive dependencies) from + the repository and unpack them to the specified location. + + Unpack-dependencies includes transitive dependencies by default. To include + only direct dependencies, set the excludeTransitive parameter to true. + + Dependencies can be included or excluded by a list of types. See + {{{unpack-dependencies-mojo.html}unpack-dependencies}} for details. + + The artifacts can be unpacked in subfolders based on type. For example: + + \outputDirectory + + \outputDirectory\jars + + \outputDirectory\wars + + The artifacts can be placed in a subfolder per artifact. For example: + \outputDirectory\junit-junit-3.8.1\ + This feature also works with the subfolders per type. For example: + \outputDirectory\jars\junit-junit-3.8.1\ + + Artifacts can also be resolved by specifying the classifer and optionally + type. Type is only used with the classifier and defaults to java-sources. + When the classifier is set, the list of dependencies is used as the base to + resolve artifacts with the classifer and type. For example: + <<>> will try to find + the sources for all dependencies and unpack them. + + Filters can be applied to include or exclude certain file or filesets as necessary + + Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. + + <> As of 2.0-alpha-5, you may mix includes and excludes of the same category (ie scope). Includes are processed before excludes. + + See the {{#Overwrite Rules}} section for rules about how overwriting is handled. + + The goal can also be launched from the command line like: + <<>> + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + unpack-dependencies + package + + unpack-dependencies + + + + + + + + + + [...] + ++---+ + +* {Overwrite Rules} + + Artifacts are copied or unpacked using the following rules: + + * If the artifact doesn't exist in the destination, then copy/unpack it. + + Otherwise: + + * For copy/unpack mojo only: if <<>> or <<>> is true, then it will force an overwrite. + + * Releases check the <<>> value (default = false). If true, then it will force an overwrite. + + * Snapshots check the <<>> value (default = false). If true, then it will force an overwrite. + + * If none of the above is set to true, then it defaults to the <<>> value (default = true). This value, if true, causes + the plugin to only copy if the source is newer than the destination (or it doesn't exist in the destination). (for unpack, this checks the existence of the marker file, created in the <<>> path. + To avoid unexpected behavior after <<>>, this path should normally be contained within the <<>> hierarchy.) + + Examples: + + * Using the default settings (<<>> = false, <<>> = false, <<>> = true), then a release or snapshot artifact will + only over write the destination if the source is newer than the destination (or marker file if unpacking). + + * If <<>> = true, then a release artifact (ie <<>>) will always overwrite. + + * If <<>> = true, then a snapshot artifact (ie <<>>) will always overwrite. + + * If all of the values are false, then a copy/unpack will only occur if it doesn't exist in the destination (or <<>> if unpacking). + + + +* The <<>> mojo + + Resolve is intended to be used from the command line like: + <<>> + + This goal simply tells maven to resolve all test scope (includes compile) + dependencies and then displays the resolved versions. This is intended to + help ensure all dependencies are downloaded to the local repository. This is + usefull when troubleshooting or during intermittent remote repository + failures when repeatedly building multiproject modules is undersirable and + the build is failing on dependency resolution. It can also be used to quickly + determine how versions are being resolved. + + Artifacts can also be resolved by specifying the classifer and optionally + type. Type is only used with the classifier and defaults to java-sources. + When the classifier is set, the list of dependencies is used as the base to + resolve artifacts with the classifer and type. For example: + <<>> will try to find the + test-jar for all dependencies resolve them to the local repository. + +* The <<>> mojo + + Sources is intended to be used from the command line like: + <<>> + + This is the same as the resolve goal except it includes the source + attachments if they exist. This is useful when you want the source + attachments downloaded to your local repository and + you don't want to use the eclipse plugin to do this since the eclipse plugin + creates/overwrites the eclipse files. + + You can also define the <<>> either in the pom or settings + to be a common location for all projects. This allows the system to resolve sources faster for dependencies that don't + have the sources published. The plugin will store a marker file to describe if the sources were resolved or not. By placing + them in a common location, multiple attempts to resolve non-existent sources will be avoided. + +* The <<>> mojo + + Resolve-plugins is intended to be used from the command line like: + <<>> + + This is the same as the resolve goal except it resolves plugins and + optionally their dependencies. + +* The <<>> mojo + + This goal is exactly the same as calling + <<>>. + +* The <<>> mojo + + This goal is meant to delete all of the dependencies for the current project + (or projects, in the case of a multimodule build) from the local repository. + Purges can be run with a variety of limiting parameters, including artifact + exclusions, limiting to direct dependencies only, and different levels of + depth for deletion. By default, deleted artifacts can be re-resolved + afterwards; you can disable this by specifying <<<-DreResolve=false>>>. + + In its simplest form, the mojo can be called like this: + ++---+ +mvn dependency:purge-local-repository ++---+ + + To add the restriction that the <<>> + artifact not be deleted, we can modify the command to this: + ++---+ +mvn dependency:purge-local-repository -Dexclude=org.apache.maven:maven-plugin-api ++---+ + + <> The <<>> parameter is a comma-delimited list of + groupId:artifactId pairs. It has a corresponding List-based parameter - + <<>> - for convenient use inside the POM. + + Another handy aspect of this mojo is the ability to wipe out artifacts at + varying depths. These depths are: + + * <> - Delete just the artifact's file. + + * <> - Delete the version directory containing this artifact. Amounts to + <<>>. + + * <> - Delete the artifactId directory containing this artifact. + Amounts to <<>>. + + * <> - Delete the groupId directory structure containing this artifact. + + At a minimum, this amounts to <<>>. + However, if the groupId contains multiple parts, the mojo will prune all groupId-part + directories that contain only the files associated with this artifact. Again, note that + the exception to this pruning algorithm is the lowest groupId part, which will always + be pruned. + + [] + + To prune dependency artifacts back to their associated artifactId directories + (in order to verify proper artifact resolution, for example), simply use this + command: + ++---+ +mvn dependency:purge-local-repository -DresolutionFuzziness=artifactId ++---+ + + Finally, it's possible to bind this mojo to the build lifecycle. One reason for this + might be to clean out all dependencies when the build is initialized, to verify + correct resolution. + + +* The <<>> mojo + + Since: 2.0-alpha-2 + + This goal will output a classpath string of dependencies from the local repository to a file or log and optionally attach and deploy the file. For instance, the file would contain a classpath string like this: + ++---+ +/home/foo/.m2/repository/org/java/utils/util/util-1.0.jar:/home/foo/.m2/ .... ++---+ + + The resulting file could then be used like this: + ++---+ +java -cp `cat resultFile` MyClass ++---+ + + In its simplest form, to output the classpath to the log, the mojo can be called like this: + ++---+ +mvn dependency:build-classpath ++---+ + + or to write the classpath to cp.txt.: + ++---+ +mvn dependency:build-classpath -Dmdep.outputFile=cp.txt ++---+ + + The goal can also be bound to a lifecycle phase with the following configuration: + ++---+ + + [...] + + + + org.apache.maven.plugins + maven-dependency-plugin + ${project.version} + + + build-classpath + generate-sources + + build-classpath + + + + + + + + + + [...] + ++---+ + +* The <<>> mojo + + This mojo performs byte code analysis to determine missing or unused dependencies. This goal is meant to be launched from the command line. It will fork the build and execute test-compile so there are class files to analyze. + If you want to bind analyze in your pom, use the <<>> mojo instead. + + This mojo can be executed from the command line: + ++---+ +mvn dependency:analyze ++---+ + + Sample output: + ++---+ +[INFO] [dependency:analyze] +[WARNING] Used undeclared dependencies found: +[WARNING] classworlds:classworlds:jar:1.1-alpha-2:compile +[WARNING] org.apache.maven.shared:maven-invoker:jar:2.0.7-SNAPSHOT:test ++---+ + +* The <<>> mojo + + This mojo looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. + In versions of maven prior to 2.0.6, it was possible to inherit versions that didn't match your dependencyManagement. See {{{http://jira.codehaus.org/browse/MNG-1577}MNG-1577}} for more info. + + If this mojo detects issues, you should attempt to resolve the discrepancies before upgrading to 2.0.6 to avoid any surprises. This can be done by upgrading or downgrading the version in dependencyManagement to match what is actually + being included at runtime, or you can specify a dependency in your project to override what is being included. You can check the results by rerunning this mojo. + If you decide to override by using a dependency, be sure to note it so you can remove it later after upgrading to 2.0.6. You could also use the dependency:analyze mojo to uncover this unused direct dependency. + + This mojo is also usefull for just detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions. + + This mojo can be executed from the command line: + ++---+ +mvn dependency:analyze-dep-mgt ++---+ + + Sample output: + ++---+ +[INFO] Found Resolved Dependency / DependencyManagement mismatches: +[INFO] Dependency: commons-lang:commons-lang:jar +[INFO] DepMgt : 1.0 +[INFO] Resolved: 2.3 +[INFO] Dependency: commons-digester:commons-digester:jar +[INFO] DepMgt : 1.6 +[INFO] Resolved: 1.7 +[INFO] Dependency: javax.servlet:servlet-api:jar +[INFO] DepMgt : 2.3 +[INFO] Resolved: 2.4 +[WARNING] Potential problems found in Dependency Management ++---+ + +* The <<>> Mojo + + This mojo is used to view the dependency hierarchy of the project currently being built. + It will output the resolved tree of dependencies that the Maven build process actually uses. + + This mojo can be executed from the command line: + ++-----+ +mvn dependency:tree ++-----+ + + Optionally, the <<>> parameter can be specified to divert the output to a file: + ++-----+ +mvn dependency:tree -Doutput=/path/to/file ++-----+ + + Also, the <<>> parameter can be used to generate different formats of output. The + following formats are currently supported: + + * text + + * dot + + * graphml + + * tgf + + [] + ++-----+ +mvn dependency:tree -Doutput=/path/to/file.graphml -DoutputType=graphml ++-----+ + +* The <<>> Mojo + + This mojo is used to list all the repositories that this build depends upon. It will show repositories defined in your settings, + poms and declared in transitive dependency poms. + +* The <<>> Mojo + + This mojo is used to fetch an artifact and (optionally) its dependencies from remote repositories using its Maven coordinates. + ++-----+ +mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=central::default::http://repo1.maven.apache.org/maven2,myrepo::::http://myrepo.com/maven2 +mvn dependency:get -DartifactId=org.apache.maven -DartifactId=maven-core -Dversion=2.2.1 -Dpackaging=jar -Dclassifier=sources -DremoteRepositories=http://repo1.maven.apache.org/maven2 +mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=http://repo1.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar ++-----+ + diff -Nru maven-dependency-plugin-2.1/src/site/fml/faq.fml maven-dependency-plugin-2.4/src/site/fml/faq.fml --- maven-dependency-plugin-2.1/src/site/fml/faq.fml 2008-08-28 16:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/fml/faq.fml 2009-08-05 13:11:09.000000000 +0000 @@ -19,7 +19,10 @@ under the License. --> - + What is the difference between dependency-maven-plugin and maven-dependency-plugin? @@ -27,47 +30,47 @@

    Actually, they are the same, it's just that it was moved and renamed. The dependency-maven-plugin is hosted at Mojo while maven-dependency-plugin is hosted at Apache. The recommended - plugin to use is the maven-dependency-plugin. + plugin to use is the maven-dependency-plugin.

    When executing mvn dependency:unpack or dependency:copy from the command line, I get "One or more required plugin parameters are invalid/missing for 'dependency:unpack'" - -

    - In order for this to work, you must configure the ArtifactItems as shown here. Note that when executing a plugin from - the command line, you must put the configuration tag outside of the executions. - - If you haven't done this correctly, the error will look like this: -

    +   
    +     

    + In order for this to work, you must configure the ArtifactItems as shown here. Note that when executing a plugin from + the command line, you must put the configuration tag outside of the executions. + + If you haven't done this correctly, the error will look like this: +

     [0] inside the definition for plugin: 'maven-dependency-plugin'specify the following:
    -	 		
    -

    -
    +
    +

    +
    Why am I getting errors that a documented goal or parameter is missing?

    The latest documents are published and may preceed the actual release. Check to make sure the goal/parameter is in the most recent version. - -OR- - Maven may be resolving the older codehaus version of the dependency plugin. See next question.

    + -OR- + Maven may be resolving the older codehaus version of the dependency plugin. See next question.

    Why is Maven resolving "dependency:xxx" to the older org.codehaus.mojo:dependency-maven-plugin?

    - Due to a bug in Maven in versions prior to 2.0.7 (MNG-2926) the search order was reversed and caused Mojo plugins to supercede ones with the same prefix at Apache. - The metadata at mojo was cleaned up when the maven-dependency-plugin was released at Apache. If you are still experiencing this error, chances are you have - old metadata in your local repository or in a proxy / internal repository. Removing /org/codehaus/mojo/maven-metadata.* from your repo/proxy will cause it to - be refreshed. Alternatively, you can specify the groupId explicitely in your pom (if you are using a bound goal), or on the command line, use groupId:artifactId:version:mojo, ie mvn + Due to a bug in Maven in versions prior to 2.0.7 (MNG-2926) the search order was reversed and caused Mojo plugins to supercede ones with the same prefix at Apache. + The metadata at mojo was cleaned up when the maven-dependency-plugin was released at Apache. If you are still experiencing this error, chances are you have + old metadata in your local repository or in a proxy / internal repository. Removing /org/codehaus/mojo/maven-metadata.* from your repo/proxy will cause it to + be refreshed. Alternatively, you can specify the groupId explicitely in your pom (if you are using a bound goal), or on the command line, use groupId:artifactId:version:mojo, ie mvn org.apache.maven.plugins:maven-dependency-plugin:2.0-alpha-4:unpack -

    +

    Why am I having trouble unpacking only a specific file?

    - The excludes will override the includes declaration. That means if you specify excludes=**/* ,includes=**/foo, you will exclude everything. If you only want foo, then just specify the includes. The plexus component used to unpack uses the following code to determing which files to unpack: return isIncluded( name ) AND !isExcluded( name ); -

    + The excludes will override the includes declaration. That means if you specify excludes=**/* ,includes=**/foo, you will exclude everything. If you only want foo, then just specify the includes. The plexus component used to unpack uses the following code to determing which files to unpack: return isIncluded( name ) AND !isExcluded( name ); +

    diff -Nru maven-dependency-plugin-2.1/src/site/site.xml maven-dependency-plugin-2.4/src/site/site.xml --- maven-dependency-plugin-2.1/src/site/site.xml 2009-01-07 21:17:44.000000000 +0000 +++ maven-dependency-plugin-2.4/src/site/site.xml 2009-08-05 13:11:09.000000000 +0000 @@ -19,12 +19,10 @@ under the License. --> - - - org.apache.maven.skins - maven-stylus-skin - 1.1 - + @@ -33,15 +31,15 @@ - + - - - + + + diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDepMgt.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDepMgt.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDepMgt.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDepMgt.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,23 +1,5 @@ package org.apache.maven.plugin.dependency; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Exclusion; -import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory; -import org.apache.maven.plugin.dependency.testUtils.stubs.DependencyProjectStub; -import org.apache.maven.project.MavenProject; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -37,6 +19,24 @@ * under the License. */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestCase; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Exclusion; +import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugin.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; + public class TestAnalyzeDepMgt extends TestCase { @@ -48,40 +48,41 @@ Dependency exclusion; Exclusion ex; - + Artifact exclusionArtifact; DependencyManagement depMgt; + DependencyManagement depMgtNoExclusions; protected void setUp() throws Exception { mojo = new AnalyzeDepMgt(); MavenProject project = new DependencyProjectStub(); - + stubFactory = new DependencyArtifactStubFactory( new File( "" ), false ); - Set allArtifacts = stubFactory.getMixedArtifacts(); - Set directArtifacts = stubFactory.getClassifiedArtifacts(); - + Set allArtifacts = stubFactory.getMixedArtifacts(); + Set 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 ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( exclusion ); - + depMgt = new DependencyManagement(); depMgt.setDependencies( list ); @@ -147,12 +148,12 @@ public void testAddExclusions() { - + assertEquals( 0, mojo.addExclusions( null ).size() ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( ex ); - Map map = mojo.addExclusions( list ); + Map map = mojo.addExclusions( list ); assertEquals( 1,map.size() ); assertTrue( map.containsKey( mojo.getExclusionKey( ex ) ) ); @@ -161,13 +162,13 @@ public void testGetExclusionErrors() { - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( ex ); // already tested this method so I can trust it. - Map map = mojo.addExclusions( list ); + Map map = mojo.addExclusions( list ); - List l = mojo.getExclusionErrors( map, mojo.getProject().getArtifacts() ); + List l = mojo.getExclusionErrors( map, mojo.getProject().getArtifacts() ); assertEquals( 1, l.size() ); @@ -177,11 +178,11 @@ public void testGetMismatch() throws IOException { - Map depMgtMap = new HashMap(); + Map depMgtMap = new HashMap(); depMgtMap.put( exclusion.getManagementKey(), exclusion ); - Map results = mojo.getMismatch( depMgtMap, mojo.getProject().getArtifacts() ); + Map results = mojo.getMismatch( depMgtMap, mojo.getProject().getArtifacts() ); assertEquals( 1, results.size() ); // the release artifact is used to create the exclusion @@ -190,7 +191,7 @@ } public void testMojo() throws IOException - { + { mojo.setIgnoreDirect( false ); try { @@ -200,9 +201,9 @@ catch ( Exception e ) { e.printStackTrace(); - fail("Caught Unexpected Exception:"+e.getLocalizedMessage()); + fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() ); } - + try { DependencyProjectStub project = (DependencyProjectStub) mojo.getProject(); @@ -213,9 +214,9 @@ catch ( Exception e ) { e.printStackTrace(); - fail("Caught Unexpected Exception:"+e.getLocalizedMessage()); + fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() ); } - + try { DependencyProjectStub project = (DependencyProjectStub) mojo.getProject(); @@ -223,13 +224,13 @@ // test with exclusion mojo.setFailBuild( true ); mojo.execute(); - fail("Expected exception to fail the build."); + fail( "Expected exception to fail the build." ); } catch ( Exception e ) { - System.out.println("Caught Expected Exception:"+e.getLocalizedMessage()); + System.out.println( "Caught Expected Exception:" + e.getLocalizedMessage() ); } - + try { DependencyProjectStub project = (DependencyProjectStub) mojo.getProject(); @@ -242,7 +243,7 @@ catch ( Exception e ) { e.printStackTrace(); - fail("Caught Unexpected Exception:"+e.getLocalizedMessage()); + fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() ); } } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDuplicateMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDuplicateMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDuplicateMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestAnalyzeDuplicateMojo.java 2010-11-06 12:21:39.000000000 +0000 @@ -0,0 +1,222 @@ +package org.apache.maven.plugin.dependency; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.maven.plugin.logging.Log; + +/** + * @author Vincent Siveton + * @version $Id: TestAnalyzeDuplicateMojo.java 1032021 2010-11-06 12:21:39Z bentmann $ + */ +public class TestAnalyzeDuplicateMojo + extends AbstractDependencyMojoTestCase +{ + public void testDuplicate() + throws Exception + { + File testPom = + new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config.xml" ); + AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo( "analyze-duplicate", testPom ); + assertNotNull( mojo ); + DuplicateLog log = new DuplicateLog(); + mojo.setLog( log ); + mojo.execute(); + + assertTrue( log.getContent().indexOf( + "List of duplicate dependencies defined in in " + + "your pom.xml" ) != -1 ); + assertTrue( log.getContent().indexOf( "junit:junit:jar" ) != -1 ); + } + + public void testDuplicate2() + throws Exception + { + File testPom = + new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config2.xml" ); + AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo( "analyze-duplicate", testPom ); + assertNotNull( mojo ); + DuplicateLog log = new DuplicateLog(); + mojo.setLog( log ); + mojo.execute(); + + assertTrue( log.getContent().indexOf( + "List of duplicate dependencies defined in in " + + "your pom.xml" ) != -1 ); + assertTrue( log.getContent().indexOf( "junit:junit:jar" ) != -1 ); + } + + class DuplicateLog + implements Log + { + StringBuffer sb = new StringBuffer(); + + /** {@inheritDoc} */ + public void debug( CharSequence content ) + { + print( "debug", content ); + } + + /** {@inheritDoc} */ + public void debug( CharSequence content, Throwable error ) + { + print( "debug", content, error ); + } + + /** {@inheritDoc} */ + public void debug( Throwable error ) + { + print( "debug", error ); + } + + /** {@inheritDoc} */ + public void info( CharSequence content ) + { + print( "info", content ); + } + + /** {@inheritDoc} */ + public void info( CharSequence content, Throwable error ) + { + print( "info", content, error ); + } + + /** {@inheritDoc} */ + public void info( Throwable error ) + { + print( "info", error ); + } + + /** {@inheritDoc} */ + public void warn( CharSequence content ) + { + print( "warn", content ); + } + + /** {@inheritDoc} */ + public void warn( CharSequence content, Throwable error ) + { + print( "warn", content, error ); + } + + /** {@inheritDoc} */ + public void warn( Throwable error ) + { + print( "warn", error ); + } + + /** {@inheritDoc} */ + public void error( CharSequence content ) + { + System.err.println( "[error] " + content.toString() ); + } + + /** {@inheritDoc} */ + public void error( CharSequence content, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) + */ + public void error( Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.err.println( "[error] " + sWriter.toString() ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() + */ + public boolean isDebugEnabled() + { + // TODO: Not sure how best to set these for this implementation... + return false; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() + */ + public boolean isInfoEnabled() + { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() + */ + public boolean isWarnEnabled() + { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() + */ + public boolean isErrorEnabled() + { + return true; + } + + private void print( String prefix, CharSequence content ) + { + sb.append( "[" + prefix + "] " ).append( content.toString() ).append( "\n" ); + } + + private void print( String prefix, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + sb.append( "[" + prefix + "] " ).append( sWriter.toString() ).append( "\n" ); + } + + private void print( String prefix, CharSequence content, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + sb.append( "[" + prefix + "] " ).append( content.toString() ).append( "\n\n" ) + .append( sWriter.toString() ).append( "\n" ); + } + + protected String getContent() + { + return sb.toString(); + } + } +} diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -41,7 +41,7 @@ /** * tests the proper discovery and configuration of the mojo - * + * * @throws Exception */ public void testEnvironment() @@ -55,8 +55,8 @@ MavenProject project = mojo.getProject(); // mojo.silent = true; - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -110,27 +110,43 @@ assertNotNull( mojo ); assertNotNull( mojo.getProject() ); - ArtifactRepository local = new StubArtifactRepository(stubFactory.getWorkingDir().getPath()); + ArtifactRepository local = new StubArtifactRepository( stubFactory.getWorkingDir().getPath() ); mojo.setLocal( local ); - + Artifact artifact = stubFactory.getReleaseArtifact(); - - + + StringBuffer sb = new StringBuffer(); mojo.setPrefix( null ); mojo.setStripVersion( false ); mojo.appendArtifactPath( artifact, sb ); - assertEquals(artifact.getFile().getPath(),sb.toString()); - + assertEquals( artifact.getFile().getPath(), sb.toString() ); + mojo.setLocalRepoProperty( "$M2_REPO" ); sb.setLength( 0 ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("$M2_REPO"+File.separator+artifact.getFile().getName(),sb.toString()); - + assertEquals( "$M2_REPO" + File.separator + artifact.getFile().getName(), sb.toString() ); + mojo.setLocalRepoProperty( "%M2_REPO%" ); sb.setLength( 0 ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("%M2_REPO%"+File.separator+artifact.getFile().getName(),sb.toString()); + assertEquals( "%M2_REPO%" + File.separator + artifact.getFile().getName(), sb.toString() ); + + mojo.setLocalRepoProperty( "%M2_REPO%" ); + sb.setLength( 0 ); + mojo.setPrependGroupId( true ); + mojo.appendArtifactPath( artifact, sb ); + assertEquals("If prefix is null, prependGroupId has no impact ", "%M2_REPO%"+File.separator + + DependencyUtil.getFormattedFileName( artifact, false, false ), sb.toString()); + + mojo.setLocalRepoProperty( "" ); + mojo.setPrefix( "prefix" ); + sb.setLength( 0 ); + mojo.setPrependGroupId( true ); + mojo.appendArtifactPath( artifact, sb ); + assertEquals("prefix"+File.separator+DependencyUtil.getFormattedFileName( artifact, false, true ), + sb.toString()); + mojo.setPrependGroupId( false ); mojo.setLocalRepoProperty( "" ); mojo.setPrefix( "prefix" ); @@ -142,6 +158,7 @@ mojo.setStripVersion( true ); sb.setLength( 0 ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("prefix"+File.separator+DependencyUtil.getFormattedFileName( artifact, true ),sb.toString()); + assertEquals( "prefix" + File.separator + DependencyUtil.getFormattedFileName( artifact, true ), sb.toString() ); + } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -57,8 +57,8 @@ assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -96,17 +96,17 @@ /** * tests the proper discovery and configuration of the mojo - * + * * @throws Exception */ public void testMojo() throws Exception { mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertTrue( file.exists() ); @@ -122,10 +122,10 @@ mojo.stripVersion = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, true ); File file = new File( mojo.outputDirectory, fileName ); assertTrue( file.exists() ); @@ -137,11 +137,11 @@ { mojo.excludeTransitive = true; mojo.execute(); - Iterator iter = mojo.project.getDependencyArtifacts().iterator(); + Iterator iter = mojo.project.getDependencyArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertTrue( file.exists() ); @@ -152,14 +152,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeTypes = "jar"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), !file.exists() ); @@ -170,7 +170,7 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -178,41 +178,41 @@ mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); - assertFalse(file.exists() ); + assertFalse( file.exists() ); } - + mojo.excludeTypes = ""; mojo.execute(); iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getType().equalsIgnoreCase( "jar" ), file.exists() ); } } - + public void testExcludeArtifactId() throws Exception { mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeArtifactIds = "one"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getArtifactId().equals( "one" ), !file.exists() ); @@ -223,30 +223,30 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; //shouldn't get anything - + mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertFalse( file.exists() ); } - + mojo.excludeArtifactIds = ""; mojo.execute(); iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getArtifactId().equals( "one" ), file.exists() ); @@ -257,29 +257,29 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; //shouldn't get anything mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); - assertFalse(file.exists() ); + assertFalse( file.exists() ); } - + mojo.excludeGroupIds = ""; mojo.execute(); iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getGroupId().equals( "one" ), file.exists() ); @@ -291,14 +291,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeGroupIds = "one"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -309,33 +309,33 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeGroupIds = "one,two"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ), !file.exists() ); } } - + public void testExcludeClassifier() throws Exception { mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeClassifiers = "one"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getClassifier().equals( "one" ), !file.exists() ); @@ -346,7 +346,7 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeClassifiers = "one"; mojo.excludeClassifiers = "one"; @@ -354,22 +354,22 @@ mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertFalse( file.exists() ); } - + mojo.excludeClassifiers = ""; mojo.execute(); - iter = mojo.project.getArtifacts().iterator(); + iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getClassifier().equals( "one" ), file.exists() ); @@ -381,16 +381,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerType = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, mojo.outputDirectory, + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false, mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); @@ -428,10 +428,10 @@ mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String useClassifier = artifact.getClassifier(); String useType = artifact.getType(); @@ -479,7 +479,7 @@ // init classifier things mojo.factory = DependencyTestUtils.getArtifactFactory(); mojo.resolver = new StubArtifactResolver( null, are, anfe ); - mojo.local = new StubArtifactRepository( this.testDir.getAbsolutePath() ); + mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) ); try { @@ -495,7 +495,7 @@ /* * public void testOverwrite() { stubFactory.setCreateFiles( false ); * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" ); - * + * * File testFile = new File( getBasedir() + File.separatorChar + * "target/test-classes/unit/copy-dependencies-test/test.zip" ); } */ @@ -504,7 +504,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact release = stubFactory.getReleaseArtifact(); release.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -535,7 +535,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact release = stubFactory.getReleaseArtifact(); release.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -569,7 +569,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact snap = stubFactory.getSnapshotArtifact(); snap.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -602,7 +602,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact snap = stubFactory.getSnapshotArtifact(); snap.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -644,16 +644,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "provided"; // mojo.silent = false; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getScope().equals( "provided" ), !file.exists() ); @@ -667,16 +667,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "system"; // mojo.silent = false; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( artifact.getScope().equals( "system" ), !file.exists() ); @@ -690,15 +690,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -710,7 +710,7 @@ throws IOException { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "test"; try @@ -729,22 +729,22 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( !saf.include( artifact ), file.exists() ); } } - + public void testCopyPom() throws Exception { @@ -752,18 +752,34 @@ mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) ); mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) ); - Set set = new HashSet(); + Set set = new HashSet(); set.add( stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE ) ); mojo.project.setArtifacts( set ); mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName.substring( 0, fileName.length() - 4 ) + ".pom" ); assertTrue( file.exists() ); } } + + public void testPrependGroupId() + throws Exception + { + mojo.prependGroupId = true; + mojo.execute(); + + Iterator iter = mojo.project.getArtifacts().iterator(); + while ( iter.hasNext() ) + { + Artifact artifact = iter.next(); + String fileName = DependencyUtil.getFormattedFileName( artifact, false, true ); + File file = new File( mojo.outputDirectory, fileName ); + assertTrue( file.exists() ); + } + } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo2.java 2011-03-13 00:17:39.000000000 +0000 @@ -61,8 +61,8 @@ assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -89,15 +89,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -109,16 +109,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "test"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -130,15 +130,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -150,14 +150,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "provided"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); assertEquals( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), file.exists() ); @@ -168,15 +168,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "system"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); @@ -190,12 +190,12 @@ mojo.useSubDirectoryPerArtifact = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, mojo.outputDirectory, + File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); @@ -206,17 +206,38 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, false, mojo.outputDirectory, + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, false, mojo.outputDirectory, + artifact ); + File file = new File( folder, fileName ); + assertTrue( file.exists() ); + } + } + + public void testSubPerArtifactAndScope() + throws Exception + { + mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); + mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.useSubDirectoryPerArtifact = true; + mojo.useSubDirectoryPerScope = true; + mojo.execute(); + + Iterator iter = mojo.project.getArtifacts().iterator(); + while ( iter.hasNext() ) + { + Artifact artifact = iter.next(); + String fileName = DependencyUtil.getFormattedFileName( artifact, false ); + File folder = DependencyUtil.getFormattedOutputDirectory( true, false, true, false, false, mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); @@ -237,8 +258,8 @@ "jar", null); - mojo.project.getArtifacts().add(expandedSnapshot); - mojo.project.getDependencyArtifacts().add(expandedSnapshot); + mojo.project.getArtifacts().add( expandedSnapshot ); + mojo.project.getDependencyArtifacts().add( expandedSnapshot ); Artifact pomExpandedSnapshot = createExpandedVersionArtifact( baseVersion, groupId, @@ -246,8 +267,8 @@ "compile", "pom", null); - mojo.project.getArtifacts().add(pomExpandedSnapshot); - mojo.project.getDependencyArtifacts().add(pomExpandedSnapshot); + mojo.project.getArtifacts().add( pomExpandedSnapshot ); + mojo.project.getDependencyArtifacts().add( pomExpandedSnapshot ); mojo.useRepositoryLayout = true; mojo.execute(); @@ -259,10 +280,10 @@ new DefaultRepositoryLayout(), false ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertArtifactExists( artifact, targetRepository ); if ( ! artifact.getBaseVersion().equals( artifact.getVersion() ) ) @@ -321,12 +342,12 @@ mojo.stripVersion = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, true ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, mojo.outputDirectory, + File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); @@ -337,18 +358,18 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String fileName = DependencyUtil.getFormattedFileName( artifact, true ); - File folder = DependencyUtil.getFormattedOutputDirectory( true, true, false, true, mojo.outputDirectory, + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestGetMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestGetMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestGetMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestGetMojo.java 2011-10-26 19:00:50.000000000 +0000 @@ -0,0 +1,139 @@ +package org.apache.maven.plugin.dependency; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; + +public class TestGetMojo + extends AbstractDependencyMojoTestCase +{ + GetMojo mojo; + + protected void setUp() + throws Exception + { + // required for mojo lookups to work + super.setUp( "markers", false ); + + File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" ); + assert testPom.exists(); + mojo = (GetMojo) lookupMojo( "get", testPom ); + + assertNotNull( mojo ); + setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( testDir.getAbsolutePath() ) ); + } + + /** + * Test transitive parameter + * + * @throws Exception + */ + public void testTransitive() + throws Exception + { + // Set properties, transitive = default value = true + setVariableValueToObject( mojo, "transitive", Boolean.FALSE ); + setVariableValueToObject( mojo, "repositoryUrl", "http://repo1.maven.apache.org/maven2" ); + setVariableValueToObject( mojo, "groupId", "org.apache.maven" ); + setVariableValueToObject( mojo, "artifactId", "maven-model" ); + setVariableValueToObject( mojo, "version", "2.0.9" ); + + mojo.execute(); + + // Set properties, transitive = false + setVariableValueToObject( mojo, "transitive", Boolean.FALSE ); + mojo.execute(); + } + + /** + * Test remote repositories parameter + * + * @throws Exception + */ + public void testRemoteRepositories() + throws Exception + { + setVariableValueToObject( mojo, "remoteRepositories", "central::default::http://repo1.maven.apache.org/maven2," + + "central::::http://repo1.maven.apache.org/maven2," + "http://repo1.maven.apache.org/maven2" ); + setVariableValueToObject( mojo, "groupId", "org.apache.maven" ); + setVariableValueToObject( mojo, "artifactId", "maven-model" ); + setVariableValueToObject( mojo, "version", "2.0.9" ); + + mojo.execute(); + } + + /** + * Test parsing of the remote repositories parameter + * + * @throws Exception + */ + public void testParseRepository() + throws Exception + { + ArtifactRepository repo; + ArtifactRepositoryPolicy policy = null; + repo = mojo.parseRepository( "central::default::http://repo1.maven.apache.org/maven2", policy ); + assertEquals( "central", repo.getId() ); + assertEquals( DefaultRepositoryLayout.class, repo.getLayout().getClass() ); + assertEquals( "http://repo1.maven.apache.org/maven2", repo.getUrl() ); + + repo = mojo.parseRepository( "central::legacy::http://repo1.maven.apache.org/maven2", policy ); + assertEquals( "central", repo.getId() ); + assertEquals( LegacyRepositoryLayout.class, repo.getLayout().getClass() ); + assertEquals( "http://repo1.maven.apache.org/maven2", repo.getUrl() ); + + repo = mojo.parseRepository( "central::::http://repo1.maven.apache.org/maven2", policy ); + assertEquals( "central", repo.getId() ); + assertEquals( DefaultRepositoryLayout.class, repo.getLayout().getClass() ); + assertEquals( "http://repo1.maven.apache.org/maven2", repo.getUrl() ); + + repo = mojo.parseRepository( "http://repo1.maven.apache.org/maven2", policy ); + assertEquals( "temp", repo.getId() ); + assertEquals( DefaultRepositoryLayout.class, repo.getLayout().getClass() ); + assertEquals( "http://repo1.maven.apache.org/maven2", repo.getUrl() ); + + try + { + repo = mojo.parseRepository( "::::http://repo1.maven.apache.org/maven2", policy ); + fail( "Exception expected" ); + } + catch ( MojoFailureException e ) + { + // expected + } + + try + { + repo = mojo.parseRepository( "central::http://repo1.maven.apache.org/maven2", policy ); + fail( "Exception expected" ); + } + catch ( MojoFailureException e ) + { + // expected + } + } +} diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackDependenciesMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackDependenciesMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackDependenciesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,20 +1,40 @@ package org.apache.maven.plugin.dependency; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; -public class TestIncludeExcludeUnpackDependenciesMojo +public class TestIncludeExcludeUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { private final String PACKED_FILE = "test.zip"; - + private final String UNPACKED_FILE_PREFIX = "test"; private final String UNPACKED_FILE_SUFFIX = ".txt"; - + private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; - + UnpackDependenciesMojo mojo; protected void setUp() @@ -38,8 +58,8 @@ assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -47,21 +67,21 @@ mojo.markersDirectory = new File( this.testDir, "markers" ); } - + protected void tearDown() { super.tearDown(); - + mojo = null; System.gc(); } - - private void assertUnpacked(boolean unpacked, String fileName) + + private void assertUnpacked( boolean unpacked, String fileName ) { - File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName ); - assertEquals(unpacked, destFile.exists()); + File destFile = new File( mojo.getOutputDirectory().getAbsolutePath(), fileName ); + assertEquals( unpacked, destFile.exists() ); } - + /** * This test will validate that only the 1 and 11 files get unpacked * @throws Exception @@ -69,14 +89,14 @@ public void testUnpackIncludesManyFiles() throws Exception { - mojo.setIncludes("**/*1" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/*1" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify only the 2 file gets unpacked * @throws Exception @@ -84,14 +104,14 @@ public void testUnpackIncludesSingleFile() throws Exception { - mojo.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify all files get unpacked * @throws Exception @@ -99,14 +119,14 @@ public void testUnpackIncludesAllFiles() throws Exception { - mojo.setIncludes("**/*"); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/*" ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will validate that only the 2 and 3 files get unpacked * @throws Exception @@ -114,14 +134,14 @@ public void testUnpackExcludesManyFiles() throws Exception { - mojo.setExcludes("**/*1" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/*1" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify only the 1, 11 & 3 files get unpacked * @throws Exception @@ -129,14 +149,14 @@ public void testUnpackExcludesSingleFile() throws Exception { - mojo.setExcludes("**/test2" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify no files get unpacked * @throws Exception @@ -144,21 +164,21 @@ public void testUnpackExcludesAllFiles() throws Exception { - mojo.setExcludes("**/*"); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/*" ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + public void testNoIncludeExcludes() throws Exception { - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,9 +1,28 @@ package org.apache.maven.plugin.dependency; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; @@ -14,16 +33,16 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactCollector; import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; -public class TestIncludeExcludeUnpackMojo +public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase { private final String PACKED_FILE = "test.zip"; - + private final String UNPACKED_FILE_PREFIX = "test"; private final String UNPACKED_FILE_SUFFIX = ".txt"; - + private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; - + UnpackMojo mojo; protected void setUp() @@ -44,32 +63,31 @@ stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + PACKED_FILE_PATH ) ); Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); ArtifactItem item = stubFactory.getArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); assertNotNull( mojo ); assertNotNull( mojo.getProject() ); - + mojo.setFactory( DependencyTestUtils.getArtifactFactory() ); mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) ); mojo.setMarkersDirectory( new File( this.testDir, "markers" ) ); mojo.setArtifactCollector( new StubArtifactCollector() ); mojo.setArtifactItems( list ); } - + protected void tearDown() { super.tearDown(); - + mojo = null; System.gc(); } - - public void assertMarkerFiles( Collection items, boolean exist ) + + public void assertMarkerFiles( Collection items, boolean exist ) { - Iterator iter = items.iterator(); - while ( iter.hasNext() ) + for ( ArtifactItem item : items ) { - assertMarkerFile( exist, (ArtifactItem) iter.next() ); + assertMarkerFile( exist, item ); } } @@ -85,13 +103,13 @@ fail( e.getLongMessage() ); } } - - private void assertUnpacked(boolean unpacked, String fileName) + + private void assertUnpacked( boolean unpacked, String fileName ) { - File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName ); + File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName ); assertEquals(unpacked, destFile.exists()); } - + /** * This test will validate that only the 1 and 11 files get unpacked * @throws Exception @@ -99,14 +117,14 @@ public void testUnpackIncludesManyFiles() throws Exception { - mojo.setIncludes("**/*1" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/*1" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify only the 2 file gets unpacked * @throws Exception @@ -114,14 +132,14 @@ public void testUnpackIncludesSingleFile() throws Exception { - mojo.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify all files get unpacked * @throws Exception @@ -129,14 +147,14 @@ public void testUnpackIncludesAllFiles() throws Exception { - mojo.setIncludes("**/*"); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setIncludes( "**/*" ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will validate that only the 2 and 3 files get unpacked * @throws Exception @@ -144,14 +162,14 @@ public void testUnpackExcludesManyFiles() throws Exception { - mojo.setExcludes("**/*1" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/*1" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify only the 1, 11 & 3 files get unpacked * @throws Exception @@ -159,14 +177,14 @@ public void testUnpackExcludesSingleFile() throws Exception { - mojo.setExcludes("**/test2" + UNPACKED_FILE_SUFFIX); - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + /** * This test will verify no files get unpacked * @throws Exception @@ -174,104 +192,106 @@ public void testUnpackExcludesAllFiles() throws Exception { - mojo.setExcludes("**/*"); - mojo.execute(); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.setExcludes( "**/*" ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + public void testNoIncludeExcludes() throws Exception { - mojo.execute(); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX); - assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + public void testIncludeArtifactItemOverride() throws Exception { - Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); + Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); ArtifactItem item = stubFactory.getArtifactItem( artifact ); - item.setIncludes("**/*"); - ArrayList list = new ArrayList( 1 ); + item.setIncludes( "**/*" ); + List list = new ArrayList( 1 ); list.add( item ); - mojo.setArtifactItems( list ); + mojo.setArtifactItems( list ); mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); - mojo.execute(); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + public void testExcludeArtifactItemOverride() throws Exception { - Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); - ArtifactItem item = stubFactory.getArtifactItem( artifact ); - item.setExcludes("**/*"); - ArrayList list = new ArrayList( 1 ); - list.add( item ); - mojo.setArtifactItems( list ); - mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX ); - mojo.execute(); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); + Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); + ArtifactItem item = stubFactory.getArtifactItem( artifact ); + item.setExcludes( "**/*" ); + List list = new ArrayList( 1 ); + list.add( item ); + mojo.setArtifactItems( list ); + mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); } - + public void testIncludeArtifactItemMultipleMarker() throws Exception { - ArrayList list = new ArrayList(); - Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); + List list = new ArrayList(); + Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); ArtifactItem item = stubFactory.getArtifactItem( artifact ); - item.setOverWrite("false"); - item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX); + item.setOverWrite( "false" ); + item.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); list.add( item ); item = stubFactory.getArtifactItem( artifact ); - item.setOverWrite("false"); - item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX); + item.setOverWrite( "false" ); + item.setIncludes( "**/test3" + UNPACKED_FILE_SUFFIX ); list.add( item ); - mojo.setArtifactItems( list ); - mojo.execute(); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - assertMarkerFiles( mojo.getArtifactItems(), true ); + mojo.setArtifactItems( list ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); + assertMarkerFiles( mojo.getArtifactItems(), true ); } - + public void testIncludeArtifactItemMultipleExecutions() throws Exception { - ArrayList list = new ArrayList(); - Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); + List list = new ArrayList(); + Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null ); ArtifactItem item = stubFactory.getArtifactItem( artifact ); - item.setOverWrite("false"); - item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX); + item.setOverWrite( "false" ); + item.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); list.add( item ); item = stubFactory.getArtifactItem( artifact ); - item.setOverWrite("false"); - item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX); + item.setOverWrite( "false" ); + item.setIncludes( "**/test3" + UNPACKED_FILE_SUFFIX ); list.add( item ); - mojo.setArtifactItems( list ); - mojo.execute(); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); - assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - assertMarkerFiles( mojo.getArtifactItems(), true ); - - //Now run again and make sure the extracted files haven't gotten overwritten - File destFile2 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); - File destFile3 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); + mojo.setArtifactItems( list ); + mojo.execute(); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); + assertMarkerFiles( mojo.getArtifactItems(), true ); + + // Now run again and make sure the extracted files haven't gotten overwritten + File destFile2 = + new File( mojo.getOutputDirectory().getAbsolutePath(), UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); + File destFile3 = + new File( mojo.getOutputDirectory().getAbsolutePath(), UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); long time = System.currentTimeMillis(); time = time - ( time % 1000 ); destFile2.setLastModified( time ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestPropertiesMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestPropertiesMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestPropertiesMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestPropertiesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -0,0 +1,73 @@ +package org.apache.maven.plugin.dependency; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.project.MavenProject; + +public class TestPropertiesMojo + extends AbstractDependencyMojoTestCase +{ + protected void setUp() + throws Exception + { + // required for mojo lookups to work + super.setUp( "markers", true ); + } + + /** + * tests the proper discovery and configuration of the mojo + * + * @throws Exception + */ + public void testSetProperties() + throws Exception + { + File testPom = new File( getBasedir(), "target/test-classes/unit/properties-test/plugin-config.xml" ); + PropertiesMojo mojo = (PropertiesMojo) lookupMojo( "properties", testPom ); + + assertNotNull( mojo ); + assertNotNull( mojo.getProject() ); + MavenProject project = mojo.getProject(); + + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + artifacts.addAll( directArtifacts ); + + project.setArtifacts( artifacts ); + project.setDependencyArtifacts( directArtifacts ); + + // this.assertNull( project.getProperties().getProperty( "org.apacha ) ) + mojo.execute(); + + for ( Artifact artifact : artifacts ) + { + File artifactFile = artifact.getFile(); + assertNotNull( artifact.getDependencyConflictId() ); + assertTrue( artifactFile.isFile() ); + + } + + } + +} \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -22,6 +22,7 @@ import java.io.File; import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.dependency.resolvers.ResolveDependenciesMojo; import org.apache.maven.plugin.dependency.utils.DependencyStatusSets; import org.apache.maven.plugin.testing.SilentLog; @@ -54,8 +55,8 @@ MavenProject project = mojo.getProject(); mojo.silent = true; - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestTreeMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestTreeMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestTreeMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestTreeMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -20,7 +20,11 @@ */ import java.io.File; +import java.io.BufferedReader; +import java.io.FileReader; import java.util.Set; +import java.util.List; +import java.util.ArrayList; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; @@ -29,16 +33,16 @@ /** * Tests TreeMojo. - * + * * @author Mark Hobson - * @version $Id: TestTreeMojo.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: TestTreeMojo.java 1081021 2011-03-13 00:17:39Z hboutemy $ * @since 2.0 */ public class TestTreeMojo extends AbstractDependencyMojoTestCase { // TestCase methods ------------------------------------------------------- - + /* * @see org.apache.maven.plugin.testing.AbstractMojoTestCase#setUp() */ @@ -48,12 +52,12 @@ // required for mojo lookups to work super.setUp( "tree", false ); } - + // tests ------------------------------------------------------------------ /** * Tests the proper discovery and configuration of the mojo. - * + * * @throws Exception */ public void testTreeTestEnvironment() @@ -68,31 +72,142 @@ MavenProject project = mojo.getProject(); project.setArtifact( this.stubFactory.createArtifact( "testGroupId", "project", "1.0" ) ); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); project.setDependencyArtifacts( directArtifacts ); mojo.execute(); - + DependencyNode rootNode = mojo.getDependencyTree(); - assertNodeEquals( "testGroupId:project:jar:1.0:compile", rootNode); + assertNodeEquals( "testGroupId:project:jar:1.0:compile", rootNode ); assertEquals( 2, rootNode.getChildren().size() ); assertChildNodeEquals( "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile", rootNode, 0 ); assertChildNodeEquals( "testGroupId:release:jar:1.0:compile", rootNode, 1 ); } - + + /** + * Test the DOT format serialization + * + * @throws Exception + */ + public void testTreeDotSerializing() + throws Exception + { + List contents = runTreeMojo( "tree1.dot", "dot" ); + assertTrue( findString( contents, "digraph \"testGroupId:project:jar:1.0:compile\" {" ) ); + assertTrue( findString( contents, + "\"testGroupId:project:jar:1.0:compile\" -> \"testGroupId:snapshot:jar:2.0-SNAPSHOT:compile\"" ) ); + assertTrue( findString( contents, + "\"testGroupId:project:jar:1.0:compile\" -> \"testGroupId:release:jar:1.0:compile\"" ) ); + } + + /** + * Test the GraphML format serialization + * + * @throws Exception + */ + public void testTreeGraphMLSerializing() + throws Exception + { + List contents = runTreeMojo( "tree1.graphml", "graphml" ); + + assertTrue( findString( contents, "" ) ); + assertTrue( findString( contents, "testGroupId:project:jar:1.0:compile" ) ); + assertTrue( findString( contents, "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile" ) ); + assertTrue( findString( contents, "testGroupId:release:jar:1.0:compile" ) ); + assertTrue( findString( contents, "" ) ); + assertTrue( findString( contents, "" ) ); + } + + /** + * Test the TGF format serialization + * + * @throws Exception + */ + public void testTreeTGFSerializing() + throws Exception + { + List contents = runTreeMojo( "tree1.tgf", "tgf" ); + assertTrue( findString( contents, "testGroupId:project:jar:1.0:compile" ) ); + assertTrue( findString( contents, "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile" ) ); + assertTrue( findString( contents, "testGroupId:release:jar:1.0:compile" ) ); + } + + /** + * Help finding content in the given list of string + * @param outputFile + * @param format + * @return list of strings in the output file + */ + private List runTreeMojo( String outputFile, String format ) + throws Exception + { + File testPom = new File( getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml" ); + String outputFileName = testDir.getAbsolutePath() + outputFile; + TreeMojo mojo = (TreeMojo) lookupMojo( "tree", testPom ); + setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( testDir.getAbsolutePath() ) ); + setVariableValueToObject( mojo, "outputType", format ); + setVariableValueToObject( mojo, "outputFile", new File( outputFileName ) ); + + assertNotNull( mojo ); + assertNotNull( mojo.getProject() ); + MavenProject project = mojo.getProject(); + project.setArtifact( this.stubFactory.createArtifact( "testGroupId", "project", "1.0" ) ); + + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + artifacts.addAll( directArtifacts ); + + project.setArtifacts( artifacts ); + project.setDependencyArtifacts( directArtifacts ); + + mojo.execute(); + + BufferedReader fp1 = new BufferedReader( new FileReader( outputFileName ) ); + List contents = new ArrayList(); + + String line = null; + while ( ( line = fp1.readLine() ) != null ) + { + contents.add( line ); + } + fp1.close(); + + return contents ; + } + + /** + * Help finding content in the given list of string + * @param contents + * @param str + */ + private boolean findString( List contents, String str ) + { + for ( String line : contents ) + { + if ( line.indexOf( str ) != -1 ) + { + // if match then return here + return true; + } + } + + // in case no match for the whole list + return false; + } + // private methods -------------------------------------------------------- - + private void assertChildNodeEquals( String expectedNode, DependencyNode actualParentNode, int actualChildIndex ) { DependencyNode actualNode = (DependencyNode) actualParentNode.getChildren().get( actualChildIndex ); - + assertNodeEquals( expectedNode, actualNode ); } - + private void assertNodeEquals( String expectedNode, DependencyNode actualNode ) { String[] tokens = expectedNode.split( ":" ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -68,8 +68,8 @@ assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -93,7 +93,8 @@ public void assertUnpacked( boolean val, Artifact artifact ) { - File folder = DependencyUtil.getFormattedOutputDirectory( mojo.useSubDirectoryPerType, + File folder = DependencyUtil.getFormattedOutputDirectory( mojo.useSubDirectoryPerScope, + mojo.useSubDirectoryPerType, mojo.useSubDirectoryPerArtifact, mojo.useRepositoryLayout, mojo.stripVersion, mojo.outputDirectory, artifact ); @@ -121,10 +122,10 @@ throws Exception { mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -134,10 +135,10 @@ { mojo.excludeTransitive = true; mojo.execute(); - Iterator iter = mojo.project.getDependencyArtifacts().iterator(); + Iterator iter = mojo.project.getDependencyArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -146,14 +147,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArchiveArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeTypes = "jar"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !artifact.getType().equalsIgnoreCase( "jar" ), artifact ); } @@ -163,16 +164,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "provided"; // mojo.silent = false; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !artifact.getScope().equals( "provided" ), artifact ); } @@ -182,16 +183,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "system"; // mojo.silent = false; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !artifact.getScope().equals( "system" ), artifact ); } @@ -201,15 +202,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !saf.include( artifact ), artifact ); } } @@ -218,7 +219,7 @@ throws IOException { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "test"; try @@ -237,15 +238,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !saf.include( artifact ), artifact ); } } @@ -254,7 +255,7 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArchiveArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; @@ -262,10 +263,10 @@ mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( false, artifact ); } @@ -276,7 +277,7 @@ iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact.getType().equalsIgnoreCase( "jar" ), artifact ); } @@ -286,14 +287,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArchiveArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerType = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -304,10 +305,10 @@ mojo.useSubDirectoryPerArtifact = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -316,15 +317,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArchiveArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -336,10 +337,10 @@ mojo.stripVersion = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -348,16 +349,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getTypedArchiveArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.useSubDirectoryPerArtifact = true; mojo.useSubDirectoryPerType = true; mojo.stripVersion = true; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact ); } } @@ -366,15 +367,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "compile"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( saf.include( artifact ), artifact ); } } @@ -383,16 +384,16 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "test"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( saf.include( artifact ), artifact ); } } @@ -401,15 +402,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "runtime"; mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( saf.include( artifact ), artifact ); } } @@ -418,14 +419,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "provided"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), artifact ); } } @@ -434,15 +435,15 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getScopedArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeScope = "system"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), artifact ); } } @@ -451,17 +452,17 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; //shouldn't get anything mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( false, artifact ); } mojo.excludeArtifactIds =""; @@ -470,7 +471,7 @@ iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( artifact.getArtifactId().equals( "one" ), artifact ); } @@ -480,17 +481,17 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getArtifactArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeArtifactIds = "one"; mojo.execute(); // test - get all direct dependencies and verify that they exist if they // do not have a classifier of "one" // then delete the file and at the end, verify the folder is empty. - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !artifact.getArtifactId().equals( "one" ), artifact ); } } @@ -499,14 +500,14 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.excludeGroupIds = "one"; mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); assertUnpacked( !artifact.getGroupId().equals( "one" ), artifact ); } } @@ -515,17 +516,17 @@ throws Exception { mojo.project.setArtifacts( stubFactory.getGroupIdArtifacts() ); - mojo.project.setDependencyArtifacts( new HashSet() ); + mojo.project.setDependencyArtifacts( new HashSet() ); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; //shouldn't get anything mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); // Testing with artifact id because group id is not in filename assertUnpacked( false, artifact ); } @@ -536,7 +537,7 @@ iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); // Testing with artifact id because group id is not in filename assertUnpacked( artifact.getGroupId().equals( "one" ), artifact ); } @@ -568,14 +569,14 @@ mojo.type = testType; mojo.factory = DependencyTestUtils.getArtifactFactory(); mojo.resolver = new StubArtifactResolver( stubFactory, false, false ); - mojo.local = new StubArtifactRepository( this.testDir.getAbsolutePath() ); + mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) ); mojo.execute(); - Iterator iter = mojo.project.getArtifacts().iterator(); + Iterator iter = mojo.project.getArtifacts().iterator(); while ( iter.hasNext() ) { - Artifact artifact = (Artifact) iter.next(); + Artifact artifact = iter.next(); String useClassifier = artifact.getClassifier(); String useType = artifact.getType(); @@ -629,7 +630,7 @@ public File getUnpackedFile( Artifact artifact ) { - File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerType(), mojo + File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), mojo.isUseSubDirectoryPerType(), mojo .isUseSubDirectoryPerArtifact(), mojo.useRepositoryLayout, mojo.stripVersion, mojo.getOutputDirectory(), artifact ); File unpacked = new File( destDir, DependencyArtifactStubFactory.getUnpackableFileName( artifact ) ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo2.java 2011-03-13 00:17:39.000000000 +0000 @@ -61,8 +61,8 @@ assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - Set artifacts = this.stubFactory.getScopedArtifacts(); - Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); + Set artifacts = this.stubFactory.getScopedArtifacts(); + Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); project.setArtifacts( artifacts ); @@ -81,7 +81,7 @@ public File getUnpackedFile( Artifact artifact ) { - File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerType(), mojo + File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), mojo.isUseSubDirectoryPerType(), mojo .isUseSubDirectoryPerArtifact(), mojo.useRepositoryLayout, mojo.stripVersion, mojo.getOutputDirectory(), artifact ); File unpacked = new File( destDir, DependencyArtifactStubFactory.getUnpackableFileName( artifact ) ); @@ -93,7 +93,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact release = stubFactory.getReleaseArtifact(); release.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -113,7 +113,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact release = stubFactory.getReleaseArtifact(); release.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -134,7 +134,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact snap = stubFactory.getSnapshotArtifact(); snap.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -156,7 +156,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact snap = stubFactory.getSnapshotArtifact(); snap.getFile().setLastModified( System.currentTimeMillis() - 2000 ); @@ -179,7 +179,7 @@ throws MojoExecutionException, InterruptedException, IOException { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Artifact snap = stubFactory.getSnapshotArtifact(); snap.getFile().setLastModified( System.currentTimeMillis() - 2000 ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java 2011-03-13 00:17:39.000000000 +0000 @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.Artifact; @@ -72,8 +71,8 @@ public ArtifactItem getSingleArtifactItem( boolean removeVersion ) throws MojoExecutionException { - ArrayList list = mojo.getProcessedArtifactItems( removeVersion ); - return (ArtifactItem) list.get( 0 ); + List list = mojo.getProcessedArtifactItems( removeVersion ); + return list.get( 0 ); } public void testGetArtifactItems() @@ -86,7 +85,7 @@ item.setGroupId( "groupId" ); item.setVersion( "1.0" ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -100,12 +99,11 @@ assertEquals( output, result.getOutputDirectory() ); } - public void assertFilesExist( Collection items, boolean exist ) + public void assertFilesExist( Collection items, boolean exist ) { - Iterator iter = items.iterator(); - while ( iter.hasNext() ) + for ( ArtifactItem item : items ) { - assertFileExists( (ArtifactItem) iter.next(), exist ); + assertFileExists( item, exist ); } } @@ -120,12 +118,13 @@ CopyMojo themojo = new CopyMojo(); assertFalse( themojo.isStripVersion() ); + assertFalse( themojo.isSkip() ); } public void testCopyFile() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); mojo.setArtifactItems( list ); @@ -133,18 +132,32 @@ assertFilesExist( list, true ); } + + public void testSkip() + throws IOException, MojoExecutionException + { + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + + mojo.setSkip( true ); + mojo.setArtifactItems( list ); + + mojo.execute(); + for ( ArtifactItem item : list ) + { + //these will be null because no processing has occured only when everything is skipped + assertEquals( null, item.getOutputDirectory() ); + assertEquals( null, item.getDestFileName() ); + } + + } public void testCopyFileNoOverwrite() throws IOException, MojoExecutionException { + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); - - Iterator iter = list.iterator(); - while ( iter.hasNext() ) + for ( ArtifactItem item : list ) { - ArtifactItem item = (ArtifactItem) iter.next(); - // make sure that we copy even if false is set - MDEP-80 item.setOverWrite( "false" ); } @@ -158,7 +171,7 @@ public void testCopyToLocation() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); ArtifactItem item = (ArtifactItem) list.get( 0 ); item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) ); @@ -172,7 +185,7 @@ public void testCopyStripVersionSetInMojo() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); ArtifactItem item = (ArtifactItem) list.get( 0 ); item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) ); mojo.setStripVersion( true ); @@ -188,7 +201,7 @@ public void testNonClassifierStrip() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() ); mojo.setStripVersion( true ); mojo.setArtifactItems( list ); @@ -200,7 +213,7 @@ public void testNonClassifierNoStrip() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getReleaseAndSnapshotArtifacts() ); mojo.setArtifactItems( list ); @@ -219,7 +232,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -234,7 +247,7 @@ } } - public List getDependencyList( ArtifactItem item ) + public List getDependencyList( ArtifactItem item ) { Dependency dep = new Dependency(); dep.setArtifactId( item.getArtifactId() ); @@ -250,7 +263,7 @@ dep2.setType( item.getType() ); dep2.setVersion( "2.1" ); - List list = new ArrayList( 2 ); + List list = new ArrayList( 2 ); list.add( dep2 ); list.add( dep ); @@ -267,7 +280,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -295,7 +308,7 @@ item.setClassifier( "sources" ); item.setType( "jar" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -314,7 +327,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -326,7 +339,7 @@ assertEquals( "2.1", item.getVersion() ); } - public List getDependencyMgtList( ArtifactItem item ) + public List getDependencyMgtList( ArtifactItem item ) { Dependency dep = new Dependency(); dep.setArtifactId( item.getArtifactId() ); @@ -342,7 +355,7 @@ dep2.setType( item.getType() ); dep2.setVersion( "3.1" ); - List list = new ArrayList( 2 ); + List list = new ArrayList( 2 ); list.add( dep2 ); list.add( dep ); @@ -369,7 +382,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -402,7 +415,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -436,7 +449,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -472,7 +485,7 @@ item.setType( "type" ); item.setVersion( "1.0" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -522,7 +535,7 @@ ArtifactItem item = new ArtifactItem( release ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -553,7 +566,7 @@ ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -584,7 +597,7 @@ ArtifactItem item = new ArtifactItem( release ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -612,7 +625,7 @@ ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -641,7 +654,7 @@ ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); mojo.setOverWriteIfNewer( true ); @@ -660,5 +673,25 @@ assertTrue( time < copiedFile.lastModified() ); } + + public void testCopyFileWithOverideLocalRepo() + throws IOException, MojoExecutionException + { + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + + mojo.setArtifactItems( list ); + mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) ); + + File execLocalRepo = new File( this.testDir.getAbsolutePath(), "executionLocalRepo" ); + assertFalse( execLocalRepo.exists() ); + + mojo.setLocalRepositoryDirectory( execLocalRepo ); + + assertEquals( execLocalRepo.getAbsolutePath(), mojo.getLocal().getBasedir() ); + mojo.execute(); + + assertFilesExist( list, true ); + + } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestUnpackMojo.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestUnpackMojo.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestUnpackMojo.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestUnpackMojo.java 2011-08-08 21:28:42.000000000 +0000 @@ -23,9 +23,10 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.Collections; import java.util.List; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -80,8 +81,8 @@ public ArtifactItem getSingleArtifactItem( boolean removeVersion ) throws MojoExecutionException { - ArrayList list = mojo.getProcessedArtifactItems( removeVersion ); - return (ArtifactItem) list.get( 0 ); + List list = mojo.getProcessedArtifactItems( removeVersion ); + return list.get( 0 ); } public void testGetArtifactItems() @@ -94,7 +95,7 @@ item.setGroupId( "groupId" ); item.setVersion( "1.0" ); - ArrayList list = new ArrayList( 1 ); + ArrayList list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -108,12 +109,11 @@ assertEquals( output, result.getOutputDirectory() ); } - public void assertMarkerFiles( Collection items, boolean exist ) + public void assertMarkerFiles( Collection items, boolean exist ) { - Iterator iter = items.iterator(); - while ( iter.hasNext() ) + for ( ArtifactItem item : items ) { - assertMarkerFile( exist, (ArtifactItem) iter.next() ); + assertMarkerFile( exist, item ); } } @@ -133,7 +133,7 @@ public void testUnpackFile() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); mojo.setArtifactItems( list ); @@ -141,11 +141,24 @@ assertMarkerFiles( list, true ); } + + public void testSkip() + throws IOException, MojoExecutionException + { + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + + mojo.setSkip( true ); + mojo.setArtifactItems( list ); + + mojo.execute(); + + assertMarkerFiles( list, false ); + } public void testUnpackToLocation() throws IOException, MojoExecutionException { - ArrayList list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); + List list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); ArtifactItem item = (ArtifactItem) list.get( 0 ); item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) ); @@ -166,7 +179,7 @@ item.setGroupId( "groupId" ); item.setType( "type" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -181,7 +194,7 @@ } } - public List getDependencyList( ArtifactItem item ) + public List getDependencyList( ArtifactItem item ) { Dependency dep = new Dependency(); dep.setArtifactId( item.getArtifactId() ); @@ -197,7 +210,7 @@ dep2.setType( item.getType() ); dep2.setVersion( "2.1" ); - List list = new ArrayList( 2 ); + List list = new ArrayList( 2 ); list.add( dep2 ); list.add( dep ); @@ -214,7 +227,7 @@ item.setGroupId( "groupId" ); item.setType( "jar" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -236,7 +249,7 @@ item.setGroupId( "groupId" ); item.setType( "war" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -248,7 +261,7 @@ assertEquals( "2.1", item.getVersion() ); } - public List getDependencyMgtList( ArtifactItem item ) + public List getDependencyMgtList( ArtifactItem item ) { Dependency dep = new Dependency(); dep.setArtifactId( item.getArtifactId() ); @@ -264,7 +277,7 @@ dep2.setType( item.getType() ); dep2.setVersion( "3.1" ); - List list = new ArrayList( 2 ); + List list = new ArrayList( 2 ); list.add( dep2 ); list.add( dep ); @@ -291,7 +304,7 @@ item.setGroupId( "groupId" ); item.setType( "jar" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -323,7 +336,7 @@ item.setGroupId( "groupId" ); item.setType( "jar" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -359,7 +372,7 @@ item.setType( "type" ); item.setVersion( "1.0" ); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add( item ); mojo.setArtifactItems( list ); @@ -409,7 +422,7 @@ ArtifactItem item = new ArtifactItem( release ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -429,7 +442,7 @@ ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -449,7 +462,7 @@ ArtifactItem item = new ArtifactItem( release ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -469,7 +482,7 @@ ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); + List list = new ArrayList( 1 ); list.add( item ); mojo.setArtifactItems( list ); @@ -484,39 +497,55 @@ public void testUnpackOverWriteIfNewer() throws IOException, MojoExecutionException, InterruptedException { + final long now = System.currentTimeMillis(); + + mojo.silent = false; stubFactory.setCreateFiles( true ); Artifact artifact = stubFactory.getSnapshotArtifact(); - artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 ); + assertTrue( artifact.getFile().setLastModified( now - 20000 ) ); ArtifactItem item = new ArtifactItem( artifact ); - ArrayList list = new ArrayList( 1 ); - list.add( item ); + List list = Collections.singletonList( item ); mojo.setArtifactItems( list ); mojo.setOverWriteIfNewer( true ); mojo.execute(); File unpackedFile = getUnpackedFile( item ); // round down to the last second - long time = System.currentTimeMillis(); + long time = now; time = time - ( time % 1000 ); // go back 10 more seconds for linux time -= 10000; // set to known value - unpackedFile.setLastModified( time ); - // set source to be newer - artifact.getFile().setLastModified( time + 4000 ); + assertTrue( unpackedFile.setLastModified( time ) ); + // set source to be newer was 4s but test is brittle on MacOS if less than 5s + assertTrue( artifact.getFile().setLastModified( time + 5000 ) ); - // manually set markerfile (must match getMarkerFile in - // DefaultMarkerFileHandler) + // manually set markerfile (must match getMarkerFile in DefaultMarkerFileHandler) File marker = new File( mojo.getMarkersDirectory(), artifact.getId().replace( ':', '-' ) + ".marker" ); - marker.setLastModified( time ); + assertTrue( marker.setLastModified( time ) ); - assertTrue( time == unpackedFile.lastModified() ); + displayFile( "unpackedFile", unpackedFile ); + displayFile( "artifact ", artifact.getFile() ); + displayFile( "marker ", marker ); + System.out.println( "mojo.execute()" ); mojo.execute(); - assertTrue( time != unpackedFile.lastModified() ); + displayFile( "unpackedFile", unpackedFile ); + displayFile( "artifact ", artifact.getFile() ); + displayFile( "marker ", marker ); + System.out.println( "marker.lastModified() = " + marker.lastModified() ); + System.out.println( "unpackedFile.lastModified() = " + unpackedFile.lastModified() ); + assertTrue( "unpackedFile '" + unpackedFile + "' lastModified() == " + marker.lastModified() + ": should be different", + marker.lastModified() != unpackedFile.lastModified() ); } + private void displayFile( String description, File file ) + { + System.out.println( description + ' ' + DateFormatUtils.ISO_DATETIME_FORMAT.format( file.lastModified() ) + ' ' + + file.getPath().substring( getBasedir().length() ) ); + } + public void assertUnpacked( ArtifactItem item, boolean overWrite ) throws InterruptedException, MojoExecutionException { @@ -544,8 +573,9 @@ public File getUnpackedFile( ArtifactItem item ) { - File unpackedFile = new File( item.getOutputDirectory(), DependencyArtifactStubFactory.getUnpackableFileName( item - .getArtifact() ) ); + File unpackedFile = + new File( item.getOutputDirectory(), + DependencyArtifactStubFactory.getUnpackableFileName( item.getArtifact() ) ); assertTrue( unpackedFile.exists() ); return unpackedFile; diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,3 +1,5 @@ +package org.apache.maven.plugin.dependency.its; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -16,12 +18,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.plugin.dependency.its; import java.io.File; import java.net.MalformedURLException; import java.util.ArrayList; -import java.util.Iterator; +import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -85,7 +86,7 @@ /** * @see org.codehaus.plexus.PlexusTestCase#setUp() */ - protected void setUp () + protected void setUp() throws Exception { if ( !installed ) @@ -145,19 +146,17 @@ /** * @see org.codehaus.plexus.PlexusTestCase#tearDown() */ - protected void tearDown () + protected void tearDown() throws Exception { super.tearDown(); - List containers = new ArrayList(); + List containers = new ArrayList(); containers.add( getContainer() ); - for ( Iterator iter = containers.iterator(); iter.hasNext(); ) + for ( PlexusContainer container : containers ) { - PlexusContainer container = (PlexusContainer) iter.next(); - if ( container != null ) { container.dispose(); @@ -180,7 +179,7 @@ * execute * @throws Exception any exception generated during test */ - protected void testProject ( String projectName, String goalList ) + protected void testProject( String projectName, String goalList ) throws Exception { Properties props = new Properties(); @@ -196,21 +195,14 @@ * execute * @throws Exception any exception generated during test */ - protected void testProject ( String projectName, Properties properties, String goalList ) + protected void testProject( String projectName, Properties properties, String goalList ) throws Exception { File theBasedir = getTestFile( "target/test-classes/its/" + projectName ); File pom = new File( theBasedir, "pom.xml" ); - String[] goal = goalList.split( "," ); - - List goals = new ArrayList(); - - for ( int i = 0; i < goal.length; i++ ) - { - goals.add( goal[i] ); - } + List goals = Arrays.asList( goalList.split( "," ) ); executeMaven( pom, properties, goals ); @@ -230,18 +222,18 @@ */ } - protected File getOutputDirectory ( String projectName ) + protected File getOutputDirectory( String projectName ) { return getTestFile( "target/test-classes/projects/" + projectName ); } - protected void executeMaven ( File pom, Properties properties, List goals ) + protected void executeMaven( File pom, Properties properties, List goals ) throws TestToolsException, ExecutionFailedException { executeMaven( pom, properties, goals, true ); } - protected void executeMaven ( File pom, Properties properties, List goals, boolean switchLocalRepo ) + protected void executeMaven( File pom, Properties properties, List goals, boolean switchLocalRepo ) throws TestToolsException, ExecutionFailedException { // insert the test property to activate the test @@ -249,15 +241,10 @@ properties.setProperty( "test", "true" ); new File( BUILD_OUTPUT_DIRECTORY ).mkdirs(); - NullPointerException npe = new NullPointerException(); - StackTraceElement[] trace = npe.getStackTrace(); - File buildLog = null; - for ( int i = 0; i < trace.length; i++ ) + for ( StackTraceElement element : new NullPointerException().getStackTrace() ) { - StackTraceElement element = trace[i]; - String methodName = element.getMethodName(); if ( methodName.startsWith( "test" ) && !methodName.equals( "testProject" ) ) @@ -307,13 +294,13 @@ } } - protected MavenProject readProject ( File pom ) + protected MavenProject readProject( File pom ) throws TestToolsException { return projectTool.readProject( pom, localRepositoryDirectory ); } - protected String getPluginCLISpecification () + protected String getPluginCLISpecification() { String pluginSpec = GROUP_ID + ":" + ARTIFACT_ID + ":"; diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java 2011-10-26 17:42:34.000000000 +0000 @@ -1,3 +1,5 @@ +package org.apache.maven.plugin.dependency.its; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -16,7 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.plugin.dependency.its; /** * This class executes the IT tests. The setup will create a pom-test.xml from the plugin pom. The version is changed to @@ -25,7 +26,7 @@ * Each test below just uses the tools to execute Maven on the named project with the passed in goals. * * @author Brian Fox Copied from the Eclipse AbstractEclipsePluginTestCase v2.4 - * @version $Id: DependencyPluginTest.java 728546 2008-12-21 22:56:51Z bentmann $ + * @version $Id: DependencyPluginTest.java 1189335 2011-10-26 17:42:34Z carlos $ */ public class DependencyPluginTest extends AbstractDependencyPluginITCase @@ -74,4 +75,15 @@ { // testProject( "resolve", "dependency:resolve" ); } + + /** + * Test Resolve Mojo. Simple Harness test essentially + * + * @throws Exception any exception thrown during test + */ + public void testGet() + throws Exception + { + // testProject( "resolve", "dependency:get" ); + } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,3 +1,5 @@ +package org.apache.maven.plugin.dependency.its; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -16,7 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.plugin.dependency.its; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.MavenInvocationException; diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/DependencyArtifactStubFactory.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/DependencyArtifactStubFactory.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/DependencyArtifactStubFactory.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/DependencyArtifactStubFactory.java 2011-03-13 00:17:39.000000000 +0000 @@ -22,14 +22,14 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem; import org.apache.maven.plugin.testing.ArtifactStubFactory; public class DependencyArtifactStubFactory -extends ArtifactStubFactory + extends ArtifactStubFactory { /** @@ -47,13 +47,12 @@ return item; } - public ArrayList getArtifactItems( Collection artifacts ) + public List getArtifactItems( Collection artifacts ) { - ArrayList list = new ArrayList(); - Iterator iter = artifacts.iterator(); - while ( iter.hasNext() ) + List list = new ArrayList(); + for ( Artifact artifact : artifacts ) { - list.add( getArtifactItem( (Artifact) iter.next() ) ); + list.add( getArtifactItem( artifact ) ); } return list; } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependencies2ProjectStub.java 2009-04-08 21:31:43.000000000 +0000 @@ -0,0 +1,69 @@ +package org.apache.maven.plugin.dependency.testUtils.stubs; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileReader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + +/** + * very simple stub of maven project, going to take a lot of work to make it + * useful as a stub though + */ +public class DuplicateDependencies2ProjectStub + extends MavenProjectStub +{ + public DuplicateDependencies2ProjectStub() + { + File pom = new File( getBasedir(), "plugin-config2.xml" ); + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = null; + + try + { + model = pomReader.read( new FileReader( pom ) ); + setModel( model ); + } + catch ( Exception e ) + { + throw new RuntimeException( e ); + } + + setGroupId( model.getGroupId() ); + setArtifactId( model.getArtifactId() ); + setVersion( model.getVersion() ); + setName( model.getName() ); + setUrl( model.getUrl() ); + setPackaging( model.getPackaging() ); + setFile( pom ); + } + + + /** + * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir() + */ + public File getBasedir() + { + return new File( super.getBasedir() + "/src/test/resources/unit/duplicate-dependencies" ); + } +} diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DuplicateDependenciesProjectStub.java 2009-04-08 21:31:43.000000000 +0000 @@ -0,0 +1,69 @@ +package org.apache.maven.plugin.dependency.testUtils.stubs; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileReader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + +/** + * very simple stub of maven project, going to take a lot of work to make it + * useful as a stub though + */ +public class DuplicateDependenciesProjectStub + extends MavenProjectStub +{ + public DuplicateDependenciesProjectStub() + { + File pom = new File( getBasedir(), "plugin-config.xml" ); + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = null; + + try + { + model = pomReader.read( new FileReader( pom ) ); + setModel( model ); + } + catch ( Exception e ) + { + throw new RuntimeException( e ); + } + + setGroupId( model.getGroupId() ); + setArtifactId( model.getArtifactId() ); + setVersion( model.getVersion() ); + setName( model.getName() ); + setUrl( model.getUrl() ); + setPackaging( model.getPackaging() ); + setFile( pom ); + } + + + /** + * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir() + */ + public File getBasedir() + { + return new File( super.getBasedir() + "/src/test/resources/unit/duplicate-dependencies" ); + } +} diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java 2010-11-06 12:21:39.000000000 +0000 @@ -1,5 +1,24 @@ package org.apache.maven.plugin.dependency.testUtils.stubs; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem; diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyStatusSets.java 2011-03-13 00:17:39.000000000 +0000 @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.dependency.AbstractDependencyMojoTestCase; public class TestDependencyStatusSets @@ -60,7 +61,7 @@ public void testDependencyStatusLog() throws IOException { - Set artifacts = this.stubFactory.getMixedArtifacts(); + Set artifacts = this.stubFactory.getMixedArtifacts(); doTestDependencyStatusLog( artifacts ); } @@ -68,16 +69,16 @@ throws IOException { this.stubFactory.setCreateFiles( false ); - Set artifacts = this.stubFactory.getMixedArtifacts(); + Set artifacts = this.stubFactory.getMixedArtifacts(); doTestDependencyStatusLog( artifacts ); } public void testDependencyStatusEmptySet() { - doTestDependencyStatusLog( new HashSet() ); + doTestDependencyStatusLog( new HashSet() ); } - public void doTestDependencyStatusLog( Set artifacts ) + public void doTestDependencyStatusLog( Set artifacts ) { // TODO: implement logger to check correct output // this test is just looking for unexpected exceptions. diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/TestDependencyUtil.java 2011-11-10 03:05:47.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.io.File; import java.util.ArrayList; @@ -37,6 +34,7 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; +import org.codehaus.plexus.util.StringUtils; /** * @author brianf @@ -45,7 +43,7 @@ public class TestDependencyUtil extends TestCase { - List artifacts = new ArrayList(); + List artifacts = new ArrayList(); Log log = new SilentLog(); @@ -92,71 +90,81 @@ throws MojoExecutionException { File folder = new File( "target/a" ); - final Artifact artifact = (Artifact) artifacts.get( 0 ); - File name = DependencyUtil.getFormattedOutputDirectory( false, false, false, false, folder, artifact ); + final Artifact artifact = artifacts.get( 0 ); + File name = DependencyUtil.getFormattedOutputDirectory( false, false, false, false, false, folder, artifact ); // object is the same. assertEquals( folder, name ); - name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, false, true, false, folder, artifact ); String expectedResult = folder.getAbsolutePath() + File.separatorChar + "test" + File.separatorChar + "one" + File.separatorChar + "1.1"; assertTrue( expectedResult.equalsIgnoreCase( name.getAbsolutePath() ) ); - name = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "jars"; assertTrue( expectedResult.equalsIgnoreCase( name.getAbsolutePath() ) ); - name = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, false, folder, artifact ); + expectedResult = folder.getAbsolutePath() + File.separatorChar + "compile"; + assertEquals( expectedResult, name.getAbsolutePath() ); + assertTrue( expectedResult.equalsIgnoreCase( name.getAbsolutePath() ) ); + + name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "one-sources-1.1-jar"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "one-sources-jar"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( true, true, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "jars" + File.separatorChar + "one-sources-1.1-jar"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( true, true, false, true, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "jars" + File.separatorChar + "one-sources-jar"; assertEquals( expectedResult, name.getAbsolutePath() ); + + name = DependencyUtil.getFormattedOutputDirectory( true, false, true, false, true, folder, artifact ); + expectedResult = folder.getAbsolutePath() + File.separatorChar + "compile" + File.separatorChar + + "one-sources-jar"; + assertEquals( expectedResult, name.getAbsolutePath() ); } public void testDirectoryName2() throws MojoExecutionException { File folder = new File( "target/a" ); - final Artifact artifact = (Artifact) artifacts.get( 1 ); - File name = DependencyUtil.getFormattedOutputDirectory( false, false, false, false, folder, artifact ); + final Artifact artifact = artifacts.get( 1 ); + File name = DependencyUtil.getFormattedOutputDirectory( false, false, false, false, false, folder, artifact ); // object is the same. assertEquals( folder, name ); - name = DependencyUtil.getFormattedOutputDirectory( true, false, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false, folder, artifact ); String expectedResult = folder.getAbsolutePath() + File.separatorChar + "wars"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, false, true, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "test" + File.separatorChar + "two" + File.separatorChar + "1.1-SNAPSHOT"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "two-1.1-SNAPSHOT-war"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( true, true, false, false, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, false, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "wars" + File.separatorChar + "two-1.1-SNAPSHOT-war"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "two-war"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( true, true, false, true, folder, artifact ); + name = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, folder, artifact ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "wars" + File.separatorChar + "two-war"; assertEquals( expectedResult, name.getAbsolutePath() ); } @@ -165,11 +173,11 @@ throws MojoExecutionException { File folder = new File( "target/a" ); - File name = DependencyUtil.getFormattedOutputDirectory( false, true, false, true, folder, sources ); + File name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, folder, sources ); String expectedResult = folder.getAbsolutePath() + File.separatorChar + "two-sources"; assertEquals( expectedResult, name.getAbsolutePath() ); - name = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, folder, sources ); + name = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, folder, sources ); expectedResult = folder.getAbsolutePath() + File.separatorChar + "two-sources-1.1-SNAPSHOT-sources"; assertEquals( expectedResult, name.getAbsolutePath() ); } @@ -177,7 +185,7 @@ public void testFileName() throws MojoExecutionException { - Artifact artifact = (Artifact) artifacts.get( 0 ); + Artifact artifact = artifacts.get( 0 ); String name = DependencyUtil.getFormattedFileName( artifact, false ); String expectedResult = "one-1.1-sources.jar"; @@ -239,7 +247,7 @@ artifact.setFile( file ); String name = DependencyUtil.getFormattedFileName( artifact, false ); - String expectedResult = "test-file-name.jar"; + String expectedResult = "two-1.1-SNAPSHOT-sources.war"; assertEquals( expectedResult, name ); name = DependencyUtil.getFormattedFileName( artifact, true ); @@ -259,4 +267,24 @@ assertEquals( expectedResult, name ); } + + public void testTokenizer() + { + String [] tokens = DependencyUtil.tokenizer( " alpha,bravo, charlie , delta kappa, theta" ); + String[] expected = new String[] { "alpha", "bravo", "charlie", "delta kappa", "theta" }; + // easier to see in the JUnit reports + assertEquals( StringUtils.join( expected, ", " ), StringUtils.join( tokens, ", " ) ); + assertEquals( expected.length, tokens.length ); + + tokens = DependencyUtil.tokenizer( " \r\n a, \t \n \r b \t \n \r" ); + assertEquals( 2, tokens.length ); + assertEquals( "a", tokens[0] ); + assertEquals( "b", tokens[1] ); + + tokens = DependencyUtil.tokenizer( null ); + assertEquals( 0, tokens.length ); + + tokens = DependencyUtil.tokenizer( " " ); + assertEquals( 0, tokens.length ); + } } diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestDestFileFilter.java 2011-03-27 15:51:44.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.io.File; import java.io.IOException; @@ -45,7 +42,7 @@ public class TestDestFileFilter extends TestCase { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Log log = new SilentLog(); @@ -82,9 +79,9 @@ boolean removeVersion ) throws IOException { - File destFolder = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerType, - useSubDirectoryPerArtifact, false, false, - outputFolder, artifact ); + File destFolder = + DependencyUtil.getFormattedOutputDirectory( false, useSubDirectoryPerType, useSubDirectoryPerArtifact, + false, false, outputFolder, artifact ); File destFile = new File( destFolder, DependencyUtil.getFormattedFileName( artifact, removeVersion ) ); destFile.getParentFile().mkdirs(); @@ -102,7 +99,7 @@ createFile( artifact ); assertFalse( filter.isArtifactIncluded( artifact) ); - filter.overWriteReleases = true; + filter.setOverWriteReleases( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); } @@ -116,7 +113,7 @@ createFile( artifact ); assertFalse( filter.isArtifactIncluded( artifact ) ); - filter.overWriteSnapshots = true; + filter.setOverWriteSnapshots( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); } @@ -125,13 +122,13 @@ { DestFileFilter filter = new DestFileFilter( outputFolder ); Artifact artifact = fact.getSnapshotArtifact(); - filter.removeVersion = true; + filter.setRemoveVersion( true ); assertTrue( filter.isArtifactIncluded( artifact) ); createFile( artifact, false, false, true ); assertFalse( filter.isArtifactIncluded( artifact ) ); - filter.overWriteSnapshots = true; + filter.setOverWriteSnapshots( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); } @@ -140,13 +137,13 @@ { DestFileFilter filter = new DestFileFilter( outputFolder ); Artifact artifact = fact.getSnapshotArtifact(); - filter.useSubDirectoryPerArtifact = true; + filter.setUseSubDirectoryPerArtifact( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); createFile( artifact, true, false, false ); assertFalse( filter.isArtifactIncluded( artifact ) ); - filter.overWriteSnapshots = true; + filter.setOverWriteSnapshots( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); } @@ -155,13 +152,13 @@ { DestFileFilter filter = new DestFileFilter( outputFolder ); Artifact artifact = fact.getSnapshotArtifact(); - filter.useSubDirectoryPerType = true; + filter.setUseSubDirectoryPerType( true ); assertTrue( filter.isArtifactIncluded( artifact) ); createFile( artifact, false, true, false ); assertFalse( filter.isArtifactIncluded( artifact ) ); - filter.overWriteSnapshots = true; + filter.setOverWriteSnapshots( true ); assertTrue( filter.isArtifactIncluded( artifact ) ); } @@ -174,7 +171,7 @@ Artifact artifact = fact.getSnapshotArtifact(); File artifactFile = artifact.getFile(); artifactFile.setLastModified( artifactFile.lastModified() ); - filter.overWriteIfNewer = true; + filter.setOverWriteIfNewer( true ); // should pass because the file doesn't exist yet. assertTrue( filter.isArtifactIncluded( artifact) ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java 2011-03-13 00:17:39.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.io.File; import java.io.IOException; @@ -45,7 +42,7 @@ public class TestMarkerFileFilter extends TestCase { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Log log = new SilentLog(); @@ -76,7 +73,7 @@ { MarkerFileFilter filter = new MarkerFileFilter( true, true, false, new DefaultFileMarkerHandler( outputFolder ) ); - Set result = filter.filter( artifacts ); + Set result = filter.filter( artifacts ); assertEquals( 2, result.size() ); filter.setOverWriteReleases( false ); @@ -92,7 +89,7 @@ handler.setMarker(); MarkerFileFilter filter = new MarkerFileFilter( true, false, false, new DefaultFileMarkerHandler( outputFolder ) ); - Set result = filter.filter( artifacts ); + Set result = filter.filter( artifacts ); assertEquals( 1, result.size() ); filter.setOverWriteSnapshots( true ); @@ -111,7 +108,7 @@ MarkerFileFilter filter = new MarkerFileFilter( false, false, false, new DefaultFileMarkerHandler( outputFolder ) ); - Set result = filter.filter( artifacts); + Set result = filter.filter( artifacts ); assertEquals( 1, result.size() ); filter.setOverWriteReleases( true ); @@ -126,19 +123,27 @@ public void testMarkerTimestamp() throws IOException, MojoExecutionException, ArtifactFilterException { + // filter includes release artifact because no marker present + // filter includes snapshot artifact becaues it is newer than marker DependencyArtifactStubFactory fileFact = new DependencyArtifactStubFactory( outputFolder, true ); Artifact snap = fileFact.getSnapshotArtifact(); Artifact release = fileFact.getReleaseArtifact(); - HashSet tempArtifacts = new HashSet(); + Set tempArtifacts = new HashSet(); tempArtifacts.add( snap ); tempArtifacts.add( release ); - snap.getFile().setLastModified( snap.getFile().lastModified() + 1500 ); DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( snap, outputFolder ); handler.setMarker(); + snap.getFile().setLastModified( snap.getFile().lastModified() + 1500 ); MarkerFileFilter filter = new MarkerFileFilter( false, false, true, new DefaultFileMarkerHandler( outputFolder ) ); - Set result = filter.filter( tempArtifacts); + Set result = filter.filter( tempArtifacts ); assertEquals( 2, result.size() ); + // update marker; filter won't include snapshot because timestamps equal + handler.setMarker(); + result = filter.filter( tempArtifacts ); + assertEquals( 1, result.size() ); + + // filter won't include snapshot because it is older than marker snap.getFile().setLastModified( snap.getFile().lastModified() - 10000 ); result = filter.filter( tempArtifacts ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestResolveMarkerFileFilter.java 2011-03-13 00:17:39.000000000 +0000 @@ -45,7 +45,7 @@ public class TestResolveMarkerFileFilter extends TestCase { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); Log log = new SilentLog(); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestDefaultMarkerFileHandler.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestDefaultMarkerFileHandler.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestDefaultMarkerFileHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestDefaultMarkerFileHandler.java 2011-03-13 00:17:39.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.io.File; import java.io.IOException; @@ -47,7 +44,7 @@ public class TestDefaultMarkerFileHandler extends TestCase { - List artifacts = new ArrayList(); + List artifacts = new ArrayList(); Log log = new SilentLog(); @@ -83,7 +80,7 @@ public void testSetMarker() throws MojoExecutionException { - DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifacts.get( 0 ), this.outputFolder ); assertFalse( handler.isMarkerSet() ); handler.setMarker(); @@ -105,7 +102,7 @@ public void testMarkerFile() throws MojoExecutionException, IOException { - DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifacts.get( 0 ), this.outputFolder ); File handle = handler.getMarkerFile(); @@ -132,7 +129,7 @@ File theFile = new File( outputFolder, "theFile.jar" ); outputFolder.mkdirs(); theFile.createNewFile(); - Artifact theArtifact = (Artifact) artifacts.get( 0 ); + Artifact theArtifact = artifacts.get( 0 ); theArtifact.setFile( theFile ); DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( theArtifact, this.outputFolder ); assertFalse( handler.isMarkerSet() ); @@ -153,7 +150,7 @@ public void testMarkerFileException() { // this stub wraps the file with an object to throw exceptions - StubDefaultFileMarkerHandler handler = new StubDefaultFileMarkerHandler( (Artifact) artifacts.get( 0 ), + StubDefaultFileMarkerHandler handler = new StubDefaultFileMarkerHandler( artifacts.get( 0 ), this.outputFolder ); try { @@ -170,7 +167,7 @@ { DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( null, null ); assertTrue( handler.getArtifact() == null ); - handler.setArtifact( (Artifact) artifacts.get( 0 ) ); + handler.setArtifact( artifacts.get( 0 ) ); assertSame( artifacts.get( 0 ), handler.getArtifact() ); assertTrue( handler.getMarkerFilesDirectory() == null ); @@ -185,7 +182,7 @@ // folder. We must clear the // marker to avoid leaving test droppings in root. DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( null, null ); - handler.setArtifact( (Artifact) artifacts.get( 0 ) ); + handler.setArtifact( artifacts.get( 0 ) ); handler.setMarker(); assertTrue( handler.isMarkerSet() ); handler.clearMarker(); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestSourcesMarkerFileHandler.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestSourcesMarkerFileHandler.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestSourcesMarkerFileHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestSourcesMarkerFileHandler.java 2011-03-13 00:17:39.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.io.File; import java.io.IOException; @@ -47,7 +44,7 @@ public class TestSourcesMarkerFileHandler extends TestCase { - List artifacts = new ArrayList(); + List artifacts = new ArrayList(); Log log = new SilentLog(); @@ -84,7 +81,7 @@ public void testSetMarkerResolved() throws MojoExecutionException { - DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, true ); assertFalse( handler.isMarkerSet() ); handler.setMarker(); @@ -105,7 +102,7 @@ public void testSetMarkerUnresolved() throws MojoExecutionException { - DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, false ); assertFalse( handler.isMarkerSet() ); handler.setMarker(); @@ -126,9 +123,9 @@ public void testBothMarkers() throws MojoExecutionException { - DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 1 ), + DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( artifacts.get( 1 ), this.outputFolder, true ); - DefaultFileMarkerHandler handler2 = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 1 ), + DefaultFileMarkerHandler handler2 = new SourcesFileMarkerHandler( artifacts.get( 1 ), this.outputFolder, false ); handler.setMarker(); @@ -145,9 +142,9 @@ public void testMarkerFile() throws MojoExecutionException, IOException { - DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, true ); - DefaultFileMarkerHandler handler2 = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + DefaultFileMarkerHandler handler2 = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, false ); File handle = handler.getMarkerFile(); @@ -219,11 +216,11 @@ File theFile = new File( outputFolder, "theFile.jar" ); outputFolder.mkdirs(); theFile.createNewFile(); - Artifact theArtifact = (Artifact) artifacts.get( 0 ); + Artifact theArtifact = artifacts.get( 0 ); theArtifact.setFile( theFile ); - SourcesFileMarkerHandler resolvedHandler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + SourcesFileMarkerHandler resolvedHandler = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, resolved ); - SourcesFileMarkerHandler unResolvedHandler = new SourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + SourcesFileMarkerHandler unResolvedHandler = new SourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, !resolved ); assertFalse( resolvedHandler.isMarkerSet() ); @@ -253,7 +250,7 @@ public void testMarkerFileException() { // this stub wraps the file with an object to throw exceptions - StubSourcesFileMarkerHandler handler = new StubSourcesFileMarkerHandler( (Artifact) artifacts.get( 0 ), + StubSourcesFileMarkerHandler handler = new StubSourcesFileMarkerHandler( artifacts.get( 0 ), this.outputFolder, true ); try { @@ -280,7 +277,7 @@ // folder. We must clear the // marker to avoid leaving test droppings in root. DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( null, null, false ); - handler.setArtifact( (Artifact) artifacts.get( 0 ) ); + handler.setArtifact( artifacts.get( 0 ) ); handler.setMarker(); assertTrue( handler.isMarkerSet() ); handler.clearMarker(); @@ -294,7 +291,7 @@ // folder. We must clear the // marker to avoid leaving test droppings in root. DefaultFileMarkerHandler handler = new SourcesFileMarkerHandler( null, null, true ); - handler.setArtifact( (Artifact) artifacts.get( 0 ) ); + handler.setArtifact( artifacts.get( 0 ) ); handler.setMarker(); assertTrue( handler.isMarkerSet() ); handler.clearMarker(); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java 2011-03-13 00:17:39.000000000 +0000 @@ -1,5 +1,24 @@ package org.apache.maven.plugin.dependency.utils.markers; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -18,7 +37,7 @@ public class TestUnpackMarkerFileHandler extends AbstractMojoTestCase { - List artifactItems = new ArrayList(); + List artifactItems = new ArrayList(); Log log = new SilentLog(); @@ -42,15 +61,15 @@ Artifact artifact = stubFactory.createArtifact( "test", "test", "1" ); ArtifactItem artifactItem = stubFactory.getArtifactItem( artifact ); artifactItems.add( stubFactory.getArtifactItem( stubFactory.createArtifact( "test", "test", "1" ) ) ); - artifact = stubFactory.createArtifact("test2", "test2", "2"); + artifact = stubFactory.createArtifact( "test2", "test2", "2" ); artifactItem = new ArtifactItem( artifact ); artifactItem.setIncludes( "**/*.xml" ); artifactItems.add( artifactItem ); - artifact = stubFactory.createArtifact("test3", "test3", "3"); + artifact = stubFactory.createArtifact( "test3", "test3", "3" ); artifactItem = new ArtifactItem( artifact ); artifactItem.setExcludes( "**/*.class" ); artifactItems.add( artifactItem ); - artifact = stubFactory.createArtifact("test4", "test4", "4"); + artifact = stubFactory.createArtifact( "test4", "test4", "4" ); artifactItem = new ArtifactItem( artifact ); artifactItem.setIncludes( "**/*.xml" ); artifactItem.setExcludes( "**/*.class" ); @@ -76,7 +95,7 @@ public void testSetMarker() throws MojoExecutionException { - UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ), + UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( artifactItems.get( 0 ), this.outputFolder ); assertFalse( handler.isMarkerSet() ); handler.setMarker(); @@ -98,7 +117,7 @@ public void testMarkerFile() throws MojoExecutionException, IOException { - UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ), + UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( artifactItems.get( 0 ), this.outputFolder ); File handle = handler.getMarkerFile(); @@ -125,7 +144,7 @@ File theFile = new File( outputFolder, "theFile.jar" ); outputFolder.mkdirs(); theFile.createNewFile(); - ArtifactItem theArtifactItem = (ArtifactItem) artifactItems.get( 0 ); + ArtifactItem theArtifactItem = artifactItems.get( 0 ); Artifact theArtifact = theArtifactItem.getArtifact(); theArtifact.setFile( theFile ); UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( theArtifactItem, this.outputFolder ); @@ -147,7 +166,7 @@ public void testMarkerFileException() { // this stub wraps the file with an object to throw exceptions - StubUnpackFileMarkerHandler handler = new StubUnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ), + StubUnpackFileMarkerHandler handler = new StubUnpackFileMarkerHandler( artifactItems.get( 0 ), this.outputFolder ); try { @@ -165,9 +184,9 @@ UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null ); assertTrue( handler.getArtifactItem() == null ); assertTrue( handler.getArtifact() == null ); - handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) ); + handler.setArtifactItem( artifactItems.get( 0 ) ); assertSame( artifactItems.get( 0 ), handler.getArtifactItem() ); - assertSame( ((ArtifactItem) artifactItems.get( 0 )).getArtifact(), handler.getArtifact() ); + assertSame( artifactItems.get( 0 ).getArtifact(), handler.getArtifact() ); assertTrue( handler.getMarkerFilesDirectory() == null ); handler.setMarkerFilesDirectory( outputFolder ); @@ -181,7 +200,7 @@ // folder. We must clear the // marker to avoid leaving test droppings in root. UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null ); - handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) ); + handler.setArtifactItem( artifactItems.get( 0 ) ); handler.setMarker(); assertTrue( handler.isMarkerSet() ); handler.clearMarker(); @@ -191,7 +210,7 @@ public void testIncludesMarker() throws MojoExecutionException, IOException { - UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 1 ), outputFolder ); + UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( artifactItems.get( 1 ), outputFolder ); File handle = handler.getMarkerFile(); assertFalse( handle.exists() ); assertFalse( handler.isMarkerSet() ); @@ -215,7 +234,7 @@ public void testExcludesMarker() throws MojoExecutionException, IOException { - UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 2 ), outputFolder ); + UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( artifactItems.get( 2 ), outputFolder ); File handle = handler.getMarkerFile(); assertFalse( handle.exists() ); assertFalse( handler.isMarkerSet() ); @@ -239,7 +258,7 @@ public void testIncludesExcludesMarker() throws MojoExecutionException, IOException { - UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 3 ), outputFolder ); + UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( artifactItems.get( 3 ), outputFolder ); File handle = handler.getMarkerFile(); assertFalse( handle.exists() ); assertFalse( handler.isMarkerSet() ); diff -Nru maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java --- maven-dependency-plugin-2.1/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java 2008-12-21 22:56:51.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java 2011-03-13 00:17:39.000000000 +0000 @@ -18,9 +18,6 @@ * specific language governing permissions and limitations * under the License. */ -/** - * - */ import java.util.HashMap; import java.util.HashSet; @@ -44,7 +41,7 @@ public class TestClassifierTypeTranslator extends AbstractDependencyMojoTestCase { - Set artifacts = new HashSet(); + Set artifacts = new HashSet(); ArtifactFactory artifactFactory; @@ -80,18 +77,15 @@ String type = "zip"; ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory ); - Set results = at.translate( artifacts, log ); + Set results = at.translate( artifacts, log ); - Iterator iter = artifacts.iterator(); - - while ( iter.hasNext() ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iter.next(); - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while ( !found && resultIter.hasNext() ) { - Artifact translatedArtifact = (Artifact) resultIter.next(); + Artifact translatedArtifact = resultIter.next(); if ( artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId() && artifact.getScope() == translatedArtifact.getScope() ) @@ -123,18 +117,15 @@ String classifier = "jdk5"; ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory ); - Set results = at.translate( artifacts, log ); - - Iterator iter = artifacts.iterator(); + Set results = at.translate( artifacts, log ); - while ( iter.hasNext() ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iter.next(); - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while ( !found && resultIter.hasNext() ) { - Artifact translatedArtifact = (Artifact) resultIter.next(); + Artifact translatedArtifact = resultIter.next(); if ( artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId() && artifact.getScope() == translatedArtifact.getScope() ) @@ -156,18 +147,15 @@ String classifier = "jdk14"; String type = "sources"; ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory ); - Set results = at.translate( artifacts, log ); - - Iterator iter = artifacts.iterator(); + Set results = at.translate( artifacts, log ); - while ( iter.hasNext() ) + for ( Artifact artifact : artifacts ) { - Artifact artifact = (Artifact) iter.next(); - Iterator resultIter = results.iterator(); + Iterator resultIter = results.iterator(); boolean found = false; while ( !found && resultIter.hasNext() ) { - Artifact translatedArtifact = (Artifact) resultIter.next(); + Artifact translatedArtifact = resultIter.next(); if ( artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId() && artifact.getScope() == translatedArtifact.getScope() ) diff -Nru maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/Interpolator.java maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/Interpolator.java --- maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/Interpolator.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/Interpolator.java 2011-07-06 12:39:44.000000000 +0000 @@ -0,0 +1,15 @@ +package org.codehaus.plexus.util.interpolation; + +/** + * COPIED FROM plexus-utils-1.5.15 TO SATISFY TESTS + * + * Interpolator interface. Based on existing RegexBasedInterpolator interface. + * + * @author cstamas + * @deprecated Use plexus-interpolation APIs instead. + * @version $Id: Interpolator.java 12174 2010-05-16 21:04:35Z rfscholte $ + */ +public interface Interpolator + extends org.codehaus.plexus.interpolation.Interpolator +{ +} \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/RegexBasedInterpolator.java maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/RegexBasedInterpolator.java --- maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/RegexBasedInterpolator.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/RegexBasedInterpolator.java 2011-07-06 12:39:44.000000000 +0000 @@ -0,0 +1,47 @@ +package org.codehaus.plexus.util.interpolation; + +import java.util.List; + +/** + * COPIED FROM plexus-utils-1.5.15 TO SATISFY TESTS + * + * @version $Id: RegexBasedInterpolator.java 12174 2010-05-16 21:04:35Z rfscholte $ + * @deprecated Use plexus-interpolation APIs instead. + */ +public class RegexBasedInterpolator + extends org.codehaus.plexus.interpolation.RegexBasedInterpolator + implements Interpolator +{ + public RegexBasedInterpolator() + { + super(); + } + + public RegexBasedInterpolator( List valueSources ) + { + super( valueSources ); + } + + public RegexBasedInterpolator( String startRegex, + String endRegex, + List valueSources ) + { + super( startRegex, endRegex, valueSources ); + } + + public RegexBasedInterpolator( String startRegex, + String endRegex ) + { + super( startRegex, endRegex ); + } + + public void addValueSource( ValueSource valueSource ) + { + super.addValueSource( valueSource ); + } + + public void removeValuesSource( ValueSource valueSource ) + { + super.removeValuesSource( valueSource ); + } +} \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/ValueSource.java maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/ValueSource.java --- maven-dependency-plugin-2.1/src/test/java/org/codehaus/plexus/util/interpolation/ValueSource.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/java/org/codehaus/plexus/util/interpolation/ValueSource.java 2011-07-06 12:39:44.000000000 +0000 @@ -0,0 +1,13 @@ +package org.codehaus.plexus.util.interpolation; + +/** + * COPIED FROM plexus-utils-1.5.15 TO SATISFY TESTS + * + * @author jdcasey + * @deprecated Use plexus-interpolation APIs instead. + * @version $Id: ValueSource.java 12174 2010-05-16 21:04:35Z rfscholte $ + */ +public interface ValueSource extends org.codehaus.plexus.interpolation.ValueSource +{ + +} \ No newline at end of file diff -Nru maven-dependency-plugin-2.1/src/test/resources/its/get/pom.xml maven-dependency-plugin-2.4/src/test/resources/its/get/pom.xml --- maven-dependency-plugin-2.1/src/test/resources/its/get/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/resources/its/get/pom.xml 2011-10-26 17:42:34.000000000 +0000 @@ -0,0 +1,62 @@ + + + 4.0.0 + + test + maven-dependency-plugin-it-parent + 1 + + + maven-dependency-plugin-it-get + pom + + + + org.apache.maven + maven-artifact + 2.0.6 + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + get + generate-sources + + get + + + + + org.apache.maven + maven-model + 2.0.9 + http://repo1.maven.org/maven2 + + + + + Binary files /tmp/efMPVo7JEF/maven-dependency-plugin-2.1/src/test/resources/m2repo/maven/plugins/maven-dependency-plugin/test/maven-dependency-plugin-test.jar and /tmp/Ty1YjJQV1P/maven-dependency-plugin-2.4/src/test/resources/m2repo/maven/plugins/maven-dependency-plugin/test/maven-dependency-plugin-test.jar differ Binary files /tmp/efMPVo7JEF/maven-dependency-plugin-2.1/src/test/resources/m2repo/test/resolve/1/resolve-1.jar and /tmp/Ty1YjJQV1P/maven-dependency-plugin-2.4/src/test/resources/m2repo/test/resolve/1/resolve-1.jar differ diff -Nru maven-dependency-plugin-2.1/src/test/resources/unit/duplicate-dependencies/plugin-config.xml maven-dependency-plugin-2.4/src/test/resources/unit/duplicate-dependencies/plugin-config.xml --- maven-dependency-plugin-2.1/src/test/resources/unit/duplicate-dependencies/plugin-config.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/resources/unit/duplicate-dependencies/plugin-config.xml 2009-04-08 21:31:43.000000000 +0000 @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + + com.mycompany.app + my-mojo + maven-plugin + 1.0-SNAPSHOT + + my-mojo Maven Mojo + http://maven.apache.org + + + + org.apache.maven + maven-plugin-api + + + junit + junit + 3.8.1 + test + + + junit + junit + 3.8.1 + test + + + + + + + maven-dependency-plugin + + + + + + + diff -Nru maven-dependency-plugin-2.1/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml maven-dependency-plugin-2.4/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml --- maven-dependency-plugin-2.1/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml 2009-04-08 21:31:43.000000000 +0000 @@ -0,0 +1,75 @@ + + + + + + 4.0.0 + + + com.mycompany.app + my-mojo + maven-plugin + 1.0-SNAPSHOT + + my-mojo Maven Mojo + http://maven.apache.org + + + + org.apache.maven + maven-plugin-api + + + junit + junit + test + + + + + + + org.apache.maven + maven-plugin-api + + + junit + junit + 3.8.1 + + + junit + junit + 3.8.1 + + + + + + + + maven-dependency-plugin + + + + + + + diff -Nru maven-dependency-plugin-2.1/src/test/resources/unit/get-test/plugin-config.xml maven-dependency-plugin-2.4/src/test/resources/unit/get-test/plugin-config.xml --- maven-dependency-plugin-2.1/src/test/resources/unit/get-test/plugin-config.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/resources/unit/get-test/plugin-config.xml 2011-11-11 00:41:23.000000000 +0000 @@ -0,0 +1,40 @@ + + + + + + maven-dependency-plugin + + org.apache.maven + maven-model + 2.0.9 + + + + + + + org.apache.maven + maven-artifact + 2.0.4 + + + diff -Nru maven-dependency-plugin-2.1/src/test/resources/unit/properties-test/plugin-config.xml maven-dependency-plugin-2.4/src/test/resources/unit/properties-test/plugin-config.xml --- maven-dependency-plugin-2.1/src/test/resources/unit/properties-test/plugin-config.xml 1970-01-01 00:00:00.000000000 +0000 +++ maven-dependency-plugin-2.4/src/test/resources/unit/properties-test/plugin-config.xml 2010-12-13 17:22:53.000000000 +0000 @@ -0,0 +1,43 @@ + + + + + + maven-dependency-plugin + + + + + + + + + org.apache.maven + maven-artifact + 2.0.9 + + + junit + junit + 4.1 + + + \ No newline at end of file