I want to run an ant
build.xml file in Maven and see all the regular logs that ant shows when running the build file. The build file contains numerous targets and are called from one another. Our ant project also utilises many jar files and pull other maven projects we have. Currently I run numerous pre-setup tasks via our Batch file such as pulling other maven projects via curl, using tar.exe
to unzip them etc. I have migrated the entire project in maven and use plugins instead which is looks great and seems more reliable. I only have one issue which will prevent us from using this new maven project that the regular logs that appear when running the build file via ant do not appear in maven such as printing the target that was called. We also have the requirement of not running maven in debug mode all the time and the target details should be shown. I have written a temp project below to show the problem. Need help
When running with ant.exe
– ant -file build.xml
:
C:temp>ant -file build.xml
ANT_OPTS is set to -Djava.security.manager=allow
Buildfile: C:tempbuild.xml
default:
[delete] Deleting directory C:temptest
[mkdir] Created dir: C:temptest
target1:
[echo] HERE
BUILD SUCCESSFUL
Total time: 0 seconds
When running with maven
(there are not target opening logs without debug mode) – mvn clean install -e -U
:
[INFO] --- maven-antrun-plugin:3.1.0:run (temp) @ temp ---
[INFO] Executing tasks
[INFO] [delete] Deleting directory C:temptest
[INFO] [mkdir] Created dir: C:temptest
[WARNING] [echo] HERE
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.954 s
[INFO] Finished at: 2024-04-30T09:19:43+10:00
[INFO] ------------------------------------------------------------------------
pom.xml
:
<?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://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>temp</groupId>
<artifactId>temp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<skipTests>true</skipTests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<!-- Versions -->
<version.ant-contrib.ant-contrib>1.0b3</version.ant-contrib.ant-contrib>
<version.org.apache.ant.ant>1.10.13</version.org.apache.ant.ant>
<version.org.apache.maven.plugins.maven-antrun-plugin>3.1.0</version.org.apache.maven.plugins.maven-antrun-plugin>
</properties>
<profiles>
<profile>
<id>temp</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${version.org.apache.maven.plugins.maven-antrun-plugin}</version>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>${version.org.apache.ant.ant}</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>${version.ant-contrib.ant-contrib}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>temp</id>
<phase>install</phase>
<configuration>
<target>
<ant antfile="${project.basedir}${file.separator}build.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
build.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project name="temp" basedir="." default="default">
<target name="default">
<sequential>
<delete dir="${basedir}${file.separator}test" />
<mkdir dir="${basedir}${file.separator}test" />
<antcall target="target1"></antcall>
</sequential>
</target>
<target name="target1">
<sequential>
<echo>HERE</echo>
</sequential>
</target>
</project>