Maven
  1. Maven
  2. MNG-5263

Cannot find dependency in Ant plugin based on multiple build scripts

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: Plugin API
    • Labels:
      None
    • Environment:
      Windows XP
    • Complexity:
      Intermediate
    • Number of attachments :
      0

      Description

      I am trying to create a custom ant plugin for Maven, based on multiple build scripts. There is a note in the documentation about it: http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html (see "A Note on Multiple Build Scripts"), but I have not been able to make it work.

      Here are the scripts:

      <root>\src\main\scripts\A.build.xml
      -----------------------------------
      <project>
      <import file="C.build.xml"/>
      <target name="hello" depends="dependency">
      <echo>Hello, World</echo>
      </target>
      </project>

      <root>\src\main\scripts\A.mojos.xml
      -----------------------------------
      <pluginMetadata>
      <mojos>
      <mojo>
      <goal>hello</goal>
      <call>hello</call>
      </mojo>
      </mojos>
      </pluginMetadata>

      <root>\src\main\scripts\B.build.xml
      -----------------------------------
      <project>
      <target name="hello">
      <echo>Hello, World</echo>
      </target>
      </project>

      <root>\src\main\scripts\B.mojos.xml
      -----------------------------------
      <pluginMetadata>
      <mojos>
      <mojo>
      <goal>hello2</goal>
      <call>hello</call>
      </mojo>
      </mojos>
      </pluginMetadata>

      <root>\src\main\scripts\C.build.xml
      -----------------------------------
      <project>
      <target name="dependency">
      <echo>This is the dependency</echo>
      </target>
      </project>

      <root>\pom.xml
      --------------
      <project>
      <modelVersion>4.0.0</modelVersion>

      <groupId>org.myproject.plugins</groupId>
      <artifactId>hello-plugin</artifactId>
      <version>1.0-SNAPSHOT</version>

      <packaging>maven-plugin</packaging>

      <name>Hello Plugin</name>

      <dependencies>
      <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-script-ant</artifactId>
      <version>2.2.1</version>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <artifactId>maven-plugin-plugin</artifactId>
      <version>2.9</version>

      <dependencies>
      <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-tools-ant</artifactId>
      <version>2.9</version>
      </dependency>
      </dependencies>

      <configuration>
      <goalPrefix>hello</goalPrefix>
      </configuration>
      </plugin>
      </plugins>
      </build>
      </project>

      At the root level, I run "mvn clean install", which is successful.

      Then I run "mvn org.myproject.plugins:hello-plugin:hello2", which is also successful and produces the "Hello, World" output.

      However, when running "mvn org.myproject.plugins:hello-plugin:hello", I get this:

      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Hello Plugin 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] — hello-plugin:1.0-SNAPSHOT:hello (default-cli) @ hello-plugin —
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 1.531s
      [INFO] Finished at: Thu Mar 08 12:52:25 PST 2012
      [INFO] Final Memory: 3M/15M
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.myproject.plugins:hello-plugin:1.0-SNAPSHOT:hello (default-cli) on project hello-plugin: Failed to execute: Executing Ant script: A.build.xml [hello]: Failed to parse. Cannot find C.build.xml imported from C:\DOCUME~1\joanes\LOCALS~1\Temp\plexus-ant-component9129296102162378706.build.xml -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

      By looking at the error, the script is executed in a temporary folder, hence it cannot find the imported C.build.xml.

        Activity

        Show
        Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014
        Hide
        Jason van Zyl added a comment -

        Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

        Show
        Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

          People

          • Assignee:
            Unassigned
            Reporter:
            Hebus Nimbus
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: