Hope that the below example can help you somehow:

<project>

  ...

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <id>ant-calling-example</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <!-- Core Ant tasks can be used as you use in build.xml -->
                <echo>Hello World</echo>
                <mkdir
dir="${project.build.directory}/generated-sources/newdir" />

                <!-- Even Ant-Contrib tasks, remember to add Ant-Contrib
                     dependency to your test classpath -->
                <taskdef name="for"
classname="net.sf.antcontrib.logic.ForTask"
                    classpathref="maven.test.classpath" />
                <taskdef name="var"
classname="net.sf.antcontrib.property.Variable"
                    classpathref="maven.test.classpath" />

                <fileset id="demo.files"
dir="${project.basedir}/src/main/demofiles">
                  <include name="1.txt" />
                  <include name="2.txt" />
                </fileset>

                <for param="filename">
                  <fileset refid="demo.files" />
                  <sequential>
                    <echo>@filename</echo>
                  </sequential>
                </for>

                <!-- Call a target in Ant build file -->

                <!-- These properties will be passed to Ant target -->
                <property name="foo" value="Foo Foo" />
                <property name="bar" value="Bar bar" />

                <ant antfile="build.xml" target="demo-target" />
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- For Ant-Contrib tasks -->
    <dependency>
      <groupId>ant-contrib</groupId>
      <artifactId>ant-contrib</artifactId>
      <version>1.0b3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  ...

</project>



CheapLisa wrote:
> 
> thanks, I'm still lost.  This section did not make much sense to me.
> 
> 
> 
> David M. Karr wrote:
>> 
>> CheapLisa wrote:
>>> I want to call some ant tasks when I run maven.
>>> 
>>> I have read all about the maven antrun plugin and found some
>>> examples, but the documentation is a wee bit hard
>>> for me to understand, and does not lead me to what I wish to accomplish.
>>> 
>>> I want all my ant tasks in a build.xml file (not in the pom.xml).
>>> 
>>> But when I execute:  mvn compile install
>>> 
>>> I want it to run (by default) one or more ant tasks 
>>> (in a specific order) that are in the build.xml.
>>> 
>>> Is there a way to do this?  When I type $mvn compile install I want
>>> the build process to be oblivous to the fact that ant is being called,
>>> unless there is a problem.
>>> 
>>> If the ant tasks fails, I want to fail the build as well.
>>> 
>>> thanks
>> 
>> I would assume the following is a good example of this kind of thing: 
>> <http://www.sonatype.com/books/maven-book/reference/lifecycle.html>.
>> 
>> You would use the "compile" phase instead of "pre-clean", and the inline 
>> task configuration would just use an "ant" task to call a target in your 
>> buildfile.
>> 
>> I don't know whether a failure in the Ant script will cause a top-level 
>> build failure.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-call-ant-task-from-maven---can-not-find-a-good-example-tp22992996p23010072.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to