Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5109

Passing Maven classpath to a ant mojo not working

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • None
    • None
    • Class Loading
    • None

    Description

      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!!!!

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            qng Quentin Ng
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment