Author: dantran Date: Sat Jan 2 19:28:47 2010 New Revision: 895269 URL: http://svn.apache.org/viewvc?rev=895269&view=rev Log: - Use ArtifactRepositoryFactory to construct alternate local repository instead of directly invoke the DefaultLocalRepostory constructor. - Rename alternateLocalRepository to localRepositoryDirectory for clarity and configuration naming convention
Modified: maven/plugins/trunk/maven-dependency-plugin/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/copying-artifacts.apt.vm maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java Modified: maven/plugins/trunk/maven-dependency-plugin/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml?rev=895269&r1=895268&r2=895269&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/copy-and-unpack-with-alternate-local-repo/pom.xml Sat Jan 2 19:28:47 2010 @@ -48,7 +48,7 @@ <goal>copy</goal> </goals> <configuration> - <alternateLocalRepository>${project.build.directory}/repo</alternateLocalRepository> + <localRepositoryDirectory>${project.build.directory}/repo</localRepositoryDirectory> <artifactItems> <artifactItem> <groupId>junit</groupId> @@ -64,7 +64,7 @@ <goal>unpack</goal> </goals> <configuration> - <alternateLocalRepository>${project.build.directory}/repo</alternateLocalRepository> + <localRepositoryDirectory>${project.build.directory}/repo</localRepositoryDirectory> <artifactItems> <artifactItem> <groupId>junit</groupId> Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?rev=895269&r1=895268&r2=895269&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java Sat Jan 2 19:28:47 2010 @@ -26,8 +26,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +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; @@ -100,21 +99,26 @@ * @since 1.0 */ private ArrayList artifactItems; - + /** - * Internal local repository + * To look up ArtifactRepository implementation + * @component + * @readonly */ - private ArtifactRepository localRepository; - + private ArtifactRepositoryFactory artifactRepositoryManager; + /** - * Path to an alternate local repository during plugin's execution. - * Set this value to a location under your project's target directory so that - * downloaded artifacts are removed as part of the build. + * 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 alternateLocalRepository; - + private File localRepositoryDirectory; + + /** + * To host and cache localRepositoryDirectory + */ + private ArtifactRepository overrideLocalRepository; abstract ArtifactItemFilter getMarkedArtifactFilter( ArtifactItem item ); @@ -367,28 +371,32 @@ /** + * Override the base to * @return Returns the local. */ protected ArtifactRepository getLocal () { - if ( this.localRepository != null ) + if ( this.overrideLocalRepository != null ) { - return this.localRepository; + return this.overrideLocalRepository; } - if ( this.alternateLocalRepository != null ) + if ( this.localRepositoryDirectory != null ) { - //create a temporary local repository with unique id - this.localRepository = new DefaultArtifactRepository( Long.toHexString( System.currentTimeMillis() ), "file://" + this.alternateLocalRepository.getAbsolutePath(), new DefaultRepositoryLayout() ); - - this.getLog().debug( "Execution local repository is at: " + this.localRepository.getBasedir() ); - - return this.localRepository; + //create a new local repo using existing layout, snapshots, and releases policy + this.overrideLocalRepository = artifactRepositoryManager.createArtifactRepository( Long + .toHexString( System.currentTimeMillis() ), "file://" + + this.localRepositoryDirectory.getAbsolutePath(), super.getLocal().getLayout(), super.getLocal() + .getSnapshots(), super.getLocal().getReleases() ); + + this.getLog().debug( "Execution local repository is at: " + this.overrideLocalRepository.getBasedir() ); + + return this.overrideLocalRepository; } - - this.localRepository = super.getLocal(); - - return this.localRepository; + + this.overrideLocalRepository = super.getLocal(); + + return this.overrideLocalRepository; } /** @@ -476,8 +484,8 @@ this.overWriteSnapshots = theOverWriteSnapshots; } - public void setAlternateLocalRepository( File alternateLocalRepository ) + public void setLocalRepositoryDirectory( File localRepositoryDirectory ) { - this.alternateLocalRepository = alternateLocalRepository; + this.localRepositoryDirectory = localRepositoryDirectory; } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/copying-artifacts.apt.vm URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/copying-artifacts.apt.vm?rev=895269&r1=895268&r2=895269&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/copying-artifacts.apt.vm (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/examples/copying-artifacts.apt.vm Sat Jan 2 19:28:47 2010 @@ -120,7 +120,7 @@ <<dependency:copy>> 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 <alternateLocalRepotority>'s value + To clean up the downloaded artifacts as part the build, set <localRepotorityDirectory>'s value to a location in your project's target directory. This use case also applies to <<dependency:unpack>> goal. @@ -148,7 +148,7 @@ </artifactItem> [...] </artifactItems> - <alternateLocalRepository>\${project.build.directory}/localrepo</alternateLocalRepository> + <localRepositoryDirectory>\${project.build.directory}/localrepo</localRepositoryDirectory> </configuration> </execution> </executions> Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java?rev=895269&r1=895268&r2=895269&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromConfiguration/TestCopyMojo.java Sat Jan 2 19:28:47 2010 @@ -672,7 +672,7 @@ File execLocalRepo = new File( this.testDir.getAbsolutePath(), "executionLocalRepo" ); assertFalse( execLocalRepo.exists() ); - mojo.setAlternateLocalRepository( execLocalRepo ); + mojo.setLocalRepositoryDirectory( execLocalRepo ); assertEquals( execLocalRepo.getAbsolutePath(), mojo.getLocal().getBasedir() ); mojo.execute();