maven-antrun-extended-plugin-1.42/0000755000175000017500000000000011571451163017623 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/pom.xml0000644000175000017500000001456311562556723021161 0ustar jamespagejamespage 4.0.0 org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin maven-plugin Maven AntRun Extended Plugin 1.42 This extended antrun maven plugin enables users not only to run ant scripts embedded in the POM, but also to reference maven dependencies using Ant task classes. This enables the user to delegate more complex tasks to Ant such as constructing file-based installation distros. Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.html psterk Paul Sterk paul.sterk@sun.com Sun Microsystems http://www.sun.com US Pacific kohsuke Kohsuke Kawaguchi kohsuke.kawaguchi@sun.com http://weblogs.java.net/blog/kohsuke/ Sun Microsystems http://www.sun.com US Pacific org.apache.maven maven-plugin-api ${maven.version} org.apache.maven maven-project ${maven.version} ant ant-launcher 1.6.5 runtime ant ant 1.6.5 org.apache.maven maven-embedder 2.0.1 test org.apache.commons commons-io 1.3.2 commons-collections commons-collections 3.2 scm:svn:https://svn.java.net/svn/maven-antrun-extended-plugin~svn/tags/maven-antrun-extended-plugin-1.42 scm:svn:https://svn.java.net/svn/maven-antrun-extended-plugin~svn/tags/maven-antrun-extended-plugin-1.42 maven-plugin-plugin 2.4 maven-compiler-plugin 1.5 1.5 org.apache.maven.plugins maven-release-plugin https://svn.java.net/svn/maven-antrun-extended-plugin~svn/tags org.jvnet.wagon-svn wagon-svn 1.12 maven2-repository.java.net Java.net Repository for Maven http://download.java.net/maven/2/ java.net java-net:/maven-antrun-extended-plugin~svn/trunk/www/ java.net false java-net:/maven2-repository~svn/trunk/repository/ integration-tests maven.test.skip true maven-invoker-plugin true src/it **/pom.xml integration-test integration-test run org.apache.maven.plugins maven-surefire-plugin 2.3 true 2.0.7 maven-antrun-extended-plugin-1.42/src/0000755000175000017500000000000011571451163020412 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/0000755000175000017500000000000011571451163021026 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test4/0000755000175000017500000000000011571451163022071 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test4/pom.xml0000644000175000017500000000517210676560207023420 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test4 1.0-SNAPSHOT Test for MANTRUN-36 properties not resolved in attributes xyz maven-antrun-plugin test Embedded tasks: P1: ${property1} P2: ${property2} P3: ${property3} mavenProperty: ${mavenProperty} run maven-antrun-extended-plugin-1.42/src/it/test4/build.xml0000644000175000017500000000203010676560207023712 0ustar jamespagejamespage P1: ${property1} P2: ${property2} P3: ${property3} maven-antrun-extended-plugin-1.42/src/it/test2/0000755000175000017500000000000011571451163022067 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test2/pom.xml0000644000175000017500000000312610676560207023413 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test2 1.0-SNAPSHOT Test for MANTRUN-28 maven.test.classpath doesn't contain test scope dependancies junit junit 3.8.1 test maven-antrun-plugin test ${test.classpath} run maven-antrun-extended-plugin-1.42/src/it/test-javac/0000755000175000017500000000000011571451163023067 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test-javac/pom.xml0000644000175000017500000000245311137413366024411 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test-javac 1.0-SNAPSHOT Make sure Ant gets javac This involves some classloader hack ant ant 1.6.5 org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin test run maven-antrun-extended-plugin-1.42/src/it/test-javac/src/0000755000175000017500000000000011571451163023656 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test-javac/src/main/0000755000175000017500000000000011571451163024602 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test-javac/src/main/java/0000755000175000017500000000000011571451163025523 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test-javac/src/main/java/Foo.java0000644000175000017500000000002311137413366027105 0ustar jamespagejamespagepublic class Foo {}maven-antrun-extended-plugin-1.42/src/it/test3/0000755000175000017500000000000011571451163022070 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test3/pom.xml0000644000175000017500000000312210676560207023410 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test3 1.0-SNAPSHOT Test for MANTRUN-32 ant tasks don't use correct environment in antrun plugin junit junit 3.8.1 test maven-antrun-plugin test user.home = ${user.home} run maven-antrun-extended-plugin-1.42/src/it/test3/build.xml0000644000175000017500000000051510676560207023717 0ustar jamespagejamespage user.home = ${user.home} maven-antrun-extended-plugin-1.42/src/it/test5/0000755000175000017500000000000011571451163022072 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test5/pom.xml0000644000175000017500000000267510676560207023426 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test5 1.0-SNAPSHOT Test for MANTRUN-34 StringIndexOutOfBoundsException in custom ant task referencing 'basedir' ant ant 1.6.5 maven-antrun-plugin test run maven-antrun-extended-plugin-1.42/src/it/test5/src/0000755000175000017500000000000011571451163022661 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test5/src/main/0000755000175000017500000000000011571451163023605 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test5/src/main/java/0000755000175000017500000000000011571451163024526 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test5/src/main/java/TestTask.java0000644000175000017500000000076310676560207027146 0ustar jamespagejamespageimport org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; public class TestTask extends Task { public void execute() throws BuildException { Project p = this.getProject(); System.out.println("sourceDirectory:" + p.getProperty("project.build.sourceDirectory")); System.out.println("project.cmdline:" + p.getProperty("project.cmdline")); System.out.println("basedir:" + p.getProperty("basedir")); } } maven-antrun-extended-plugin-1.42/src/it/test5/build.xml0000644000175000017500000000203010676560207023713 0ustar jamespagejamespage P1: ${property1} P2: ${property2} P3: ${property3} maven-antrun-extended-plugin-1.42/src/it/test1/0000755000175000017500000000000011571451163022066 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test1/pom.xml0000644000175000017500000000277310676560207023421 0ustar jamespagejamespage 4.0.0 org.apache.maven.plugins.antrun test1 1.0-SNAPSHOT Test for compile and plugin classpath references Ensure that maven.compile.classpath and maven.plugin.classpath referencies are set org.apache.maven.plugins maven-antrun-plugin compile compile target/generated/src/main/java run maven-antrun-extended-plugin-1.42/src/it/test1/src/0000755000175000017500000000000011571451163022655 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test1/src/main/0000755000175000017500000000000011571451163023601 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test1/src/main/java/0000755000175000017500000000000011571451163024522 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/it/test1/src/main/java/Test.java0000644000175000017500000000015610676560207026313 0ustar jamespagejamespagepublic class Test { public static void main(String args[]) { System.out.println("done"); } }maven-antrun-extended-plugin-1.42/src/it/test1/build.xml0000644000175000017500000000036310676560207023716 0ustar jamespagejamespage maven-antrun-extended-plugin-1.42/src/site/0000755000175000017500000000000011571451163021356 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/site/apt/0000755000175000017500000000000011571451163022142 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/site/apt/usage.apt0000644000175000017500000000210710737301112023743 0ustar jamespagejamespage ---- Usage ---- ---- ---- Usage The following POM snippet shows how to invoke this plugin. ------ ... ... org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin generate-sources run ------ The example above illustrates how to bind an ant script to a lifecycle phase. You can add a script to each lifecycle phase, by duplicating the <<<\>>> section and specifying a new phase. maven-antrun-extended-plugin-1.42/src/site/apt/index.apt0000644000175000017500000000256710737301112023760 0ustar jamespagejamespage ----- Introduction ----- ----- ----- Introduction {{{http://maven.apache.org/plugins/maven-antrun-plugin/}Maven antrun plugin}} allows you to embed Ant build script in a Maven process, but unfortunately the build script doesn't have much access to the surrounding Maven environment, which limits the use. This plugin enhances the maven antrun plugin by defining a series of Ant tasks that provide access to the surrounding Maven environment. This allows you to use Ant for accessing dependencies, performing a complex filtering of dependencies, attach files as artifacts, and much more. A typical usage of this plugin includes the following: * Create an assembly and attach it. Doing it in Ant is often so much easier and hassle-free than using {{{http://maven.apache.org/plugins/maven-assembly-plugin/}maven assembly plugin}}. * Invoke code/resource generators [] * How is this different from Maven ant tasks {{{http://maven.apache.org/ant-tasks.html}Maven ant tasks}} is a series of Ant tasks designed for your Ant based project to utilize some of Maven's capability. While you can use them from maven antrun plugin, they are not designed together so the Maven ant tasks don't know anything about the outer-most Maven environment. Features * Retrieve dependencies * Work with dependency graphs by performing arithemetic operations [] maven-antrun-extended-plugin-1.42/src/site/site.xml0000644000175000017500000000263010714414535023045 0ustar jamespagejamespage org.jvnet.maven-javanet-skin maven-javanet-skin 1.0 ${reports} maven-antrun-extended-plugin-1.42/src/test/0000755000175000017500000000000011571451161021367 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/0000755000175000017500000000000011571451161022310 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/0000755000175000017500000000000011571451161023077 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/jvnet/0000755000175000017500000000000011571451161024225 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/jvnet/maven/0000755000175000017500000000000011571451161025333 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/jvnet/maven/plugin/0000755000175000017500000000000011571451161026631 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/jvnet/maven/plugin/antrun/0000755000175000017500000000000011571451161030140 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/java/org/jvnet/maven/plugin/antrun/AntRunMojoTest.java0000644000175000017500000001466110724070403033702 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /* * Copyright 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. */ import java.io.File; import java.io.OutputStream; import java.io.PrintStream; import java.util.Arrays; import java.util.Properties; import org.apache.maven.cli.ConsoleDownloadMonitor; import org.apache.maven.embedder.MavenEmbedder; import org.apache.maven.embedder.MavenEmbedderConsoleLogger; import org.apache.maven.embedder.PlexusLoggerAdapter; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.monitor.event.DefaultEventMonitor; import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.StringOutputStream; /** * Class to test AntRun plugin * * @author Vincent Siveton * @version $Id: AntRunMojoTest.java 511210 2007-02-24 04:52:20Z brett $ */ public class AntRunMojoTest extends PlexusTestCase { /** * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp(); } /** * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { // nop } /** * Method to test Default Antrun generation * * @throws Exception */ public void testDefaultProject() throws Exception { try { String result = invokeMaven( "antrun-default-test", new Properties() ); assertTrue( result.indexOf( "[echo] Hello World!" ) != -1 ); } catch (LifecycleExecutionException ex) { String message = ex.getMessage(); if (message.contains("'org.jvnet.maven-antrun-extended-plugin:maven-antrun-extended-plugin' not found in repository")) { System.out.println("maven-antrun-extended-plugin missing from local repository. Run mvn install and retest"); } else { throw ex; } } } /** * Method to test tasks attributes * * @throws Exception */ public void testTasksAttributesProject() throws Exception { try { Properties properties = new Properties(); String result = invokeMaven( "tasksattributes-test", properties ); assertTrue( result.indexOf( "[echo] To skip me" ) != -1 ); properties.put( "maven.test.skip", "true" ); result = invokeMaven( "tasksattributes-test", properties ); assertTrue( result.indexOf( "[echo] To skip me" ) == -1 ); } catch (LifecycleExecutionException ex) { String message = ex.getMessage(); if (message.contains("'org.jvnet.maven-antrun-extended-plugin:maven-antrun-extended-plugin' not found in repository")) { System.out.println("maven-antrun-extended-plugin missing from local repository. Run mvn install and retest"); } else { throw ex; } } } /** * Invoke Maven for a given test project name *
* The Maven test project should be in a directory called testProject in * "src/test/resources/unit/" directory. * The Maven test project should be called "testProject"-plugin-config.xml. * * @param testProject * @param properties * @return the output of MavenEmbedder * @throws Exception */ private String invokeMaven( String testProject, Properties properties ) throws Exception { MavenEmbedder maven = new MavenEmbedder(); maven.setClassLoader( Thread.currentThread().getContextClassLoader() ); maven.setLogger( new MavenEmbedderConsoleLogger() ); maven.setLocalRepositoryDirectory( getTestFile( "target/local-repo" ) ); maven.setOffline( true ); maven.start(); EventMonitor eventMonitor = new DefaultEventMonitor( new PlexusLoggerAdapter( new MavenEmbedderConsoleLogger() ) ); File testPom = new File( getBasedir(), "src/test/resources/unit/" + testProject + "/" + testProject + "-plugin-config.xml" ); MavenProject project = maven.readProjectWithDependencies( testPom ); PrintStream oldOut = System.out; OutputStream outOS = new StringOutputStream(); PrintStream out = new PrintStream( outOS ); System.setOut( out ); try { maven.execute( project, Arrays.asList( new String[] { "org.jvnet.maven-antrun-extended-plugin:maven-antrun-extended-plugin:run" } ), eventMonitor, new ConsoleDownloadMonitor(), properties, new File( PlexusTestCase .getBasedir(), "/target/test/unit/" + testProject + "/" ) ); return outOS.toString(); } catch (LifecycleExecutionException ex) { // if maven-antrun-extended-plugin is not in target/local-repo and not in remote repos, look in default // local repo location: ${user.home}/.m2/repository maven.setLocalRepositoryDirectory(null); maven.start(); maven.execute( project, Arrays.asList( new String[] { "org.jvnet.maven-antrun-extended-plugin:maven-antrun-extended-plugin:run" } ), eventMonitor, new ConsoleDownloadMonitor(), properties, new File( PlexusTestCase .getBasedir(), "/target/test/unit/" + testProject + "/" ) ); return outOS.toString(); } finally { System.setOut( oldOut ); } } public static void main(String[] args) throws Exception { AntRunMojoTest test = new AntRunMojoTest(); test.setUp(); test.testDefaultProject(); test.tearDown(); } } maven-antrun-extended-plugin-1.42/src/test/resources/0000755000175000017500000000000011571451161023401 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/resources/unit/0000755000175000017500000000000011571451161024360 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/test/resources/unit/antrun-default-test/0000755000175000017500000000000011571451161030266 5ustar jamespagejamespage././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/test/resources/unit/antrun-default-test/antrun-default-test-plugin-config.xmlmaven-antrun-extended-plugin-1.42/src/test/resources/unit/antrun-default-test/antrun-default-test-pl0000644000175000017500000000330110702777422034533 0ustar jamespagejamespage 4.0.0 antrun-plugin.test antrun-plugin-test jar 1.0-SNAPSHOT 2006 Maven Antrun Plugin Test http://maven.apache.org junit junit 3.8.1 test org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin maven-antrun-extended-plugin-1.42/src/test/resources/unit/tasksattributes-test/0000755000175000017500000000000011571451161030571 5ustar jamespagejamespage././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/test/resources/unit/tasksattributes-test/tasksattributes-test-plugin-config.xmlmaven-antrun-extended-plugin-1.42/src/test/resources/unit/tasksattributes-test/tasksattributes-test-0000644000175000017500000000341710702777422035015 0ustar jamespagejamespage 4.0.0 antrun-plugin.test antrun-plugin-test jar 1.0-SNAPSHOT 2006 Maven Antrun Plugin Test http://maven.apache.org junit junit 3.8.1 test org.jvnet.maven-antrun-extended-plugin maven-antrun-extended-plugin To skip me, just call mvn -Dmaven.test.skip=true maven-antrun-extended-plugin-1.42/src/main/0000755000175000017500000000000011571451163021336 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/0000755000175000017500000000000011571451161022255 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/0000755000175000017500000000000011571451161023044 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/0000755000175000017500000000000011571451161024172 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/0000755000175000017500000000000011571451161025300 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/0000755000175000017500000000000011571451161026576 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/0000755000175000017500000000000011571451163030107 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GroupIdFilter.java0000644000175000017500000000121011000001031033427 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * @author Kohsuke Kawaguchi */ public class GroupIdFilter extends ListFilter { private String groupId; private String groupIdNot; public void setValue(String v) { groupId = v; } public void setNot(String v) { groupIdNot = v; } public boolean visit(DependencyGraph.Node node) { String p = node.getProject().getGroupId(); if(groupId !=null && groupId.equals(p)) return true; // positive match if(groupIdNot !=null && !groupIdNot.equals(p)) return true; // negative match return false; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/MavenComponentBag.java0000644000175000017500000003025711172203362034315 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /* * 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.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; 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.ScopeArtifactFilter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.MavenProjectHelper; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Exposes maven components to the Ant tasks. * * @author Vincent Siveton * @version $Id: MavenComponentBag.java 510478 2007-02-22 12:29:45Z vsiveton $ */ final class MavenComponentBag { /** * Used for resolving artifacts */ public final ArtifactResolver resolver; /** * Factory for creating artifact objects */ public final ArtifactFactory factory; /** * The local repository where the artifacts are located */ public final ArtifactRepository localRepository; /** * The remote repositories where artifacts are located */ public final List remoteRepositories; /* * The maven project */ public final MavenProject project; /* * TODO: document that this is */ public final ArtifactMetadataSource artifactMetadataSource; public final ArtifactHandlerManager artifactHandlerManager; /** * The boolean flag that indicates whether or not to verify that the * resolved artifact is contained in the pom.xml file. * Default is 'true'. */ public boolean verifyArtifact = true; public final MavenProjectHelper projectHelper; public final MavenProjectBuilder mavenProjectBuilder; /** * Creates a wrapper and associates that with the current thread. */ /*package*/ MavenComponentBag( ArtifactResolver resolver, ArtifactFactory factory, ArtifactRepository localRepository, List remoteRepositories, MavenProject project, MavenProjectHelper projectHelper, ArtifactHandlerManager artifactHandlerManager, ArtifactMetadataSource artifactMetadataSource, MavenProjectBuilder mavenProjectBuilder) { this.resolver = resolver; this.factory = factory; this.localRepository = localRepository; this.remoteRepositories = remoteRepositories; this.project = project; this.projectHelper = projectHelper; this.artifactMetadataSource = artifactMetadataSource; this.artifactHandlerManager = artifactHandlerManager; this.mavenProjectBuilder = mavenProjectBuilder; INSTANCES.set(this); } public void setVerifyArtifact(boolean verifyArtifact) { this.verifyArtifact = verifyArtifact; } /** * Return the artifact path in the local repository for an artifact defined by its groupId, * its artifactId and its version. * * @param groupId * @param artifactId * @param version * @return the locale artifact path * @throws IOException if any */ public String getArtifactAbsolutePath( String groupId, String artifactId, String version ) throws IOException { Artifact artifact = factory.createArtifact( groupId, artifactId, version, "compile", "jar" ); try { resolver.resolve( artifact, remoteRepositories, localRepository ); return artifact.getFile().getAbsolutePath(); } catch ( ArtifactResolutionException e ) { throw new IOException( "Unable to resolve artifact: " + groupId + ":" + artifactId + ":" + version ); } catch ( ArtifactNotFoundException e ) { throw new IOException( "Unable to find artifact: " + groupId + ":" + artifactId + ":" + version ); } } private static final ThreadLocal INSTANCES = new ThreadLocal(); public static MavenComponentBag get() { return INSTANCES.get(); } /** * Releases the instance tied to the thread to avoid memory leak. */ public static void reset() { INSTANCES.set(null); } /** * This is a helper method that provides a facade for creating Maven artifacts * with a classifier. It contains additional code to scan the MavenProject * artifacts when the groupId, version, and/or classifier values are null. * This method will scan the artifacts to see if there is a unique match * based on the artifactId. If there is not a match, an exception is * thrown. * * @param groupId * A String containing the maven artifact's group id * @param artifactId * A String containing the maven artifact's artifactId * @param version * A String containing the maven artifact's version * @param type * A String containing the maven artifact's type * @param classifier * A String containing the maven artifact's classifier * @throws ArtifactResolutionException * Thrown if artifact cannot be resolved * @throws ArtifactNotFoundException * Thrown if artifact is resolved and verifyArtifact is 'true' and artifact * is not configured in the pom.xml file. */ public Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier) throws IOException { Artifact artifact; if (artifactId == null) { throw new IOException("Cannot resolve artifact: artifactId is null"); } else if (groupId == null || version == null || verifyArtifact) { // we are missing some critical parameters, or verifyArtifact is true, in which case // we only allow resolution in the project's dependencies artifact = resolveArtifactUsingMavenProjectArtifacts(artifactId, groupId, version, type, classifier); } else { // otherwise we'll just create an artifact from what the user specified artifact = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); } // If no matches, throw exception if (artifact == null) { throw new IOException("Cannot resolve artifact. " +" groupId: "+ groupId + " artifactId: " + artifactId + " version: " + version + " type: "+ type + " classifier: "+ classifier); } return artifact; } public ArtifactResolutionResult resolveTransitively( String groupId, String artifactId, String version, String type, String classifier) throws ArtifactResolutionException, ArtifactNotFoundException, IOException { Set artifacts = new HashSet(); Artifact artifact = createArtifactWithClassifier( groupId, artifactId, version, type, classifier); ResolutionGroup resolutionGroup; try { resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() ); artifacts.addAll( resolutionGroup.getArtifacts() ); } catch ( ArtifactMetadataRetrievalException e ) { throw new ArtifactResolutionException( "Unable to download metadata from repository for artifact '" + artifact.getId() + " " +e.getMessage(), artifact); } ArtifactResolutionResult result = resolver.resolveTransitively( artifacts, artifact, localRepository, remoteRepositories, artifactMetadataSource, new ScopeArtifactFilter("runtime") ); return result; } /** * Works like {@link #resolveArtifactUsingMavenProjectArtifacts(String, String, String, String, String)} but * infers everything else from the artifact ID. */ public Artifact resolveArtifactUsingMavenProjectArtifacts(String artifactId) throws IOException { return resolveArtifactUsingMavenProjectArtifacts(artifactId,null,null,null,null); } /** * This method tries to match a request against artifacts loaded by Maven and * exposed through the MavenProject object. * * NOTE: This method may return 'null'. */ public Artifact resolveArtifactUsingMavenProjectArtifacts(String artifactId, String groupId, String version, String type, String classifier) throws IOException { Artifact artifactMatch = null; // Do match based on artifactId. If value is null or if no match, throw exception if (artifactId == null) { throw new IOException("Cannot resolve artifact: artifactId is null"); } Set artifacts = project.getArtifacts(); for (Artifact a : artifacts) { if(match(a.getArtifactId(),artifactId) && match(a.getGroupId(),groupId) && match(a.getVersion(),version) && match(a.getType(),type) && match(a.getClassifier(),classifier)) { if(artifactMatch!=null) { // matched to more than one thing. Error throw new IOException("Matched more than one artifacts: "+a+" and "+artifactMatch); } artifactMatch = a; } } return artifactMatch; } private static boolean match(String valueFromPom, String valueFromTask) { if(valueFromTask==null) return true; // no value specified in the task. Any value from artifact match if(valueFromPom==null) return false; // the actual value in the artifact didn't match the one given by task return valueFromPom.equalsIgnoreCase(valueFromTask); } /** * Obtains/downloads the artifact file by using the current set of repositories. */ public void resolveArtifact(Artifact artifact, List remoteRepositories) throws ArtifactResolutionException, ArtifactNotFoundException { if(remoteRepositories ==null) remoteRepositories = this.remoteRepositories; // fall back to the default list try { resolver.resolve(artifact, remoteRepositories,localRepository); } catch (ArtifactResolutionException e) { // these pointless catch blocks are convenient for setting breakpoint throw e; } catch (ArtifactNotFoundException e) { throw e; } } public void resolveArtifact(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException { resolveArtifact(artifact, remoteRepositories); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphVisitor.java0000644000175000017500000000122710752727017033401 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * Traverses a {@link DependencyGraph} in a depth-first order. * All the reachable nodes and edges are visited once and only once. * * @author Kohsuke Kawaguchi */ public interface GraphVisitor { /** * Visits an edge. * * @return * false to cut the traversal here and don't visit * its destination node. */ boolean visit(DependencyGraph.Edge edge); /** * Visits a node. * * @return * false to cut the traversal here and don't visit * any of forward edges from this node. */ boolean visit(DependencyGraph.Node node); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DependencyGraphTask.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DependencyGraphTask.ja0000644000175000017500000000747511040233351034307 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.project.ProjectBuildingException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import java.io.IOException; import java.util.Collection; /** * Base class for tasks that work with a dependency graph defined as a nested structure. * * @author Kohsuke Kawaguchi * @author Paul Sterk */ public abstract class DependencyGraphTask extends Task { private String groupId,artifactId,version,type="jar",classifier; private String baseGraph; private boolean tolerateBrokenPOMs; public void setGroupId(String groupId) { this.groupId = groupId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public void setVersion(String version) { this.version = version; } public void setType(String type) { this.type = type; } public void setClassifier(String classifier) { this.classifier = classifier; } public void setBaseGraph(String id) { this.baseGraph = id; } /** * If true, ignore an artifact that fails to resolve. */ public void setTolerateBrokenPOMs(boolean tolerateBrokenPOMs) { this.tolerateBrokenPOMs = tolerateBrokenPOMs; } /** * Transforms a graph by applying the given filter to thtese "source graph", * which is determined by the various parameter to this task. */ protected DependencyGraph buildGraph(GraphFilter filter) { try { DependencyGraph g = buildSourceGraph(); if(filter==null) return g; // apply transformation to g final DependencyGraph old = GraphFilter.CURRENT_INPUT.get(); GraphFilter.CURRENT_INPUT.set(g); try { g = filter.process(); } finally { GraphFilter.CURRENT_INPUT.set(old); } Collection nodes = g.getAllNodes(); log("Filtered down to "+ nodes.size()+" artifact(s)",Project.MSG_DEBUG); for (DependencyGraph.Node n : nodes) log(" "+n,Project.MSG_DEBUG); return g; } catch (AbstractArtifactResolutionException e) { throw new BuildException(e); } catch (IOException e) { throw new BuildException(e); } catch (ProjectBuildingException e) { throw new BuildException(e); } } /** * Computes the source grpah. */ private DependencyGraph buildSourceGraph() throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException, IOException { MavenComponentBag w = MavenComponentBag.get(); DependencyGraph g; if(baseGraph!=null) { g = (DependencyGraph)getProject().getReference(baseGraph); if(g==null) throw new BuildException("There's no graph with id="+baseGraph); } else if(groupId==null && artifactId==null && version==null) { // if no clue is given whatsoever, use all the project dependencies g = new DependencyGraph(w.project.getArtifact(), tolerateBrokenPOMs); } else { // otherwise pick up dependencies from the specified artifact g = new DependencyGraph(w.createArtifactWithClassifier(groupId,artifactId,version,type,classifier), tolerateBrokenPOMs); log("artifactId "+artifactId, Project.MSG_DEBUG); } g = new DependencyExclusionFilter().filter(g); log("Graph="+g,Project.MSG_DEBUG); return g; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AntPropertyHelper.java0000644000175000017500000001246711001167270034402 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /* * Copyright 2004-2005 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. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.tools.ant.PropertyHelper; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; import java.io.File; import java.util.Hashtable; import java.util.Map; import java.util.Set; /** * Makes the ${expressions} used in Maven available to Ant as properties. * * @author Kenney Westerhof */ public class AntPropertyHelper extends PropertyHelper { private Log log; private ExpressionEvaluator exprEvaluator; private MavenProject mavenProject; private Map artifactMap = new Hashtable(); /** * @deprecated use the other constructor * @param project * @param l */ public AntPropertyHelper( MavenProject project, Log l ) { mavenProject = project; log = l; } /** * @param exprEvaluator * @param artifacts * @param l */ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set artifacts, Log l ) { this.mavenProject = null; this.exprEvaluator = exprEvaluator; this.log = l; for (Artifact artifact : artifacts) { String key = "maven.dependency." + artifact.getGroupId() + "." + artifact.getArtifactId() + (artifact.getClassifier() != null ? "." + artifact.getClassifier() : "") + (artifact.getType() != null ? "." + artifact.getType() : "") + ".path"; log.debug("Storing: " + key + "=" + artifact.getFile().getPath()); artifactMap.put(key, artifact.getFile()); } } /** * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean) */ public synchronized Object getPropertyHook( String ns, String name, boolean user ) { if ( log.isDebugEnabled() ) { log.debug( "getProperty(ns="+ns+", name="+name+", user="+user+")" ); } /* keep old behaviour */ if ( mavenProject != null ) { return getPropertyHook( ns, name, user, mavenProject ); } Object val = null; if ( name.startsWith( "maven.dependency." ) ) { val = artifactMap.get( name ).getPath(); } if ( val == null ) { try { val = exprEvaluator.evaluate( "${" + name + "}" ); } catch (ExpressionEvaluationException e) { if ( log.isErrorEnabled() ) { log.error("Failed to evaluate expression" , e); } } } if ( val == null ) { val = super.getPropertyHook( ns, name, user ); if ( val == null ) { val = System.getProperty( name.toString() ); } } return val; } /** * @deprecated added to keep backwards compatibility * @param ns * @param name * @param user * @param mavenProject * @return */ private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject ) { Object val = null; try { if ( name.startsWith( "maven.dependency." ) ) { val = artifactMap.get( name ).getPath(); } else if ( name.startsWith( "project." ) ) { val = ReflectionValueExtractor.evaluate( name, mavenProject, true ); } else if ( name.equals("basedir") ) { val = ReflectionValueExtractor.evaluate( "basedir.path", mavenProject, false ); } } catch ( Exception e ) { if ( log.isWarnEnabled() ) { log.warn( "Error evaluating expression '" + name + "'", e ); } e.printStackTrace(); } if ( val == null ) { val = super.getPropertyHook( ns, name, user ); if ( val == null ) { val = System.getProperty(name); } } if ( val instanceof File ) { val = ((File) val).getAbsoluteFile(); } return val; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/UnJarTask.java0000644000175000017500000000710311430055555032614 0ustar jamespagejamespage/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can obtain * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. * Sun designates this particular file as subject to the "Classpath" exception * as provided by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the License * Header, with the fields enclosed by brackets [] replaced by your own * identifying information: "Portions Copyrighted [year] * [name of copyright owner]" * * Contributor(s): * * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */ package org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.taskdefs.Expand; import org.apache.tools.ant.util.FileUtils; import java.io.File; /** * Extends the unjar task to be able to specify dynamic destination directory. * * For example: * *
*
 *       
 *       
 *           
 *               
 *           
 *       
 *
 * produces:
 *
 *      [unjar] Expanding: /tmp/src/a.jar into /tmp/a_jar
 *      [unjar] Expanding: /tmp/src/b.jar into /tmp/b_jar
 *      [unjar] Expanding: /tmp/src/c.jar into /tmp/c_jar
 *      [unjar] Expanding: /tmp/src/d.jar into /tmp/d_jar
 *
 * 
* * @author bhavanishankar@dev.java.net * */ public class UnJarTask extends Expand { @Override protected void expandFile(FileUtils fileUtils, File srcF, File dir) { String destDirName = dir.getAbsolutePath(); if (destDirName.indexOf("@filebasename@") != -1) { String fileBaseName = getBaseName(srcF); destDirName = destDirName.replaceAll("@filebasename@", fileBaseName); File destDir = new File(destDirName); destDir.mkdirs(); super.expandFile(fileUtils, srcF, destDir); } else { super.expandFile(fileUtils, srcF, dir); } } private String getBaseName(File file) { String srcFileName = file.getName(); String fileBaseName = srcFileName.indexOf('.') != -1 ? srcFileName.substring(0, srcFileName.lastIndexOf('.')) : srcFileName; return fileBaseName; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphVisitors.java0000644000175000017500000000520210737012252033550 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import java.util.Arrays; import java.util.Collection; /** * Factories for {@link GraphVisitor}. * * @author Kohsuke Kawaguchi */ public class GraphVisitors { /** * Combines multiple {@link GraphVisitor} by AND-ing its output. * Can be used to create intersections. */ public static GraphVisitor and(GraphVisitor... visitors) { return and(Arrays.asList(visitors)); } /** * Combines multiple {@link GraphVisitor} by AND-ing its output. * Can be used to create intersections. */ public static GraphVisitor and(final Collection visitors) { return new GraphVisitor() { public boolean visit(DependencyGraph.Edge edge) { for (GraphVisitor v : visitors) { if(!v.visit(edge)) return false; } return true; } public boolean visit(DependencyGraph.Node node) { for (GraphVisitor v : visitors) { if(!v.visit(node)) return false; } return true; } }; } /** * Combines multiple {@link GraphVisitor} by OR-ing its output. * Can be used to create unions. */ public static GraphVisitor or(GraphVisitor... visitors) { return or(Arrays.asList(visitors)); } /** * Combines multiple {@link GraphVisitor} by OR-ing its output. * Can be used to create unions. */ public static GraphVisitor or(final Collection visitors) { return new GraphVisitor() { public boolean visit(DependencyGraph.Edge edge) { for (GraphVisitor v : visitors) { if(v.visit(edge)) return true; } return false; } public boolean visit(DependencyGraph.Node node) { for (GraphVisitor v : visitors) { if(!v.visit(node)) return true; } return false; } }; } /** * Obtains a {@link GraphVisitor} that does boolean-negation of the current {@link GraphVisitor}. */ public static GraphVisitor not(final GraphVisitor graph) { return new GraphVisitor() { public boolean visit(DependencyGraph.Edge edge) { return !graph.visit(edge); } public boolean visit(DependencyGraph.Node node) { return !graph.visit(node); } }; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DumpGraphFilter.java0000644000175000017500000000062010737030025033776 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.Project; /** * Special {@link GraphFilter} that dumps the graph. Useful for debugging. * * @author Kohsuke Kawaguchi */ public class DumpGraphFilter extends GraphFilter { public DependencyGraph process() { DependencyGraph g = evaluateChild(); log(g.toString(), Project.MSG_INFO); return g; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DependencyExclusionFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DependencyExclusionFil0000644000175000017500000000731210752732376034450 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.project.MavenProject; import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import java.util.List; import java.util.Set; import java.util.Stack; import java.util.HashSet; import java.util.Collections; /** * Filters out a graph by honoring dependency exclusion. * *

* A care is taken to handle a diamond dependency with exclusion correctly. * For example, in the following situation X shouldn't be excluded * because there's a valid reachable path to X. * *

 *   A -+-> B[exclude=X] -+
 *      |                 |
 *      +-> C ------------+-> D ---> X
 * 
* * @author Kohsuke Kawaguchi */ public class DependencyExclusionFilter extends GraphFilter { public DependencyGraph process() { final DependencyGraph g = evaluateChild(); return filter(g); } public DependencyGraph filter(final DependencyGraph g) { // All the reachable nodes will be accumulated here. final Set reachables = new HashSet(); new Runnable() { private final Stack> exclusions = new Stack>(); /** * Nodes that are already visited without any exclusion. * This is optimization, as if this is the case we know there's no point in visiting * such node twice. */ private final Set visitedWithNoExclusion = new HashSet(); private boolean noExclusionSoFar = true; public void run() { visit(g.getRoot()); } /** * Visits all the paths. */ private void visit(DependencyGraph.Node node) { // is this node excluded in the current path? If so, return. String id = node.groupId + ':' + node.artifactId; for (Set e : exclusions) if(e.contains(id)) return; // now we know that this is reachable reachables.add(node); if(noExclusionSoFar && !visitedWithNoExclusion.add(node)) // optimization. this node has already been visited with no exclusion, // so no point in doing it twice return; // create a new environment final boolean old = noExclusionSoFar; Set newExc = computeExclusionSet(node); exclusions.push(newExc); noExclusionSoFar &= newExc.isEmpty(); // recurse for (DependencyGraph.Edge e : node.getForwardEdges(g)) { if(!e.optional) visit(e.dst); } // then restore the old environment exclusions.pop(); noExclusionSoFar = old; } /** * Computes the exclusion set added by this node. They are strings of the form 'groupId:artifactId'. */ private Set computeExclusionSet(DependencyGraph.Node node) { MavenProject p = node.getProject(); if(p==null) return Collections.emptySet(); Set excSet = new HashSet(); for( Dependency d : (List)p.getDependencies() ) for( Exclusion exc : (List)d.getExclusions() ) excSet.add(exc.getGroupId()+':'+exc.getArtifactId()); return excSet; } }.run(); return g.createSubGraph(g.getRoot(), reachables); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AbstractArtifactsExclusionFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AbstractArtifactsExclu0000644000175000017500000000531711037730547034450 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.Artifact; import org.apache.tools.ant.BuildException; import java.util.Set; import java.util.HashSet; import java.util.List; import java.util.ArrayList; import java.util.Collection; import java.util.Arrays; import java.io.IOException; /** * Base class for {@link ListFilter}s that takes several nested <artifact> elements as parameters * to identify artifacts. * * @author Kohsuke Kawaguchi */ public abstract class AbstractArtifactsExclusionFilter extends ListFilter { /** * IDs of the artifacts to exclude. "groupId:artifactId:classifier". * These three are sufficient to identify an artifact uniquely within the context of single project * and its dependency. */ protected final Set ids = new HashSet(); private final List artifactElements = new ArrayList(); protected AbstractArtifactsExclusionFilter(Collection artifactIds) throws IOException { for (String artifactId : artifactIds) addArtifactId(artifactId); } protected AbstractArtifactsExclusionFilter(String... artifactIds) throws IOException { this(Arrays.asList(artifactIds)); } protected AbstractArtifactsExclusionFilter(String artifactId) throws IOException { addArtifactId(artifactId); } // for Ant protected AbstractArtifactsExclusionFilter() {} /** * Resolves all the artifacts and computes {@link #ids}. * * This normally needs to be done at {@link #visit(DependencyGraph.Node)}, * because this implementation could be used as a filter. * Can be invoked multiple times safely. */ protected final void resolve() { try { for (ArtifactElement ae : artifactElements) addArtifact(ae.createArtifact()); artifactElements.clear(); } catch (IOException e) { throw new BuildException(e); } } /** * Adds the artifact ID to {@link #ids}. Note that this requires us to infer other parameters like * groupId, version, etc. */ private void addArtifactId(String artifactId) throws IOException { addArtifact(MavenComponentBag.get().resolveArtifactUsingMavenProjectArtifacts(artifactId)); } protected void addArtifact(Artifact a) { ids.add(a.getGroupId()+':'+a.getArtifactId()+':'+a.getClassifier()); } /** * Nested <artifact> element can be used to specify what artifacts to exclude. */ public void addConfiguredArtifact(ArtifactElement a) { // can't resolve this to artifact yet, because we don't have MavenComponentBag here. artifactElements.add(a); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AbstractAntMojo.java0000644000175000017500000001444610737013060034007 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /* * Copyright 2005-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. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.PropertyHelper; import org.apache.tools.ant.Target; import org.apache.tools.ant.types.Path; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; import org.jvnet.maven.plugin.antrun.components.AntTargetConverter; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; /** * Abstract class for the Antrun plugin * * @author Kenney Westerhof * @author Vincent Siveton * @version $Id: AbstractAntMojo.java 557320 2007-07-18 16:35:18Z kenney $ */ public abstract class AbstractAntMojo extends AbstractMojo { /** * @deprecated use {@link AbstractAntMojo#executeTasks(Target,MavenProject,List)}. */ protected void executeTasks( Target antTasks, MavenProject mavenProject ) throws MojoExecutionException { executeTasks( antTasks, mavenProject, null ); } /** * @param antTasks * @param mavenProject * @throws MojoExecutionException */ protected void executeTasks( Target antTasks, MavenProject mavenProject, List pluginArtifacts ) throws MojoExecutionException { if ( antTasks == null ) { getLog().info( "No ant tasks defined - SKIPPED" ); return; } try { //TODO refactor - place the manipulation of the expressionEvaluator into a separated class. ExpressionEvaluator exprEvaluator = (ExpressionEvaluator) antTasks.getProject() .getReference( AntTargetConverter.MAVEN_EXPRESSION_EVALUATOR_ID ); Project antProject = antTasks.getProject(); PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper( antProject ); propertyHelper.setNext( new AntPropertyHelper( exprEvaluator, mavenProject.getArtifacts(), getLog() ) ); DefaultLogger antLogger = new DefaultLogger(); antLogger.setOutputPrintStream( System.out ); antLogger.setErrorPrintStream( System.err ); antLogger.setMessageOutputLevel( getLog().isDebugEnabled() ? Project.MSG_DEBUG : Project.MSG_INFO ); antProject.addBuildListener( antLogger ); antProject.setBaseDir( mavenProject.getBasedir() ); Path p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator ) ); /* maven.dependency.classpath it's deprecated as it's equal to maven.compile.classpath */ antProject.addReference( "maven.dependency.classpath", p ); antProject.addReference( "maven.compile.classpath", p ); p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator ) ); antProject.addReference( "maven.runtime.classpath", p ); p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getTestClasspathElements().iterator(), File.pathSeparator ) ); antProject.addReference( "maven.test.classpath", p ); /* set maven.plugin.classpath with plugin dependencies */ antProject.addReference( "maven.plugin.classpath", getPathFromArtifacts( pluginArtifacts, antProject ) ); if ( getLog().isInfoEnabled() ) { getLog().info( "Executing tasks" ); } configureProject(antProject); antTasks.execute(); if ( getLog().isInfoEnabled() ) { getLog().info( "Executed tasks" ); } } catch ( DependencyResolutionRequiredException e ) { throw new MojoExecutionException( "DependencyResolutionRequiredException: " + e.getMessage(), e ); } catch ( BuildException e ) { throw new MojoExecutionException( "An Ant BuildException has occured: " + e.getMessage(), e ); } catch ( Exception e ) { throw new MojoExecutionException( "Error executing ant tasks: " + e.getMessage(), e ); } } /** * Provides an opportunity for derived types to customize Ant project. */ protected void configureProject(Project antProject) { } /** * @param artifacts * @param antProject * @return a path * @throws DependencyResolutionRequiredException */ public Path getPathFromArtifacts( Collection artifacts, Project antProject ) throws DependencyResolutionRequiredException { if ( artifacts == null ) { return new Path( antProject ); } List list = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } Path p = new Path( antProject ); p.setPath( StringUtils.join( list.iterator(), File.pathSeparator ) ); return p; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/RemoveSpecificArtifactsFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/RemoveSpecificArtifact0000644000175000017500000000306110770317752034420 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import java.io.IOException; import java.util.Collection; import java.util.Set; import java.util.HashSet; /** * Filter {@link DependencyGraph} by excluding artifacts that are specific to the given artifacts. * *

* By specific, I mean an artifact that's only depended on by one and the only one of the * given artifacts. * * @author Kohsuke Kawaguchi */ public class RemoveSpecificArtifactsFilter extends AbstractArtifactsExclusionFilter { /** * Nodes to be retained. */ private Set nodes; public RemoveSpecificArtifactsFilter(Collection artifactIds) throws IOException { super(artifactIds); } public RemoveSpecificArtifactsFilter(String... artifactIds) throws IOException { super(artifactIds); } public RemoveSpecificArtifactsFilter(String artifactId) throws IOException { super(artifactId); } public RemoveSpecificArtifactsFilter() { } public boolean visit(DependencyGraph.Node node) { resolve(); if(!ids.isEmpty()) { final DependencyGraph base = evaluateChild(); nodes = new HashSet(base.getAllNodes()); for (String id : ids) { ExcludeArtifactsTransitivelyFilter exf = new ExcludeArtifactsTransitivelyFilter(); exf.ids.add(id); DependencyGraph x = base.createSubGraph(exf); nodes.retainAll(x.getAllNodes()); } } return nodes.contains(node); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/RetentionSetFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/RetentionSetFilter.jav0000755000175000017500000000454510737030751034414 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.project.ProjectBuildingException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import java.io.IOException; /** * Use this filter to create a retention set from a DependencyGraph. Indicate * which artifacts you wish to include in the set by passing the artifactId(s) * to one of the constructors. * * @author Paul Sterk */ public final class RetentionSetFilter extends GraphFilter { private ArtifactElement root; /** * Nested <artifact> element can be used to specify what artifacts to exclude. */ public void addConfiguredArtifact(ArtifactElement a) { // can't resolve this to artifact yet, because we don't have MavenComponentBag here. if(root!=null) throw new BuildException("Only one is allowed"); root = a; } public DependencyGraph process() { try { final DependencyGraph base = evaluateChild(); // Step 1. Subtract out all the artifacts specified in the artifactIds // collection by doing set subtraction ExcludeArtifactsTransitivelyFilter sbf = new ExcludeArtifactsTransitivelyFilter(); sbf.addConfiguredArtifact(root); final DependencyGraph subtractionSet = base.createSubGraph(sbf); // Step 2. Create the retention set by subtracting the artifacts in the // subtractionSet created in Step 1 from the original dependencyGraph set DependencyGraph g = base.createSubGraph( base.toNode(root.createArtifact()), new DefaultGraphVisitor() { public boolean visit(DependencyGraph.Node node) { return !subtractionSet.contains(node); } }); log(getClass().getSimpleName()+" -> "+g,Project.MSG_DEBUG); return g; } catch (ProjectBuildingException e) { throw new BuildException("Failed to resolve artifacts",e); } catch (AbstractArtifactResolutionException e) { throw new BuildException("Failed to resolve artifacts",e); } catch (IOException e) { throw new BuildException("Failed to resolve artifacts",e); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ExcludeArtifactsTransitivelyFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ExcludeArtifactsTransi0000755000175000017500000000364210770317752034462 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.Artifact; import org.apache.tools.ant.BuildException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Filter {@link DependencyGraph} by excluding the specified set of artifacts. Any artifacts made * unreachable by this process will be also excluded. * *

* Informally, a node will remain in the graph * only when it's reachable from the root without going through * any of the excluded artifacts. * *

* Here's the format definition. *

* Let normalize(G={r,V,E}) -> G'={r,V',E'} be defined as follows. * This is an operation to remove unreachable nodes and edges. * *

 *  V' = { v | \exists r ->* v in G }
 *  E' = { (u,v) | u \in V' and v \in V' }
 * 
* * Given the graph G=(r,V,E) and exclusion nodes N, * the new graph G' is defined as follows: * *
 * G'=normalize(r,V-N),E)
 * 
* * @author Paul Sterk * @author Kohsuke Kawaguchi * @see RemoveSpecificArtifactsFilter */ public final class ExcludeArtifactsTransitivelyFilter extends AbstractArtifactsExclusionFilter { public ExcludeArtifactsTransitivelyFilter(Collection artifactIds) throws IOException { super(artifactIds); } public ExcludeArtifactsTransitivelyFilter(String... artifactIds) throws IOException { super(artifactIds); } public ExcludeArtifactsTransitivelyFilter(String artifactId) throws IOException { super(artifactId); } public ExcludeArtifactsTransitivelyFilter() { } public boolean visit(DependencyGraph.Node node) { resolve(); // If the artifact matches an artifact in the artifacts Set, do not // include in the subgraph. Indicate this by returning 'false'. return !ids.contains(node.getId()); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ResolveAllTask.java0000644000175000017500000001513111066427721033650 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.Artifact; import org.jvnet.maven.plugin.antrun.DependencyGraph.Node; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Transitively resolve dependencies, perform some filtering first on the graph data model, * then on list data model, and deliver the resulting * set of artifacts in various forms (as a new {@link Path} object, into a directory, etc.) * * @author Kohsuke Kawaguchi * @author Paul Sterk */ public class ResolveAllTask extends DependencyGraphTask { private File todir; private String pathId; private GraphFilter filter; private String classifier; private final List listFilters = new ArrayList(); private boolean stripVersion; public void setTodir(File todir) { this.todir = todir; todir.mkdirs(); } public void setPathId(String pathId) { this.pathId = pathId; } /** * Instead of resolving the artifact as appeared in the dependency graph, * resolve a specific classifier. * * This is normally used to gather source jars. */ public void setClassifier(String classifier) { this.classifier = classifier; } /** * If set to true, destination file names won't have version * encoded in them. * @param stripVersion destination file name to have version or not */ public void setStripVersion(boolean stripVersion) { this.stripVersion = stripVersion; } /** * Adds a {@link GraphFilter} child. Ant will invoke this for each child element given in build script. */ public void add(GraphFilter child) { if(filter==null) this.filter = child; else { if (child instanceof ListFilter) { listFilters.add((ListFilter) child); } else { throw new BuildException(filter+" is not a list filter"); } } } public void execute() throws BuildException { log("Starting ResolveAllTasks.execute ", Project.MSG_DEBUG); // first graph filtering DependencyGraph g = buildGraph(filter); List nodes = new ArrayList(g.getAllNodes()); // further trim down the list by list filtering final DependencyGraph old = GraphFilter.CURRENT_INPUT.get(); GraphFilter.CURRENT_INPUT.set(g); try { for (ListFilter listFilter : listFilters) { for (Iterator itr = nodes.iterator(); itr.hasNext();) if(!listFilter.visit(itr.next())) itr.remove(); } } finally { GraphFilter.CURRENT_INPUT.set(old); } if(pathId!=null) { // collect all artifacts into a path and export Path path = new Path(getProject()); for (Node n : nodes) { try { File f = resolve(n); if(f!=null) path.createPathElement().setLocation(f); } catch (AbstractArtifactResolutionException e) { throw new BuildException("Failed to resolve artifact. Trail="+n.getTrail(g),e); } catch (IOException e) { throw new BuildException("Failed to resolve artifact. Trail="+n.getTrail(g),e); } } getProject().addReference(pathId,path); } if(todir!=null) { boolean hasSomethingToCopy=false; for (Node n : nodes) { try { File f = resolve(n); if(f!=null) { // copy files to the specified target directory. // use the task implementation to do up-to-date check. Copy cp = new Copy(); cp.setTaskName(getTaskName()); cp.setProject(getProject()); cp.setTodir(todir); if (stripVersion) { cp.add(new VersionStripper(n.version)); } FileSet fs = new FileSet(); fs.setFile(f); cp.addFileset(fs); cp.execute(); hasSomethingToCopy=true; } } catch (AbstractArtifactResolutionException e) { throw new BuildException("Failed to resolve artifact. Trail="+n.getTrail(g),e); } catch (IOException e) { throw new BuildException("Failed to resolve artifact. Trail="+n.getTrail(g),e); } } if(!hasSomethingToCopy) log("Nothing to copy",Project.MSG_INFO); } log("Exiting ResolveAllTasks.execute ", Project.MSG_DEBUG); } private File resolve(Node n) throws AbstractArtifactResolutionException, IOException { if(classifier==null) return n.getArtifactFile(); final MavenComponentBag w = MavenComponentBag.get(); Artifact a = w.factory.createArtifactWithClassifier(n.groupId, n.artifactId, n.version, n.type, classifier); List remoteRepos=null; if(n.getProject()!=null) remoteRepos = n.getProject().getRemoteArtifactRepositories(); w.resolveArtifact(a,remoteRepos); return a.getFile(); } private class VersionStripper implements FileNameMapper { String version; public VersionStripper(String v) { version = v; } public void setFrom(String s) { } public void setTo(String s) { } public String[] mapFileName(String s) { int idx = s.lastIndexOf(version); String to = s; if (idx != -1) { // remove version in artifactId-version(-classifier).type String baseFilename = s.substring( 0, idx - 1 ); String extension = s.substring( idx + version.length()); to = baseFilename + extension; } log("mapFileName: " + s + " -> " + to, Project.MSG_DEBUG); return new String[]{to}; } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ArtifactElement.java0000644000175000017500000000333310737021252034016 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.Artifact; import java.io.IOException; /** * Represents <artifact> element in build.xml * *

* This Java bean is a part of the XML configuration binding via Ant. * * @author Kohsuke Kawaguchi */ public class ArtifactElement { private String groupId, artifactId, version, type, classifier; public String getGroupId() { return groupId; } public void setGroupId(String groupId) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getClassifier() { return classifier; } public void setClassifier(String classifier) { this.classifier = classifier; } /** * Creates an {@link Artifact} from the configured information, * by possibly guessing parameters that were missing. */ public Artifact createArtifact() throws IOException { MavenComponentBag bag = MavenComponentBag.get(); return bag.createArtifactWithClassifier(groupId,artifactId,version,type,classifier); } /** * Retrurns the ID of this artifact after guessing omitted parameters. * The returned string follows the {@link Artifact#getId()} format. */ public String getId() throws IOException { return createArtifact().getId(); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ManifestEntryFilter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ManifestEntryFilter.ja0000644000175000017500000000277110774775426034407 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.tools.ant.BuildException; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.jar.Attributes; /** * Filter out a {@link DependencyGraph} by looking at manifest entries in the jar file. * * @author Kohsuke Kawaguchi */ public class ManifestEntryFilter extends ListFilter { private String entry; /** * The manifest main entry name that the jar has to have. */ public void setHas(String v) { entry = v; } public boolean visit(DependencyGraph.Node node) { try { File v = node.getArtifactFile(); if(v==null) return false; // whether this is the right behavior is worth an argument JarFile jar = new JarFile(v); try { Manifest m = jar.getManifest(); if(m==null) return false; Attributes att = m.getMainAttributes(); if(att==null) return false; // don't know if this can ever happen return att.getValue(entry)!=null; } finally { jar.close(); } } catch (AbstractArtifactResolutionException e) { throw new BuildException("Failed to filter "+node,e); } catch (IOException e) { throw new BuildException("Failed to filter "+node,e); } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AntRunMojo.java0000644000175000017500000002566111155656473033031 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /* * Copyright 2005-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. */ import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.profiles.ProfileManager; import org.apache.tools.ant.Project; import org.apache.tools.ant.Target; import org.apache.tools.ant.taskdefs.Taskdef; import org.apache.tools.ant.taskdefs.Typedef; import java.beans.Introspector; import java.io.File; import java.util.List; import java.net.URLClassLoader; import java.net.MalformedURLException; import java.net.URL; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; /** * Maven AntRun Mojo. * * This plugin provides the capability of calling Ant tasks * from a POM by running the nested ant tasks inside the <tasks/> * parameter. It is encouraged to move the actual tasks to * a separate build.xml file and call that file with an * <ant/> task. * * @author Kenney Westerhof * @author Vincent Siveton * @version $Id: AntRunMojo.java 557316 2007-07-18 16:29:17Z kenney $ * @configurator override * @goal run * @requiresDependencyResolution test */ // TODO: phase package public class AntRunMojo extends AbstractAntMojo { /** * The Maven project object * * @parameter expression="${project}" * @required * @readonly */ private MavenProject project; /** * The plugin dependencies. * * @parameter expression="${plugin.artifacts}" * @required * @readonly */ private List pluginArtifacts; /** * The XML for the Ant task. You can add anything you can add * between <target> and </target> in a build.xml. * * @parameter expression="${tasks}" */ private Target tasks; /** * This folder is added to the list of those folders * containing source to be compiled. Use this if your * ant script generates source code. * * @parameter expression="${sourceRoot}" */ private File sourceRoot; /** * This folder is added to the list of those folders * containing source to be compiled for testing. Use this if your * ant script generates test source code. * * @parameter expression="${testSourceRoot}" */ private File testSourceRoot; /** * Requires that artifacts to be resolved be defined in the dependency section of the POM. * Setting this to false allows you to resolve arbitrary artifact. * * @parameter expression="${verifyArtifact}" default-value="true" */ private boolean verifyArtifact=true; /** * Used for resolving artifacts * * @component */ private ArtifactResolver resolver; /** * Factory for creating artifact objects * * @component */ private ArtifactFactory factory; /** * The local repository where the artifacts are located * * @parameter expression="${localRepository}" * @required */ private ArtifactRepository localRepository; /** * The remote repositories where artifacts are located * * @parameter expression="${project.remoteArtifactRepositories}" */ private List remoteRepositories; /** * @component */ private MavenProjectHelper projectHelper; /** * @component */ protected ArtifactMetadataSource artifactMetadataSource; private MavenComponentBag bag; /** * @component */ private ArtifactHandlerManager artifactHandlerManager; /** * @component */ private MavenProjectBuilder mavenProjectBuilder; // this is not available as a component // /** // * @component // */ // private ProfileManager profileManager; /** * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() throws MojoExecutionException { initArtifactResolverWrapper(); /* Uncomment the following code to debug the MavenComponentBag bag.setVerifyArtifact(false); try { bag.resolveTransitively("org.glassfish.web", "gf-web-connector", "10.0-SNAPSHOT", "jar", "runtime"); } catch (Throwable t) { t.printStackTrace(); } */ try { executeTasks( tasks, project, pluginArtifacts ); } finally { MavenComponentBag.reset(); } if ( sourceRoot != null ) { getLog().info( "Registering compile source root " + sourceRoot ); project.addCompileSourceRoot( sourceRoot.toString() ); } if ( testSourceRoot != null ) { getLog().info( "Registering compile test source root " + testSourceRoot ); project.addTestCompileSourceRoot( testSourceRoot.toString() ); } } /* * This method is invoked to initialize the MavenComponentBag and * set it in ArtifactResolverWrapperThreadLocal. This thread local class * can be used by other classes, such as Ant tasks, to obtain the * MavenComponentBag. */ private void initArtifactResolverWrapper() { bag = new MavenComponentBag(resolver, factory, localRepository, remoteRepositories, project, projectHelper, artifactHandlerManager, artifactMetadataSource, mavenProjectBuilder); bag.setVerifyArtifact(verifyArtifact); } protected void configureProject(Project antProject) { // define all tasks for (Class task : TASKS) { typeDef(antProject, task, new Taskdef(), inferName(task, "Task")); } // define all filters for (Class filter : FILTERS) { typeDef(antProject, filter, new Typedef(), inferName(filter, "Filter")); } // expose basic properties antProject.setProperty("artifactId",project.getArtifactId()); antProject.setProperty("groupId",project.getGroupId()); antProject.setProperty("version",project.getVersion()); antProject.setProperty("packaging",project.getPackaging()); } private void typeDef(Project antProject, Class task, Typedef def, String name) { def.setName(name); def.setClassname(task.getName()); def.setProject(antProject); def.execute(); } private String inferName(Class task, String suffix) { String taskName = task.getSimpleName(); if(taskName.endsWith(suffix)) // chop off suffix taskName = taskName.substring(0,taskName.length()-suffix.length()); taskName = Introspector.decapitalize(taskName); return taskName; } private static final Class[] TASKS = new Class[] { ResolveArtifactTask.class, ResolveAllTask.class, AttachArtifactTask.class, GraphDefTask.class, IfTask.class }; private static final Class[] FILTERS = new Class[] { RetentionSetFilter.class, ExcludeArtifactsTransitivelyFilter.class, GroupIdFilter.class, PackagingFilter.class, ManifestEntryFilter.class, DependencyExclusionFilter.class, RemoveSpecificArtifactsFilter.class, ScopeFilter.class, DumpGraphFilter.class, SubtractFilter.class, SubGraphFilter.class, FullGraphFilter.class, VisualizeFilter.class, GraphRefFilter.class }; /* Mac JDKs don't have tools.jar (but they are just a part of rt.jar. Because of this, users of this plugin cannot add tools.jar to the dependency of antrun in a portable fashion --- doing so via plugin/dependencies/dependnecy as suggested in http://jira.codehaus.org/browse/MANTRUN-23 would break Mac builds. Typical error message is like this: [INFO] [antrun-extended:run {execution: default}] [INFO] Executing tasks [javac] Compiling 1 source file to /home/kohsuke/ws/gfv3/antrun/src/it/test-javac/target [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] An Ant BuildException has occured: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK So here we special-case tools.jar by locating them and adding them automatically to the classloader that loaded us. */ static { try { Class.forName("com.sun.tools.javac.Main"); } catch (ClassNotFoundException e) { // if not found, try to locate them File javaHome = new File(System.getProperty("java.home")); File toolsJar = new File(javaHome,"../lib/tools.jar"); if(toolsJar.exists()) { ClassLoader cl = AntRunMojo.class.getClassLoader(); if (cl instanceof URLClassLoader) { URLClassLoader ucl = (URLClassLoader) cl; try { Method m = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); m.setAccessible(true); m.invoke(ucl,toolsJar.toURL()); } catch (MalformedURLException e1) { // ignore the error and hope that the ant doesn't use javac } catch (InvocationTargetException e1) { // ignore the error and hope that the ant doesn't use javac } catch (NoSuchMethodException e1) { // ignore the error and hope that the ant doesn't use javac } catch (IllegalAccessException e1) { // ignore the error and hope that the ant doesn't use javac } } } } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphVizVisualizer.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphVizVisualizer.jav0000644000175000017500000001070510740504262034420 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Map; import java.util.HashMap; /** * Generates a dependency diagram by using GraphViz. * * @author Kohsuke Kawaguchi */ public class GraphVizVisualizer implements GraphVisitor { private final PrintWriter out; private final Map colors = new HashMap(); /** * Unique IDs given to GraphViz for each node. */ private Map ids = new HashMap(); public GraphVizVisualizer(PrintWriter out) { this.out = out; out.println("digraph G {"); } public GraphVizVisualizer(OutputStream out) { this(new PrintWriter(out)); } /** * Paint all edges and nodes that belong to the given subgraph by using the specified color. */ public void addColoredSubgraph(DependencyGraph g, final String color) { g.accept(new GraphVisitor() { public boolean visit(DependencyGraph.Edge edge) { colors.put(edge,color); return true; } public boolean visit(DependencyGraph.Node node) { colors.put(node,color); return true; } }); } public void close() { out.println("}"); out.close(); } public boolean visit(DependencyGraph.Edge edge) { Map attrs = new HashMap(); if(!edge.scope.equals("compile")) // most of dependencies are compile, so skip them for brevity attrs.put("label",edge.scope); if(edge.optional) attrs.put("style","dotted"); attrs.put("color",colors.get(edge)); if(edge.src.groupId.equals(edge.dst.groupId)) attrs.put("weight","10"); out.printf("%s -> %s ", id(edge.src), id(edge.dst)); writeAttributes(attrs); return true; } public boolean visit(DependencyGraph.Node node) { Map attrs = new HashMap(); attrs.put("label",node.groupId+':'+node.artifactId); attrs.put("color",colors.get(node)); out.print(id(node)+' '); writeAttributes(attrs); return true; } private void writeAttributes(Map attributes) { out.print('['); boolean first=true; for (Map.Entry e : attributes.entrySet()) { if(e.getValue()==null) continue; // skip out.printf("%s=\"%s\"",e.getKey(),e.getValue()); if(!first) out.print(','); else first = false; } out.println("];"); } private String id(DependencyGraph.Node n) { String id = ids.get(n); if(id==null) { id = "n"+ids.size(); ids.put(n,id); } return id; } /** * Returns a {@link GraphVizVisualizer} that generates a PNG file. */ public static GraphVizVisualizer createPng(final File pngFile) throws IOException { ProcessBuilder pb = new ProcessBuilder("dot","-Tpng"); final Process proc = pb.start(); final Thread stdoutCopier = new Thread() { public void run() { try { FileOutputStream out = new FileOutputStream(pngFile); IOUtils.copy(proc.getInputStream(), out); IOUtils.closeQuietly(out); } catch (IOException e) { throw new Error(e); } } }; stdoutCopier.start(); // copy stderr new Thread() { public void run() { try { IOUtils.copy(proc.getErrorStream(), System.err); } catch (IOException e) { throw new Error(e); } } }.start(); return new GraphVizVisualizer(proc.getOutputStream()) { @Override public void close() { super.close(); try { stdoutCopier.join(); } catch (InterruptedException e) { // handle interruption later Thread.currentThread().interrupt(); } } }; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ResolveArtifactTask.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ResolveArtifactTask.ja0000644000175000017500000000534010741766230034347 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.Artifact; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Copy; import java.io.File; /** * Ant task that resolves an artifact through Maven. * * @author Paul Sterk * @author Kohsuke Kawaguchi */ public class ResolveArtifactTask extends Task { // properties of artifact. private String groupId,artifactId,version,type,classifier; private String property; private File tofile,todir; public void setProperty(String property) { this.property = property; } public void setGroupId(String groupId) { this.groupId = groupId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public void setVersion(String version) { this.version = version; } public void setType(String type) { this.type = type; } public void setClassifier(String classifier) { this.classifier = classifier; } /** * The file name to copy the artifact to. * Optional. The name is */ public void setTofile(File target) { this.tofile = target; } /** * The directory name to copy the artifact to. * Optional. */ public void setTodir(File target) { this.todir = target; } public void execute() throws BuildException { log("Starting execute", Project.MSG_DEBUG); try { MavenComponentBag w = MavenComponentBag.get(); Artifact a = w.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); w.resolveArtifact(a); // Property attribute is optional. Check for null value if (property != null) { getProject().setProperty(property, a.getFile().getAbsolutePath()); } if(tofile!=null) { log("Copying "+a.getFile()+" to "+tofile); Copy cp = new Copy(); cp.setProject(getProject()); cp.setFile(a.getFile()); cp.setTofile(tofile); cp.execute(); } if(todir!=null) { log("Copying "+a.getFile()+" to "+todir); Copy cp = new Copy(); cp.setProject(getProject()); cp.setFile(a.getFile()); cp.setTodir(todir); cp.execute(); } } catch (Throwable ex) { log("Problem resolving artifact: "+ex.getMessage(), Project.MSG_ERR); throw new BuildException(ex); } log("Exiting execute", Project.MSG_DEBUG); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ScopeFilter.java0000644000175000017500000000241710754120146033171 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; /** * Filter out a {@link DependencyGraph} by only traversing the given scope. * * @author Kohsuke Kawaguchi * @author Paul Sterk */ public final class ScopeFilter extends GraphFilter implements GraphVisitor { private final Set scopes = new HashSet(); public ScopeFilter(Collection scopes) { this.scopes.addAll(scopes); } public ScopeFilter(String... scopes) { this(Arrays.asList(scopes)); } // needed for Ant public ScopeFilter() { } public void setLevel(String level) { StringTokenizer tokens = new StringTokenizer(level,", "); while(tokens.hasMoreTokens()) scopes.add(tokens.nextToken().trim()); } public DependencyGraph process() { // Create a subgraph of the dependencyGraph by using this class as a // GraphVisitor. return evaluateChild().createSubGraph(this); } public boolean visit(DependencyGraph.Edge edge) { return scopes.contains(edge.scope); } public boolean visit(DependencyGraph.Node node) { return true; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DependencyGraph.java0000644000175000017500000005611511562556723034032 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; import org.apache.commons.collections.ListUtils; import java.io.File; import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.Queue; import java.util.LinkedList; /** * Graph of dependencies among Maven artifacts. * *

* This graph, which consists of interconnected {@link Node}s and {@link Edge}s, * represents a complete dependency graph rooted at the given Maven module. * The constructor recursively parses all POMs for the dependency and builds this information. * *

* For example, if you have 4 modules A,B,C, and D that has the dependencies among them as follows: *

 * A->B,C
 * B->D
 * C->D
 * 
*

* Then if you construct a graph from 'A', you'll get a graph of four nodes (each representing * maven module A,B,C, and D) and four edges (each representing dependencies among them.) * *

* Once constructed, a graph is accessible in several ways: * *

    *
  • * Start with {@link #getRoot() the root node} and traverse through edges like * {@link Node#getForwardEdges(DependencyGraph)}. * *
  • * Use {@link #createSubGraph(GraphVisitor)} and obtain a sub-graph that matches the given * criteria. *
* * * @author Kohsuke Kawaguchi */ public final class DependencyGraph { private final MavenComponentBag bag = MavenComponentBag.get(); private final Node root; /** * All {@link Node}s keyed by "groupId:artifactId:classifier" */ private final Map nodes = new TreeMap(); /** * If true, ignore the {@link Node} that have failed to load. */ private final boolean tolerateBrokenPOMs; /** * Forward edges. * * Edges are kept on {@link DependencyGraph} so that we can * create multiple {@link DependencyGraph}s that share the same node set. */ private final Map> forwardEdges = new HashMap>(); private final Map> backwardEdges = new HashMap>(); /** * Creates a full dependency graph with the given artifact at the top. */ public DependencyGraph(Artifact root, boolean tolerateBrokenPOMs) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { this.tolerateBrokenPOMs = tolerateBrokenPOMs; Queue q = new LinkedList(); this.root = buildNode(root,q); visitBFS(q); } /** * Creates a full dependency graph with the given project at the top. */ public DependencyGraph(MavenProject root, boolean tolerateBrokenPOMs) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { this.tolerateBrokenPOMs = tolerateBrokenPOMs; Queue q = new LinkedList(); this.root = buildNode(root,q); visitBFS(q); } /** * Completes the graph in a breadth-first fashion. */ private void visitBFS(Queue q) throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException { while(!q.isEmpty()) q.poll().expand(this,q); } /** * Used to create a subgraph. *

* This method assumes that all nodes and edges are connected, * hence the 'private' access. Use {@link #createSubGraph(GraphVisitor)} * to construct a subset reliably. */ private DependencyGraph(Node root, Collection nodes, Collection edges, boolean tolerateBrokenPOMs) { this.tolerateBrokenPOMs = tolerateBrokenPOMs; if(nodes.isEmpty()) root = null; // graph is empty this.root = root; if(root!=null) { Set reachable = new HashSet(); reachable.add(root); // root is always reachable if(!nodes.contains(root)) throw new IllegalArgumentException("root "+root+" is not a part of nodes:"+nodes); for (Node n : nodes) this.nodes.put(n.getId(),n); for (Edge e : edges) { if(contains(e.src) && contains(e.dst)) { e.addEdge(forwardEdges,e.src); e.addEdge(backwardEdges,e.dst); reachable.add(e.dst); } } // some nodes were unreachable if(reachable.size()!=this.nodes.size()) throw new IllegalArgumentException(); } } /** * Gets the root node. * *

* This is non-null unless this graph is {@link #isEmpty() empty}. */ public Node getRoot() { return root; } /** * Returns true if the graph contains nothing at all. */ public boolean isEmpty() { return root==null; } /** * Returns all nodes in this graph. */ public Collection getAllNodes() { return nodes.values(); } /** * Checks if the graph contains the given node. */ public boolean contains(Node node) { return nodes.containsKey(node.getId()); } /** * Gets the associated {@link Node}, or null if none exists. */ public Node toNode(Artifact a) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { String id = a.getGroupId()+':'+a.getArtifactId()+':'+a.getClassifier(); return nodes.get(id); } /** * Gets the associated {@link Node}. If none exists, it will be created. * *

* Graph building has to be done breadth-first fashion so that the version * conflit resolution happens correctly — that is, if there exists dependency like * A -> B(1.0) -> C(2.0) and A -> C(2.2), then we want to pick up C(2.2), not C(2.0). * The criteria to do this in Maven is the length of the dependency chain, and that * can be done naturally by BFS. So we pass around a {@link Queue} to keep track of the remaining * {@link Node}s to be expanded. */ private Node buildNode(Artifact a, Queue q) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { String id = a.getGroupId()+':'+a.getArtifactId()+':'+a.getClassifier(); Node n = nodes.get(id); if(n==null) { n = new Node(a,this,q); nodes.put(id, n); } return n; } private Node buildNode(MavenProject p, Queue q) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { String id = p.getGroupId()+':'+p.getArtifactId()+":null"; Node n = nodes.get(id); if(n==null) { n = new Node(p, q); nodes.put(id, n); } return n; } /** * Accepts the visitor and invoke its visitor methods to create a sub-graph. * *

* This method is convenient for obtaining a sub-graph of dependencies * by filtering out nodes/edges. For example, to obtain all the transitive * dependencies that exclude provided/test dependencies, you can do: * *

     * createSubgraph(new {@link ScopeFilter}("compile","runtime"))
     * 
* * @return * A sub-graph of this graph that consists of nodes and edges for which the visitor returns true. * Can be an empty graph, but never null. */ public DependencyGraph createSubGraph(GraphVisitor visitor) { return createSubGraph(root,visitor); } /** * Accepts the visitor. Simply an alias for {@link #createSubGraph(GraphVisitor)}. */ public void accept(GraphVisitor visitor) { createSubGraph(visitor); } /** * Creates a full subgraph rooted at the given node. */ public DependencyGraph createSubGraph(Node root) { return createSubGraph(root,new DefaultGraphVisitor()); } /** * Visits the graph started at the given node, and creates a sub-graph * from visited nodes and edges. * *

* This is the slightly generalized version of {@link #createSubGraph(GraphVisitor)} */ public DependencyGraph createSubGraph(Node node, GraphVisitor visitor) { Set visited = new HashSet(); Set nodes = new HashSet(); List edges = new ArrayList(); Stack q = new Stack(); q.push(node); while(!q.isEmpty()) { DependencyGraph.Node n = q.pop(); if(visitor.visit(n)) { nodes.add(n); for (Edge e : n.getForwardEdges(this)) { if(visitor.visit(e)) { edges.add(e); if(visited.add(e.dst)) q.push(e.dst); } } } } return new DependencyGraph(node,nodes,edges, tolerateBrokenPOMs); } /** * Creates a sub-graph from the given set of nodes (which must be subset of * nodes in the current graph) with all edges { (u,v) | u \in nodes, v \in nodes } */ public DependencyGraph createSubGraph(Node root, Collection nodes) { List edges = new ArrayList(); for (List el : forwardEdges.values()) { for (Edge e : el) { if(nodes.contains(e.src) && nodes.contains(e.dst)) edges.add(e); } } return new DependencyGraph(root,nodes,edges, tolerateBrokenPOMs); } public String toString() { StringBuilder buf = new StringBuilder(); buf.append("DependencyGraph[root=").append(root).append(",\n"); buf.append(" nodes=[\n"); for (Node node : nodes.values()) buf.append(" ").append(node).append('\n'); buf.append(" ]\n"); buf.append(" edges=[\n"); for (Map.Entry> n : forwardEdges.entrySet()) { for (Edge e : n.getValue()) { buf.append(" ").append(e).append('\n'); } } buf.append(" ]\n]"); return buf.toString(); } private interface Resolver { File resolve() throws AbstractArtifactResolutionException; } private static final Resolver NULL = new Resolver() { public File resolve() { return null; } }; /** * Node, which represents an artifact. * *

* A single {@link Node} can be used in multiple {@link DependencyGraph} objects, * so the graph traversal method all takes {@link DependencyGraph} object * to determine the context in which the operation works. */ public static final class Node { /** * Basic properties of a module. * If {@link #pom} is non-null, this information is redundant, but it needs to be * kept separately for those rare cases where pom==null. */ public final String groupId,artifactId,version,type,classifier; private final MavenProject pom; private /*final*/ File artifactFile; private Resolver artifactResolver = NULL; /** * Represents the artifact that we want to fetch. */ private final Artifact artifact; private Node(Artifact artifact, DependencyGraph g, Queue q) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { groupId = artifact.getGroupId(); artifactId = artifact.getArtifactId(); version = artifact.getVersion(); type = artifact.getType(); classifier = artifact.getClassifier(); this.artifact = artifact; if("system".equals(artifact.getScope())) { // system scoped artifacts don't have POM, so the attempt to load it will fail. pom = null; } else { pom = g.bag.mavenProjectBuilder.buildFromRepository( // this create another Artifact instance whose type is 'pom' g.bag.factory.createProjectArtifact(artifact.getGroupId(),artifact.getArtifactId(), artifact.getVersion()), g.bag.project.getRemoteArtifactRepositories(), g.bag.localRepository); q.add(this); // visit dependencies from this POM later } } private void checkArtifact(final Artifact artifact, final MavenComponentBag bag) { artifactResolver = new Resolver() { public File resolve() throws AbstractArtifactResolutionException { if(bag.project.getArtifact()==artifact) { // our own module. Trying to resolve this in the usual way is most likely to fail, // so use what we have, if any. artifactFile =artifact.getFile(); return artifactFile; } if(pom!=null) { if (pom.getRemoteArtifactRepositories()==null) bag.resolveArtifact(artifact); else { //use repositories from pom and also MavenComponentBag bag.resolveArtifact(artifact, ListUtils.sum(pom.getRemoteArtifactRepositories(), bag.remoteRepositories)); } } else bag.resolveArtifact(artifact); artifactFile = artifact.getFile(); if(artifactFile==null) throw new IllegalStateException("Artifact is not resolved yet: "+artifact); return artifactFile; } }; } private Node(MavenProject pom, Queue q) { this.pom = pom; groupId = pom.getGroupId(); artifactId = pom.getArtifactId(); version = pom.getVersion(); type = pom.getPackaging(); // are these the same thing? classifier = null; artifact = pom.getArtifact(); q.add(this); // visit dependencies from this POM later } private void expand(DependencyGraph g, Queue q) throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException { checkArtifact(artifact,g.bag); loadDependencies(g,q); } private void loadDependencies(DependencyGraph g, Queue q) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { for( Dependency d : (List)pom.getDependencies() ) { // the last boolean parameter is redundant, but the version that doesn't take this // has a bug. See MNG-2524 Artifact a = g.bag.factory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), VersionRange.createFromVersion(d.getVersion()), d.getType(), d.getClassifier(), d.getScope(), false); // beware of Maven bug! make sure artifact got the value inherited from dependency assert a.getScope().equals(d.getScope()); try { new Edge(g,this,g.buildNode(a,q),d.getScope(),d.isOptional()); } catch (ProjectBuildingException e) { handleNodeResolutionException(g,e); } catch (ArtifactResolutionException e) { handleNodeResolutionException(g,e); } catch (ArtifactNotFoundException e) { handleNodeResolutionException(g,e); } } } private void handleNodeResolutionException(DependencyGraph g, Exception e) throws ProjectBuildingException { if (g.tolerateBrokenPOMs) System.err.println("Failed to parse dependencies of " + getId() + ". trail=" + getTrail(g)); else throw new ProjectBuildingException(getId(), "Failed to parse dependencies of " + getId() + ". trail=" + getTrail(g), e); } /** * Gets the parsed POM for this artifact. * * @return null * if POM is not available for this module. * That can happen for example for system-scoped artifacts. */ public MavenProject getProject() { return pom; } /** * Gets the artifact file, like a jar. * * @return * for system-scoped artifacts, this may null. If this node represents the current module * being built, this field may or may not be null, depending on whether the artifact is * already created in the current build or not. * For all the other modules, this is never null. * @throws AbstractArtifactResolutionException * Failed to resolve artifacat. */ public File getArtifactFile() throws AbstractArtifactResolutionException { if(artifactFile==null) artifactFile = artifactResolver.resolve(); return artifactFile; } /** * Gets the forward dependency edges (modules that this module depends on.) */ public List getForwardEdges(DependencyGraph g) { return getEdges(g.forwardEdges); } /** * Gets the backward dependency edges (modules that depend on this module.) */ public List getBackwardEdges(DependencyGraph g) { return getEdges(g.backwardEdges); } private List getEdges(Map> allEdges) { List edges = allEdges.get(this); if(edges==null) return Collections.emptyList(); return edges; } /** * Gets the nodes that the given node depends on. */ public List getForwardNodes(final DependencyGraph g) { return new AbstractList() { final List forward = getForwardEdges(g); public Node get(int index) { return forward.get(index).dst; } public int size() { return forward.size(); } }; } /** * Gets the nodes that depend on the given node. */ public List getBackwardNodes(final DependencyGraph g) { return new AbstractList() { final List backward = getBackwardEdges(g); public Node get(int index) { return backward.get(index).src; } public int size() { return backward.size(); } }; } public String toString() { return groupId+':'+artifactId+':'+version; } public String getId() { return groupId+':'+artifactId+':'+classifier; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Node node = (Node) o; if (!artifactId.equals(node.artifactId)) return false; if (classifier != null ? !classifier.equals(node.classifier) : node.classifier != null) return false; if (!groupId.equals(node.groupId)) return false; if (version != null ? !version.equals(node.version) : node.version != null) return false; return true; } public int hashCode() { int result; result = groupId.hashCode(); result = 31 * result + artifactId.hashCode(); result = 31 * result + (version != null ? version.hashCode() : 0); result = 31 * result + (classifier != null ? classifier.hashCode() : 0); return result; } /** * Builds the dependency trail from this node to the root node, in that order. * * This is useful as diagnostic information. */ public List getTrail(DependencyGraph graph) { List trail = new ArrayList(); Node n = this; while(n!=graph.getRoot()) { List list = n.getBackwardEdges(graph); if(list.isEmpty()) throw new AssertionError("Lost trail at "+trail+" from "+this+" with "+graph); Edge e = list.get(0); trail.add(e); n = e.src; } Collections.reverse(trail); return trail; } } public static final class Edge { /** * The module that depends on another. */ public final Node src; /** * The module that is being dependent by another. */ public final Node dst; /** * Dependency scope. Stuff like "compile", "runtime", etc. * Never null. */ public final String scope; /** * True if this dependency is optional. */ public final boolean optional; public Edge(DependencyGraph g, Node src, Node dst, String scope, boolean optional) { this.src = src; this.dst = dst; if(scope==null) scope="compile"; this.scope = scope; this.optional = optional; addEdge(g.forwardEdges,src); addEdge(g.backwardEdges,dst); } private void addEdge(Map> edgeSet, Node index) { List l = edgeSet.get(index); if(l==null) edgeSet.put(index,l=new ArrayList()); for (Edge e : l) { if(e.src.equals(this.src) && e.dst.equals(this.dst)) return; // duplicate } l.add(this); } public String toString() { StringBuilder buf = new StringBuilder(); buf.append(src).append("--(").append(scope); if(optional) buf.append("/optional"); buf.append(")-->").append(dst); return buf.toString(); } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Edge that = (Edge) o; return dst.equals(that.dst) && src.equals(that.src); } public int hashCode() { int result; result = src.hashCode(); result = 31 * result + dst.hashCode(); return result; } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphDefTask.java0000644000175000017500000000202310767631223033255 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; /** * Computes a dependency graph by applying a filter, then store it to the current project * so that it can be used later with <graphRef> filter. * *

* The name is chosen to match with other xxxDef tasks in Ant, like taskDef, typeDef, etc. * * @author Kohsuke Kawaguchi */ public class GraphDefTask extends DependencyGraphTask { private String id; protected GraphFilter filter; public void setId(String id) { this.id = id; } /** * Adds a {@link GraphFilter} child. Ant will invoke this for each child element given in build script. */ public void add(GraphFilter child) { if(filter!=null) throw new BuildException("Too many filters are given"); this.filter = child; } public void execute() throws BuildException { if(id==null) throw new BuildException("@id is required"); getProject().addReference(id,buildGraph(filter)); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/FullGraphFilter.java0000644000175000017500000000042610737032343034004 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * A pseudo filter that returns the current full dependency graph. * @author Kohsuke Kawaguchi */ public class FullGraphFilter extends GraphFilter { public DependencyGraph process() { return CURRENT_INPUT.get(); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/VisualizeFilter.java0000644000175000017500000000360110742755214034076 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.Project; import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.io.PrintWriter; import java.util.List; import java.util.ArrayList; /** * Filter that generates a graph by using GraphViz. * * @author Kohsuke Kawaguchi */ public class VisualizeFilter extends GraphFilter { private File output; private final List subGraphs = new ArrayList(); /** * PNG file to be created. */ public void setFile(File output) { this.output = output; } public void addConfiguredSubgraph(Subgraph g) { subGraphs.add(g); } public DependencyGraph process() { DependencyGraph g = evaluateChild(); try { GraphVizVisualizer viz = GraphVizVisualizer.createPng(output); for (Subgraph subGraph : subGraphs) viz.addColoredSubgraph( subGraph.process(), subGraph.color); g.accept(viz); viz.close(); } catch (IOException e) { // report an error, but don't let this fail the build, so that it can still // work in environments that don't have GraphViz. log("Failed to create "+output, Project.MSG_WARN); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); log(sw.toString(),Project.MSG_VERBOSE); } return g; } /** * Nested <subgraph> element. *

* Each takes nested filtering specifier, and those subgraphs will be drawn in a different color. */ public static final class Subgraph extends GraphFilter { private String color; public void setColor(String color) { this.color = color; } public DependencyGraph process() { return evaluateChild(); } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/components/0000755000175000017500000000000011571451162032273 5ustar jamespagejamespage././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/components/AntTargetConverter.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/components/AntTargetCo0000644000175000017500000002134510713726543034403 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun.components; /* * Copyright 2004-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. */ import org.apache.tools.ant.ComponentHelper; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.RuntimeConfigurable; import org.apache.tools.ant.Target; import org.apache.tools.ant.UnknownElement; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.util.StringUtils; /** * Plexus ConfigurationConverter to set up Ant Target component fields. * * @author Kenney Westerhof * @author Vincent Siveton * @version $Id: AntTargetConverter.java 511210 2007-02-24 04:52:20Z brett $ */ public class AntTargetConverter extends AbstractConfigurationConverter { public static final String MAVEN_EXPRESSION_EVALUATOR_ID = "maven.expressionEvaluator"; public static final String ROLE = ConfigurationConverter.class.getName(); /** * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#canConvert(java.lang.Class) */ public boolean canConvert( Class type ) { return Target.class.isAssignableFrom( type ); } /** * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#fromConfiguration(org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup, org.codehaus.plexus.configuration.PlexusConfiguration, java.lang.Class, java.lang.Class, java.lang.ClassLoader, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator, org.codehaus.plexus.component.configurator.ConfigurationListener) */ public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) throws ComponentConfigurationException { Object retValue = fromExpression( configuration, expressionEvaluator, type ); if ( retValue != null ) { return retValue; } Class implementation = getClassForImplementationHint( type, configuration, classLoader ); retValue = instantiateObject( implementation ); if (! ( retValue instanceof Target ) ) { retValue = new Target(); } processConfiguration( (Target)retValue, configuration, expressionEvaluator ); return retValue; } private void processConfiguration( Target target, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException { Project project = new Project(); project.setName( "DummyProject" ); target.setName( "" ); target.setProject( project ); String[] attributeNames = configuration.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; String attributeValue = configuration.getAttribute( attributeNames[i], null ); addAttributes( target, attributeName, attributeValue ); } project.addTarget( target ); project.addReference( MAVEN_EXPRESSION_EVALUATOR_ID, expressionEvaluator ); initDefinitions( project, target ); processConfiguration( null, project, target, configuration ); project.init(); } private void processConfiguration( RuntimeConfigurable parentWrapper, Project project, Target target, PlexusConfiguration configuration ) throws ComponentConfigurationException { int items = configuration.getChildCount(); Object parent = parentWrapper == null ? null : parentWrapper.getProxy(); for ( int i = 0; i < items; i++ ) { PlexusConfiguration childConfiguration = configuration.getChild( i ); UnknownElement task = new UnknownElement( childConfiguration.getName() ); task.setProject( project ); task.setNamespace( "" ); task.setQName( childConfiguration.getName() ); task.setTaskType( ProjectHelper.genComponentName( task.getNamespace(), childConfiguration.getName() ) ); task.setTaskName( childConfiguration.getName() ); task.setOwningTarget( target ); task.init(); if ( parent != null ) { ( (UnknownElement) parent ).addChild( task ); } else { target.addTask( task ); } RuntimeConfigurable wrapper = new RuntimeConfigurable( task, task.getTaskName() ); try { if ( childConfiguration.getValue() != null ) { wrapper.addText( childConfiguration.getValue() ); } } catch ( PlexusConfigurationException e ) { throw new ComponentConfigurationException( "Error reading text value from element '" + childConfiguration.getName() + "'", e ); } String[] attrNames = childConfiguration.getAttributeNames(); for ( int a = 0; a < attrNames.length; a++ ) { try { String v = childConfiguration.getAttribute( attrNames[a] ); wrapper.setAttribute( attrNames[a], v ); } catch ( PlexusConfigurationException e ) { throw new ComponentConfigurationException( "Error getting attribute '" + attrNames[a] + "' of tag '" + childConfiguration.getName() + "'", e ); } } if ( parentWrapper != null ) { parentWrapper.addChild( wrapper ); } processConfiguration( wrapper, project, target, childConfiguration ); } } protected void initDefinitions( Project project, Target unused ) { ComponentHelper componentHelper = ComponentHelper.getComponentHelper( project ); componentHelper.initDefaultDefinitions(); } /** * Add specific attributeValue to the tasks for given attributeName like * "if", "unless", "name" and "description". *
* Note: "depends" from Ant tasks is not be used. * * @see Ant targets * * @param tasks should be not null * @param attributeName if empty, skipped * @param attributeValue if empty, skipped */ private static void addAttributes( Target tasks, String attributeName, String attributeValue ) { if ( StringUtils.isEmpty( attributeName ) ) { return; } if ( StringUtils.isEmpty( attributeValue ) ) { return; } if ( attributeName.toLowerCase().equals( "name" ) ) { tasks.setName( attributeValue ); } if ( attributeName.toLowerCase().equals( "unless" ) ) { tasks.setUnless( attributeValue ); } if ( attributeName.toLowerCase().equals( "description" ) ) { tasks.setDescription( attributeValue ); } if ( attributeName.toLowerCase().equals( "if" ) ) { tasks.setIf( attributeValue ); } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/IfTask.java0000644000175000017500000000110311005157154032121 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Sequential; /** * Conditional execution. * * @author Kohsuke Kawaguchi */ public class IfTask extends Sequential { private Boolean test; public void setTest(boolean value) { this.test = value; } public void execute() throws BuildException { if(test()) super.execute(); } private boolean test() throws BuildException { if(test!=null) return test; return false; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/SubGraphFilter.java0000644000175000017500000000334610737032262033637 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.project.ProjectBuildingException; import java.io.IOException; /** * Computes a full subgraph rooted on the given node. * @author Kohsuke Kawaguchi */ public class SubGraphFilter extends GraphFilter { private String groupId, artifactId, version, type, classifier; public void setGroupId(String groupId) { this.groupId = groupId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public void setVersion(String version) { this.version = version; } public void setType(String type) { this.type = type; } public void setClassifier(String classifier) { this.classifier = classifier; } public DependencyGraph process() { try { MavenComponentBag bag = MavenComponentBag.get(); Artifact a = bag.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); DependencyGraph g = evaluateChild(); return g.createSubGraph(g.toNode(a)); } catch (IOException e) { throw new BuildException("Failed to resolve artifacts",e); } catch (ProjectBuildingException e) { throw new BuildException("Failed to resolve artifacts",e); } catch (AbstractArtifactResolutionException e) { throw new BuildException("Failed to resolve artifacts",e); } } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphRefFilter.java0000644000175000017500000000122710737273143033623 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; /** * Obtains a graph stored by {@link GraphDefTask}. * * @author Kohsuke Kawaguchi */ public class GraphRefFilter extends GraphFilter { private String ref; public void setRefid(String ref) { this.ref = ref; } public DependencyGraph process() { Object o = getProject().getReference(ref); if(o==null) throw new BuildException("No graph exists with id="+ref); if (o instanceof DependencyGraph) return (DependencyGraph) o; throw new BuildException("id="+ref+" is not a graph but "+o); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/PackagingFilter.java0000755000175000017500000000135410767631223034015 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * Filter out a {@link DependencyGraph} by only traversing the given packaging. * * @author Paul Sterk */ public final class PackagingFilter extends ListFilter { private String packaging; private String packagingNot; public void setValue(String v) { packaging = v; } public void setNot(String v) { packagingNot = v; } public boolean visit(DependencyGraph.Node node) { String p = node.getProject().getPackaging(); if(packaging!=null && packaging.equals(p)) return true; // positive match if(packagingNot!=null && !packagingNot.equals(p)) return true; // negative match return false; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/ListFilter.java0000644000175000017500000000167610770317752033052 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * {@link ListFilter} is a special kind of {@link GraphFilter} * that only filters graph based on {@link DependencyGraph.Node}. * *

* This kind of filters can be applied on a list of nodes. * * @author Kohsuke Kawaguchi */ public abstract class ListFilter extends GraphFilter implements GraphVisitor { public final DependencyGraph process() { // Create a subgraph of the dependencyGraph by using this class as a // GraphVisitor. The visit(node) and visit(edge) methods are called // by the immutable DependencyGraph instance to construct the subgraph. // when this class is used as a list filter, this method won't be invoked, // so don't let derived classes shoot themselves in the foot by overriding this. return evaluateChild().createSubGraph(this); } public final boolean visit(DependencyGraph.Edge edge) { return true; } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/SubtractFilter.java0000644000175000017500000000126410737032262033710 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; /** * Filter that takes two children G1 and G2, and compute G1-G2. * * @author Kohsuke Kawaguchi */ public class SubtractFilter extends GraphFilter { public DependencyGraph process() { if(children.size()!=2) throw new BuildException(" needs two children"); DependencyGraph base = evaluateChild(0); return base.createSubGraph(new DefaultGraphVisitor() { DependencyGraph excess = evaluateChild(1); public boolean visit(DependencyGraph.Node node) { return !excess.contains(node); } }); } } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/GraphFilter.java0000755000175000017500000000277210737020443033170 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.ProjectComponent; import java.util.ArrayList; import java.util.List; /** * Filter a {@link DependencyGraph} based on configuration by Ant. * * @author psterk */ public abstract class GraphFilter extends ProjectComponent { protected final List children = new ArrayList(); public abstract DependencyGraph process(); /** * Adds another child. Ant will invoke this for each child element given in build script. */ public void add(GraphFilter child) { children.add(child); } /** * Evaluate the n-th child {@link GraphFilter}. If omitted, it returns the input graph, * so that the full graph can be given as an input implicitly. Whether this defaulting * is a good idea or not, it's hard to say. */ protected DependencyGraph evaluateChild(int index) { if(children.size()<=index) return CURRENT_INPUT.get(); else return children.get(index).process(); } /** * Short for {@code evaluateChild(0)}, for those fitlers that only have one child. */ protected final DependencyGraph evaluateChild() { if(children.size()>1) throw new BuildException("Too many children in "+getClass().getName()); return evaluateChild(0); } /*package*/ static final ThreadLocal CURRENT_INPUT = new ThreadLocal(); } maven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/RejarTask.java0000644000175000017500000000563211266074112032642 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.commons.io.IOUtils; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Jar; import org.apache.tools.ant.types.ZipFileSet; import org.apache.tools.zip.ZipOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; /** * <jar> task extended to correctly merge manifest metadata. * * TODO: this contains HK2 knowledge, so it should be moved to HK2. * * @author Kohsuke Kawaguchi */ public class RejarTask extends Jar { // // these fields only have a life-span within the execute method. // /** * Merged metadata files in META-INF */ private final Map metadata = new HashMap(); public void execute() throws BuildException { // we want to put metadata files earlier in the file for faster runtime access, // and for that we require two passes. doubleFilePass = true; super.execute(); } protected void initZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException { if (!skipWriting) { // write out the merged metadata and service entries for (Map.Entry e : metadata.entrySet()) { super.zipFile( new ByteArrayInputStream(e.getValue().toByteArray()), zOut, e.getKey(), System.currentTimeMillis(), null, ZipFileSet.DEFAULT_FILE_MODE); } } super.initZipOutputStream(zOut); } protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, long lastModified, File fromArchive, int mode) throws IOException { boolean isInhabitantsFile = vPath.startsWith("META-INF/inhabitants/"); boolean isServicesFile = vPath.startsWith("META-INF/services/"); if (isInhabitantsFile || isServicesFile) { // merging happens in the first pass. // in the second pass, ignore them. if(skipWriting) { ByteArrayOutputStream stream = metadata.get(vPath); if (isServicesFile) { if (stream != null) stream.write(("\n").getBytes()); } if(stream==null) metadata.put(vPath,stream= new ByteArrayOutputStream()); if(isInhabitantsFile) { // print where the lines came from stream.write(("# from "+fromArchive.getName()+"\n").getBytes()); } IOUtils.copy(is,stream); } return; } // merge inhabitants file super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DefaultGraphVisitor.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/DefaultGraphVisitor.ja0000644000175000017500000000056310737017534034360 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; /** * Partial {@link GraphVisitor} implementation that returns true. * * @author Kohsuke Kawaguchi */ public class DefaultGraphVisitor implements GraphVisitor { public boolean visit(DependencyGraph.Edge edge) { return true; } public boolean visit(DependencyGraph.Node node) { return true; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AttachArtifactTask.javamaven-antrun-extended-plugin-1.42/src/main/java/org/jvnet/maven/plugin/antrun/AttachArtifactTask.jav0000644000175000017500000000573310723105351034317 0ustar jamespagejamespagepackage org.jvnet.maven.plugin.antrun; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import java.io.File; /** * Attaches the artifact to Maven. * * @author Kohsuke Kawaguchi */ public class AttachArtifactTask extends Task { private File file; private String classifier; private String type; /** * The file to be treated as an artifact. */ public void setFile(File file) { this.file = file; } /** * Optional classifier. If left unset, the task will * attach the main artifact. */ public void setClassifier(String classifier) { if(classifier!=null && classifier.length()==0) classifier = null; this.classifier = classifier; } /** * Artifact type. Think of it as a file extension. * Optional, and if omitted, infered from the file extension. */ public void setType(String type) { this.type = type; } public void execute() throws BuildException { final MavenComponentBag w = MavenComponentBag.get(); if(classifier==null) { if(type!=null) throw new BuildException("type is set but classifier is not set"); log("Attaching "+file, Project.MSG_VERBOSE); w.project.getArtifact().setFile(file); // Even if you define ArtifactHandlers as components, often because of the // initialization order, a proper ArtifactHandler won't be discovered. // so force our own ArtifactHandler that gets the extension right. ArtifactHandler handler = new ArtifactHandler() { public String getExtension() { return AttachArtifactTask.this.getExtension(file.getName()); } public String getDirectory() { return null; } public String getClassifier() { return null; } public String getPackaging() { return w.project.getPackaging(); } public boolean isIncludesDependencies() { return false; } public String getLanguage() { return null; } public boolean isAddedToClasspath() { return false; } }; w.project.getArtifact().setArtifactHandler(handler); } else { log("Attaching "+file+" as an attached artifact", Project.MSG_VERBOSE); String type = this.type; if(type==null) type = getExtension(file.getName()); w.projectHelper.attachArtifact(w.project,type,classifier,file); } } private String getExtension(String name) { int idx = name.lastIndexOf('.'); return name.substring(idx+1); } } maven-antrun-extended-plugin-1.42/src/main/resources/0000755000175000017500000000000011571451163023350 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/resources/META-INF/0000755000175000017500000000000011571451163024510 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/resources/META-INF/plexus/0000755000175000017500000000000011571451163026030 5ustar jamespagejamespagemaven-antrun-extended-plugin-1.42/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000260210723063737030743 0ustar jamespagejamespage org.codehaus.plexus.component.configurator.ComponentConfigurator override org.codehaus.plexus.component.configurator.BasicComponentConfigurator org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup override org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup override org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup org.codehaus.plexus.component.configurator.converters.ConfigurationConverter AntTarget customConverters org.codehaus.plexus.component.configurator.converters.ConfigurationConverter AntTarget org.jvnet.maven.plugin.antrun.components.AntTargetConverter