Use maven antrun plugin to create directory in target folder
Use maven antrun plugin to create directory in target folder
Use maven antrun plugin to create directory in target folder
Watch Explanation on YouTube
How to use maven antrun plugin to create directory in target folder
Creating a directory in maven target folder can be achieved by using “maven-antrun-plugin”.
This plugin keeps the deletion or creation of directory platform independent.
This plugin usage example is also present on below maven site maven-antrun-plugin usage
An example of same:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>tempFolder</id>
<phase>generate-test-resources</phase>
<configuration>
<tasks>
<echo message="Creating temporary directory"/>
<delete dir="./target/temp"/>
<mkdir dir="./target/temp"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>tempFolder</id>
<phase>generate-test-resources</phase>
<configuration>
<target>
<echo message="Creating temporary directory"/>
<delete dir="./target/temp"/>
<mkdir dir="./target/temp"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
We can change the phase of directory creation.
The phases can be found documented @ below maven site under “Default Lifecycle”.
You can get this plugin latest version at maven central using the below link
This post is licensed under
CC BY 4.0
by the author.