You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Thomas Diesler (JIRA)" <ji...@codehaus.org> on 2008/04/14 10:58:58 UTC

[jira] Created: (MANTRUN-86) Cannot handle multiple tasks elements

Cannot handle multiple tasks elements
-------------------------------------

                 Key: MANTRUN-86
                 URL: http://jira.codehaus.org/browse/MANTRUN-86
             Project: Maven 2.x Antrun Plugin
          Issue Type: Bug
            Reporter: Thomas Diesler


      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>install</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks if="jboss.local.repository">
                <property name="version.id" value="${project.version}"/>
                <property name="jboss.local.repository" value="${jboss.local.repository}"/>
                <ant antfile="ant/build-install.xml" target="install"/>
              </tasks>
              <tasks unless="jboss.local.repository">
                <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>

Always executes the last tasks element although 'jboss.local.repository' is set

[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
[INFO] Executed tasks



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

        

[jira] Closed: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Paul Gier (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Gier closed MANTRUN-86.
----------------------------

    Resolution: Won't Fix
      Assignee: Paul Gier

I'm closing this as Won't fix because I believe the logic for deciding which tasks to run doesn't belong in the antrun plugin.  If you need multiple tasks, it's probably better to have a separate build.xml file and call that from the antrun using the <ant> task.

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>            Assignee: Paul Gier
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Thomas Diesler (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=131538#action_131538 ] 

Thomas Diesler commented on MANTRUN-86:
---------------------------------------

Ok, in that case we might want to rename the issue to "Improve configuration error reporting"

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Updated: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MANTRUN-86:
-------------------------------------

    Affects Version/s: 1.1

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Issue Comment Edited: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Stefan Franke (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=157372#action_157372 ] 

Stefan Franke edited comment on MANTRUN-86 at 12/9/08 4:21 AM:
---------------------------------------------------------------

a workaround is to add ant-contrib to the ant classpath and then use <if> inside of the single target:
{code}
<!-- can contain typos, since I wrote this from scratch... -->
<configuration>
  <tasks>
    <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
    <if>
      <!-- maybe there is a more elegant way to check a property... -->
      <contains string="${jboss.local.repository}" substring="{jboss.local.repository}">
        <then>
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
      </then>
      <else>
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
       </else>
      </contains>
    </if>
  </tasks>
</configuration>
{code}

      was (Author: bebbo):
    a workaround is to add ant-contrib to the ant classpath and then use <if> inside of the single target:

<!-- can contain typos, since I wrote this from scratch... -->
<configuration>
  <tasks>
    <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
    <if>
      <!-- maybe there is a more elegant way to check a property... -->
      <contains string="${jboss.local.repository}" substring="{jboss.local.repository}">
        <then>
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
      </then>
      <else>
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
       </else>
      </contains>
    </if>
  </tasks>
</configuration>

  
> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Steffl (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=255078#action_255078 ] 

Steffl commented on MANTRUN-86:
-------------------------------

Pleas re-open this since it is really pain in the a*** to do all this workarround just to decide which target should be executed. It costs me 3 hours until now! And what I got is unreadable, crazy configurations. And I'am not the only one. It could be so easy:

<target name="targetA" if="doTargetA">
</target>

<target name="targetB" if="doTargetB">
</target>

You mentioned, the reason why you won't fix is because you "believe the logic for deciding which tasks to run doesn't belong in the antrun plugin". OK, but there is already logic support for the "if" and "unless" attributes on a single <target/> element. In my opinion, this is not consequently enough. Either you drop support for these attributes completely or you support multimple target elements (I would prefer).

Please re-think. Thanks a lot.

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>            Assignee: Paul Gier
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Paul Gier (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=255286#action_255286 ] 

Paul Gier commented on MANTRUN-86:
----------------------------------

Can you use multiple antrun executions?  I would think this will accomplish the same thing.
If that doesn't work for you, the best thing is probably to create a new jira issue and attach a patch.

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>            Assignee: Paul Gier
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Stefan Franke (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=157372#action_157372 ] 

Stefan Franke commented on MANTRUN-86:
--------------------------------------

a workaround is to add ant-contrib to the ant classpath and then use <if> inside of the single target:

<!-- can contain typos, since I wrote this from scratch... -->
<configuration>
  <tasks>
    <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
    <if>
      <!-- maybe there is a more elegant way to check a property... -->
      <contains string="${jboss.local.repository}" substring="{jboss.local.repository}">
        <then>
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
      </then>
      <else>
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
       </else>
      </contains>
    </if>
  </tasks>
</configuration>


> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=130734#action_130734 ] 

Benjamin Bentmann commented on MANTRUN-86:
------------------------------------------

If you look at the documentation for the [antrun:run|http://maven.apache.org/plugins/maven-antrun-plugin/run-mojo.html] goal, you will notice that its parameter {{tasks}} is not declared to be of type array/collection. So it's by design that you cannot have multiple {{<tasks>}} elements in the same {{<configuration>}}. The solution to your use case is to setup multiple {{<execution>}} elements, each one having only one {{<tasks>}} element.

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Commented: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Kathy Hale (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=192776#action_192776 ] 

Kathy Hale commented on MANTRUN-86:
-----------------------------------

To give you some context, I was trying import 3 targets: start web server, stop web server, and start webserver as debug. They really aren't related to the lifecycle as I see it, but they're still a nice developer tool to have scripted to avoid using services and shell scripts. 

So these seem like my only options unless the plugin was improved/fixed, none of which sound very appealing:
# Mash 3 targets into one maven target, and use if/else's to control which is called
# Leave these 3 targets in ANT and don't migrate to maven
# Bind the targets to arbitrary lifecycle phases (which doesn't really make sense) so I can use {{<execute>}}

> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Issue Comment Edited: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Stefan Franke (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=157372#action_157372 ] 

Stefan Franke edited comment on MANTRUN-86 at 12/9/08 4:22 AM:
---------------------------------------------------------------

a workaround is to add ant-contrib to the ant classpath and then use <if> inside of the single target:
{code}
<!-- can contain typos, since I wrote this from scratch... -->
<configuration>
  <tasks>
    <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
    <if>
      <!-- maybe there is a more elegant way to check a property... -->
      <contains string="${jboss.local.repository}" substring="{jboss.local.repository}">
        <then>
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
      </then>
      <else>
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
       </else>
      </contains>
    </if>
  </tasks>
</configuration>
{code}

      was (Author: bebbo):
    a workaround is to add ant-contrib to the ant classpath and then use <if> inside of the single target:
{code}
<!-- can contain typos, since I wrote this from scratch... -->
<configuration>
  <tasks>
    <taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
    <if>
      <!-- maybe there is a more elegant way to check a property... -->
      <contains string="${jboss.local.repository}" substring="{jboss.local.repository}">
        <then>
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
      </then>
      <else>
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
       </else>
      </contains>
    </if>
  </tasks>
</configuration>
{code}
  
> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.1
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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

        

[jira] Updated: (MANTRUN-86) Cannot handle multiple tasks elements

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MANTRUN-86?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MANTRUN-86:
-------------------------------------

    Description: 
{code:xml}
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>install</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks if="jboss.local.repository">
          <property name="version.id" value="${project.version}"/>
          <property name="jboss.local.repository" value="${jboss.local.repository}"/>
          <ant antfile="ant/build-install.xml" target="install"/>
        </tasks>
        <tasks unless="jboss.local.repository">
          <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>
{code}

Always executes the last tasks element although 'jboss.local.repository' is set

[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
[INFO] Executed tasks



  was:
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>install</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks if="jboss.local.repository">
                <property name="version.id" value="${project.version}"/>
                <property name="jboss.local.repository" value="${jboss.local.repository}"/>
                <ant antfile="ant/build-install.xml" target="install"/>
              </tasks>
              <tasks unless="jboss.local.repository">
                <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>

Always executes the last tasks element although 'jboss.local.repository' is set

[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
[INFO] Executed tasks




> Cannot handle multiple tasks elements
> -------------------------------------
>
>                 Key: MANTRUN-86
>                 URL: http://jira.codehaus.org/browse/MANTRUN-86
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>            Reporter: Thomas Diesler
>
> {code:xml}
> <plugin>
>   <artifactId>maven-antrun-plugin</artifactId>
>   <executions>
>     <execution>
>       <phase>install</phase>
>       <goals>
>         <goal>run</goal>
>       </goals>
>       <configuration>
>         <tasks if="jboss.local.repository">
>           <property name="version.id" value="${project.version}"/>
>           <property name="jboss.local.repository" value="${jboss.local.repository}"/>
>           <ant antfile="ant/build-install.xml" target="install"/>
>         </tasks>
>         <tasks unless="jboss.local.repository">
>           <echo message="Cannot install to jboss.local.repository=${jboss.local.repository}"/>
>         </tasks>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> {code}
> Always executes the last tasks element although 'jboss.local.repository' is set
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>      [echo] Cannot install to jboss.local.repository=/home/tdiesler/svn/jboss.local.repository
> [INFO] Executed tasks

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