[ 
http://jira.codehaus.org/browse/MANTRUN-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=139096#action_139096
 ] 

baerrach edited comment on MANTRUN-75 at 6/20/08 12:19 AM:
-----------------------------------------------------------------

A work around is to use a profile:

{code:xml} 
  <profiles>
    <profile>
      <id>your-id-here</id>
      <activation>
        <property>
          <name>property-to-use-to-turn-on</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>your-execution-id-here</id>
                <phase>generate-resources</phase>
                <configuration>
                  <tasks>
                    <echo message="See profile work" />
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
{code} 

Then to get this antrun profile use

{code} mvn install -Dproperty-to-use-to-turn-on{code} 

which will enable this profile and hence run your antrun task.

      was (Author: baerrach):
    A work around is to use a profile:

  <profiles>
    <profile>
      <id>your-id-here</id>
      <activation>
        <property>
          <name>property-to-use-to-turn-on</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>your-execution-id-here</id>
                <phase>generate-resources</phase>
                <configuration>
                  <tasks>
                    <echo message="See profile work" />
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

Then to get this antrun profile use

mvn install -Dproperty-to-use-to-turn-on

which will enable this profile and hence run your antrun task.
  
> tasks if or unless does not work properly 
> ------------------------------------------
>
>                 Key: MANTRUN-75
>                 URL: http://jira.codehaus.org/browse/MANTRUN-75
>             Project: Maven 2.x Antrun Plugin
>          Issue Type: Bug
>         Environment: Win XP ( CYGWIN) JDK 1.5 update 7 
>            Reporter: Alan Mehio
>         Attachments: mantrun-75.diff
>
>
> the below
> <tasks unless="maven.test.skip">
>                 <echo message="To skip me, just call mvn 
> -Dmaven.test.skip=true"/>
>               </tasks>
> does not work from the example at  
> http://maven.apache.org/plugins/maven-antrun-plugin/examples/tasksAttributes.html
> The complete POM file ; please see below 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>       xsi:schemaLocation="http://vmaven.apache.org/POM/4.0.0 
> http://maven.apache.org/maven-v4_0_0.xsd";>
>       <modelVersion>4.0.0</modelVersion>
>       <groupId>mygr</groupId>
>       <artifactId>myartifact</artifactId>
>       <packaging>pom</packaging>
>       <version>1.1.0</version>
>       <name>myartifact</name>
>       <url>http://maven.apache.org</url>
>       <dependencies>
>               <dependency>
>                       <groupId>junit</groupId>
>                       <artifactId>junit</artifactId>
>                       <version>3.8.1</version>
>                       <scope>test</scope>
>               </dependency>
>       </dependencies>
>       <build>
>               <plugins>
>                       <plugin>
>                               <groupId>org.apache.maven.plugins</groupId>
>                               <artifactId>maven-compiler-plugin</artifactId>
>                               <configuration>
>                                       <source>1.5</source>
>                                       <target>1.5</target>
>                               </configuration>
>                       </plugin>
>                       <!--  jar file plugin -->
>                       <plugin>
>                               <groupId>org.apache.maven.plugins</groupId>
>                               <artifactId>maven-jar-plugin</artifactId>
>                               <configuration>
>                                       <archive>
>                                               <manifest>
>                                                       
> <addClasspath>true</addClasspath>
>                                                       
> <classpathPrefix>./</classpathPrefix>
>                                               </manifest>
>                                       </archive>
>                               </configuration>
>                       </plugin>
>                       <!--  anrrun plugin; this plugin as other the  two 
> above will be inherited by the the children pom  -->
>                       <plugin>
>                               <groupId>org.apache.maven.plugins</groupId>
>                               <artifactId>maven-antrun-plugin</artifactId>
>                               <dependencies>
>                                       <!--  why should we define  
> dependencies for the plugin -->
>                                       <dependency>
>                                               <groupId>commons-net</groupId>
>                                               
> <artifactId>commons-net</artifactId>
>                                               <version>1.4.1</version>
>                                       </dependency>
>                                       <dependency>
>                                               <groupId>ant</groupId>
>                                               
> <artifactId>ant-commons-net</artifactId>
>                                               <version>1.6.5</version>
>                                       </dependency>
>                               </dependencies>
>                               <executions>
>                                       <execution>
>                                               <id>install</id>
>                                               <phase>install</phase>
>                                               <configuration>
>                                                       <tasks 
> unless="maven.test.skip">
>                                                               <echo
>                                                                       
> message="To skip me, just call mvn -Dmaven.test.skip=true" />
>                                                               <echo
>                                                                       
> message="Alan Mehio ---: project.build.finalName:  ${basedir}/build.xml" />
>                                                       </tasks>
>                                               </configuration>
>                                               <goals>
>                                                       <goal>run</goal>
>                                               </goals>
>                                       </execution>
>                               </executions>
>                       </plugin>
>               </plugins>
>       </build>
> </project>
> the command I run is 
> mvn clean install -Dmaven.test.skip=true
> it did not skip  the "tasks" and it always go through the tasks  
> I use the "if" attribute and it does not do any check for the property; it 
> passes the validation eventhougth the property is not set 
> <tasks if="maven.project.alan.mehio.does.not.exit">
>                 <echo message="Does not skip the tasks "/>
> </tasks>
> it passes the check (if condition) event the property 
> "maven.project.alan.mehio.does.not.exit" does not exist 
> Regards,
> Alan Mehio
> London, UK
>               

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

        

Reply via email to