logo Apache Maven AntRun Plugin

Runs Ant scripts embedded in the POM

homepage: maven.apache.org/plugins
fresh index:
last release: 2 years ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
antrun:help

Display help information on maven-antrun-plugin. Call mvn antrun:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

antrun:run

Maven AntRun Mojo. This plugin provides the capability of calling Ant tasks from a POM by running the nested Ant tasks inside the <target/> parameter. It is encouraged to move the actual tasks to a separate build.xml file and call that file with an <ant/> task.

Often used code snippets:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.1</version>
  <executions>
    <execution>
      <id>clean_target</id>
      <phase>install</phase>
      <configuration>
        <tasks>
          <delete dir="src/main/resources"/>
          <delete dir="src/main"/>
          <delete dir="src"/>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.1</version>
  <executions>
    <execution>
      <id>source-code-generation</id>
      <phase>process-resources</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
          <path id="wsdl2java.classpath">
            <pathelement location="${settings.localRepository}/org/apache/ws/commons/axiom/wso2/axiom/${axiom.wso2.version}/axiom-${axiom.wso2.version}.jar"/>
            <pathelement location="${settings.localRepository}/org/apache/axis2/wso2/axis2-client/${axis2.wso2.version}/axis2-client-${axis2.wso2.version}.jar"/>
            <pathelement location="${settings.localRepository}/org/apache/axis2/wso2/axis2/${axis2.wso2.version}/axis2-${axis2.wso2.version}.jar"/>
          </path>
          <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
            <arg line="-uri src/main/resources/ClaimMetadataManagementService.wsdl -u -uw -o target/generated-code -p org.wso2.carbon.identity.claim.metadata.mgt.stub -ns2p http://mgt.metadata.claim.identity.carbon.wso2.org=org.wso2.carbon.identity.claim.metadata.mgt.stub,http://dto.mgt.metadata.claim.identity.carbon.wso2.org/xsd=org.wso2.carbon.identity.claim.metadata.mgt.stub.dto,http://exception.mgt.metadata.claim.identity.carbon.wso2.org/xsd=org.wso2.carbon.identity.claim.metadata.mgt.exception,http://org.apache.axis2/xsd=org.wso2.carbon.identity.claim.metadata.mgt.stub.types.axis2,http://claim.core.user.carbon.wso2.org/xsd=org.wso2.carbon.identity.claim.metada.mgt.stub.types"/>
            <classpath refid="wsdl2java.classpath"/>
          </java>
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.1</version>
  <executions>
    <execution>
      <id>clean-APIM-h2-database</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
          <delete file="src/main/resources/repository/database/WSO2AM_DB.h2.db"/>
        </tasks>
      </configuration>
    </execution>
    <execution>
      <id>create-API-manager-database</id>
      <phase>package</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
          <path id="h2.classpath">
            <path refid="maven.compile.classpath"/>
          </path>
          <echo message="########### Creating API Manager Database ##############"/>
          <sql autocommit="true" driver="org.h2.Driver" onerror="continue" password="wso2carbon" url="jdbc:h2:${basedir}/src/main/resources/repository/database/WSO2AM_DB;create=true" userid="wso2carbon">
            <classpath>
              <path refid="h2.classpath"/>
            </classpath>
            <fileset file="${basedir}/src/main/resources/sql/h2.sql"/>
          </sql>
          <echo message="##################### END ########################"/>
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>clean_target</id>
      <phase>install</phase>
      <configuration>
        <target>
          <delete dir="src/main/resources"/>
          <delete dir="src/main"/>
          <delete dir="src"/>
        </target>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>create-test-database</id>
      <phase>compile</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
          <path id="h2.classpath">
            <path refid="maven.compile.classpath"/>
          </path>
          <echo message="########### Create Test Database ##############"/>
          <sql autocommit="true" driver="org.h2.Driver" onerror="continue" password="wso2carbon" url="jdbc:h2:${basedir}/target/repository/database/WSO2AM_DB" userid="wso2carbon">
            <classpath>
              <path refid="h2.classpath"/>
            </classpath>
            <fileset file="${basedir}/src/test/resources/dbscripts/h2.sql"/>
            <fileset file="${basedir}/src/test/resources/dbscripts/h2-sample-data.sql"/>
          </sql>
          <echo message="##################### END ########################"/>
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.