[ http://jira.codehaus.org/browse/MNG-5109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=269347#action_269347 ]
Quentin Ng commented on MNG-5109: --------------------------------- Note that the ListToTask ant task uses the MavenProject.getArtifacts(...) to work out the compile classpath. getArtifacts() returns the set of dependencies (including transitive) that were last resolved. Thus, the set thus then depends one either: 1) What you have set for your mojos @requiresDependencyResolution tag. If you have it set to runtime, it will be the runtime stuff. 2) If you dont have a @requiresDependencyResolution tag, it will depend on where in the lifecycle your plugin runs and what plugins were called before it. For example, if your plugin runs in the validate phase, the set is most likely going to be null. If you run after compile, youll get the compile stuff, if you run after test, youll get the test stuff. > Passing Maven classpath to a ant mojo not working > ------------------------------------------------- > > Key: MNG-5109 > URL: http://jira.codehaus.org/browse/MNG-5109 > Project: Maven 2 & 3 > Issue Type: Bug > Components: Class Loading > Environment: Apache Maven 3.0.3 (r1075438; 2011-03-01 04:31:09+1100) > Maven home: /usr/share/maven3 > Java version: 1.6.0_24, vendor: Sun Microsystems Inc. > Java home: /usr/lib/jvm/java-6-sun-1.6.0.24/jre > Default locale: en_AU, platform encoding: UTF-8 > OS name: "linux", version: "2.6.35-28-generic", arch: "amd64", family: "unix" > Reporter: Quentin Ng > Attachments: qng-maven3.tar > > > I use a ant tast called listtopath > This is part of: > http://snapshots.repository.codehaus.org/org/codehaus/mojo/was-plugin-anttasks/1.0/ > This task is to get around the headache of trying to get > ${maven.compile.classpath} to be passed from maven to the ant mojo. > It has worked like a treat in Maven 2 (I've included the maven 2 example) > but trying to run on maven 3 the CP isn't being passed through. > Basically this is what I do: > I have a simple mojo that takes a reference to the maven project. > It then uses the listtopath task to convert it into a refid that can be used. > eg. > The mojo. > the parameter to pass the maven project > <pluginMetadata> > <mojos> > <mojo> > <goal>ejb-stub-compile</goal> > <call>ejb-stub-compile</call> > <requiresProject>true</requiresProject> > <!--- rest ommitted --//> > <parameter> > <name>mavenproject</name> > <type>org.apache.maven.project.MavenProject</type> > <required>true</required> > <description>This is the pom for the project. Property is > read-only (i.e you can not set it) > </description> > </parameter> > <!--- rest ommitted --//> > Then in my maven-ant build > <project xmlns:artifact="antlib:org.apache.maven.artifact.ant"> > <property environment="env" value=""/> > <!-- make reference to the listtopath --> > <taskdef name="listtopath" > classname="org.codehaus.mojo.wasanttasks.ListToPathTask"> > <classpath> > <pathelement > > location="${env.USERPROFILE}/.m2/repository/org/codehaus/mojo/was-plugin-anttasks/1.0/was-plugin-anttasks-1.0.jar"/> > </classpath> > </taskdef> > <target name="ejb-stub-compile" depends="init-windows,init-unix"> > <echo>Starting ejb stub compilation</echo> > <!-- using the maven project get the classpath --> > <listtopath targetRef="classpath" mavenproject="mavenproject"/> > <!-- convert it into a path and store in ref --> > <pathconvert property="converted.compile.classpath" refid="classpath" > dirsep="/"/> > <!-- if the classpath works it should appear here --> > <echo>classpath:${converted.compile.classpath}</echo> > After compiling this I make a local-repository reference and call it > the call in the pom. > <plugin> > <groupId>com.nag.build</groupId> > <artifactId>ejb-stub-compile</artifactId> > <version>1.0.15</version> > <configuration> > <mavenproject > implementation="org.apache.maven.project.MavenProject">${project}</mavenproject> > <websphere.home>${websphere.home}</websphere.home> > > <input-file>${project.build.directory}/${project.build.finalName}.jar</input-file> > > <output-file>${project.build.directory}/${project.build.finalName}-tmp.jar</output-file> > </configuration> > <executions> > <execution> > <phase>pre-integration-test</phase> > <goals> > <goal>ejb-stub-compile</goal> > </goals> > </execution> > </executions> > <dependencies> > <dependency> > <groupId>org.codehaus.mojo</groupId> > <artifactId>was-plugin-anttasks</artifactId> > <version>1.0</version> > </dependency> > </dependencies> > </plugin> > The above worked with maven2 - migrating to Maven3 has caused the listtopath > to stop working. > Alternatively there has to be an easier way to pass the cp through to ant!!!! -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira