How to delete .original file after Spring boot maven build - spring

After built, we are getting two jars.
One myjar.jar with all dependencies and another one myJar.jar.original without dependencies. How to delete the myJar.jar.original file ?
<build>
<finalName>myJar</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
</plugins>
</build>

This is how you could do it with maven-antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete file="target/myJar.jar.original" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>

Based on the question apparently there are two possible ways you are getting myJar.jar.original.
1. There might be repackage configuration in your pom.xml which repackages a jar or war that is built during the package phase of the Maven lifecycle.
Here is sample 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>
<!-- ... -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.1.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
If the above configuration is present then you simple $ mvn package command will generate myJar.jar.original and myJar.jar
$ mvn package
$ ls target/*.jar
target/myJar.jar target/myJar.jar.original
Secondly you might be using maven repackage to build you mvn
$ mvn package spring-boot:repackage
$ ls target/*.jar
target/myproject-1.0.0.jar target/myproject-1.0.0.jar.original
So please check your maven configuration and if you have the repackage in your pom than please remove it. Else if you are building using "$ mvn package spring-boot:repackage" than i would suggest you "$ mvn package"

Related

Checkstyle not working in build or verify phase

I cannot get maven checkstyle to run on build or verify, despite copy & pasting the code directly from the checkstyle website.
I can see checkstyle working fine and finding problems when running mvn checkstyle:check, but not on any phase like clean compile verify. These phases just compile fine and find no problems, completely ignoring checkstyle. I set up a minimal example here. The pom.xml is as follows:
<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">
<groupId>checkstyle-test</groupId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>15</java.version>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
You need to bind Checkstyle execution to the verify phase, like this:
...
<execution>
<id>checkstyle-check</id>
<phase>verify</phase>
<configuration>
<sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
<configLocation>config/checkstyle_checks.xml</configLocation>
<encoding>UTF-8</encoding>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
...
This snippet is taken from one of my projects, you can view the entire pom.xml here.
Figured it out: I had the block in <pluginManagement>. Moving it out of there it instantly worked. I wished, maven would have more complete example on their website.

Apache Dashboard HTML reports with Jmeter Maven plugin

I want mvn clean verify to run following command for me
jmeter -n -t <file.jmx> -l <reports.csv> -e -o /htmlReports
I checked below similar question How to create HTML reports using Jmeter Maven Plugin 2.1.0. but it didn't work for me.
I want all data to be inside target folder, plus .jtl so that at next run all previous gets cleaned up.
pom.xml
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.performancetesting</groupId>
<artifactId>Demo-performance-testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.8.0</version>
<configuration>
<generateReports>true</generateReports>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.codecentric</groupId>
<artifactId>jmeter-graph-maven-plugin</artifactId>
<version>0.1.0</version>
<configuration>
<inputFile>${project.build.directory}/jmeter/results/*.jtl</inputFile>
<graphs>
<graph>
<pluginType>ResponseTimesOverTime</pluginType>
<width>800</width>
<height>600</height>
<outputFile>${project.build.directory}/jmeter/results/BlazeDemoRequest.png</outputFile>
</graph>
</graphs>
</configuration>
</plugin>
</plugins>
</build>
</project>
You can do this using Maven Exec plugin, the relevant configuration would be
<configuration>
<basedir>/path/to/bin/folder/of/your/jmeter/installation</basedir>
<executable>jmeter</executable>
<commandlineArgs>-n -t -f file.jmx -l ${basedir}/target/reports.csv -e -o ${basedir}/target/htmlReports</commandlineArgs>
</configuration>
Just in case something "will not work" again here is full pom.xml file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<basedir>/path/to/bin/folder/of/your/jmeter/installation</basedir>
<executable>jmeter</executable>
<commandlineArgs>-n -t -f file.jmx -l ${basedir}/target/reports.csv -e -o
${basedir}/target/htmlReports
</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Don't forget to change /path/to/bin/folder/of/your/jmeter/installation to real path to your JMeter otherwise it "will not work".
Report generation via JMeter Maven Plugin should also work fine, if you experience any issues please show your pom.xml file and maven command output.
Example configuration you can use for reference:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.8.0</version>
<executions>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<generateReports>true</generateReports>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
N.B.
you will need to copy your file.jmx script into src/test/jmeter folder, otherwise it "will not work"
if your test is using any JMeter Plugins - it "will not work" without defining them as dependencies
if your test uses external data files - it "will not work" unless you copy them to src/test/jmeter folder
More information: Five Ways To Launch a JMeter Test without Using the JMeter GUI
Report generation with JMeter Maven Plugin works for your requirement, you don't need any additional plugin.
Example:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.performancetesting</groupId>
<artifactId>Demo-performance-testing</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.8.0</version>
<executions>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Requirements:
copy your jmx file into src/test/jmeter folder
if you use 3rd party plugins like JMeter Plugins, ensure you follow this documentation
if you use CSV data files - copy them to src/test/jmeter folder
Step 1 - Create test plan and save JMX script
Step 2 - Executing JMeter tests
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreResultFailures>true</ignoreResultFailures>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
</plugin>
Step 3 - Save test result into csv/xls file
Step 4 - The following plugin is used to transform the result
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${project.build.directory}/jmeter/results</dir>
<stylesheet>${project.basedir}/src/main/jmeter-results-report_21.xsl</stylesheet>
<outputDir>${project.build.directory}/jmeter/results</outputDir>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
<pattern>(.*?)\s(.*?)</pattern>
<replacement>$1$2</replacement>
<replaceAll>true</replaceAll>
</fileMapper>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
</plugin>

Maven tests run twice when a profile identifier is in multiple projects. Why?

I have numerous projects in IntelliJ, each of which has a pom.xml, and each of the projects' poms inherit from the master pom.xml. One profile (called test1) is present in two of the poms (for project2 and project4). When I run maven from the command line, specifying one project and the profile name, it works (the tests in that project are executed once) Here is the commmand:
mvn test -pl project2 -am -P test1
When I specify both projects (both of which have the same profile present), the tests in project4 are executed twice. Here is the command:
mvn test -pl project2,project4 -am -P test1
I would like the tests only to be executed once. I am running maven 3.1.1.
As a further complication, when I specify just project4, the tests in project2 get executed once, and the tests in project4 don't get executed at all. Here is the command:
mvn test -pl project4 -am -P test1
Here is pom.xml for project2:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns stuff...>
<parent>
<artifactId>parent artifact id</artifactId>
<groupId>group id</groupId>
<version>version</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>project2</name>
<artifactId>project2</artifactId>
<packaging>jar</packaging>
<profiles>
<profile>
<id>test1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>execute-tests-1</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>com/path/to/exclude/**/*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<!-- We don't want to run any tests without an active profile -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!-- This exports the classes in the tests for use with our other modules' tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
[ dependencies ...]
</dependencies>
</project>
Here is the pom.xml for project4:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns stuff>
<parent>
<artifactId>[parent artifact id]</artifactId>
<groupId>[group id]</groupId>
<version>[version]</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>project4</name>
<artifactId>project4</artifactId>
<packaging>jar</packaging>
<dependencies>
[ dependencies ...]
</dependencies>
<profiles>
<profile>
<id>test1</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>execute-tests-2</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>com/path/to/tests/*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
[ dependencies...]
</dependencies>
</profile>
</profiles>
</project>
I figured out the answer to my own question (by looking carefully at some of our other projects' Maven test setup). I had to do two things:
Include a <skip>false</skip> element in the <configuration> aggregate in the surefire plugin.
Include a generic surefire <plugins> aggregate outside of the <profiles> section. This one has <skip> set to true and prevents tests being run unless they are in a profile. Here is what the section looks like:
<build>
<plugins>
<!-- We don't want to run any tests without an active profile -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
The problem was that the tests were running the default-test lifecycle phase and then they were running again in the test phase. After I made the change they only ran in the test phase.

maven-release-plugin does not work for multi-module POMs

Plugin version: 2.0
I am trying to use the maven-release-plugin to set the version of the parent POM and all modules.
Using the following parent POM:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.mycompany</groupId>
<artifactId>myProject</artifactId>
<version>latest-SNAPSHOT</version>
<packaging>pom</packaging>
<name>My Project</name>
<modules>
<module>../../subPom1</module>
<module>../../subPom2</module>
<module>../../subPom3</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>clean</phase>
<id>set-release-versions</id>
<configuration>
<developmentVersion>1.1.8</developmentVersion>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When running mvn clean install -DskipTests -Pdeploy, the configuration to run the plugin on the clean phase is totally ignored and the build is made using the value "latest-SNAPSHOT".
I was expecting it to pick up the value "1.1.8" from the plugin configuration.
Each child POM is equivalent to:
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>uk.co.mycompany</groupId>
<artifactId>myProject</artifactId>
<version>latest-SNAPSHOT</version>
<relativePath>../../System/build/parentPom.xml</relativePath>
</parent>
...
</project>
Why is the configuration ignored?
Edit #1: Filesystem structure as requested:
/
|- system
| |
| |- build
| |
| |-parentPOM file
|
|- business
| |
| | - childPOM1
| | - childPOM2
|- client
| | - childPOM3
| | - childPOM4
Ignore the .../... in the SSCCE - I have obfuscated the true values to describe the problem generically.
Edit #2: I have moved the definition to <pluginManagement> as advised but the problem remains the same (not using plugin, no feedback to console):
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<configuration>
<developmentVersion>1.1.8</developmentVersion>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
You forgot to set the goal of the plugin. You configured the parameter needed for the update-versions goal but you told maven only to execute the plugin in the clean phase, but not which goal of the plugin. So it does nothing at all.
Check the maven log when you try a mvn clean it should only show:
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # test ---
When you change your config to:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>clean</phase>
<id>set-release-versions</id>
<goals><goal>update-versions</goal></goals>
<configuration>
<developmentVersion>1.1.8</developmentVersion>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The goal update-versions is called in the clean phase of maven.
[INFO] --- maven-release-plugin:2.0:update-versions (set-release-versions) # bdd ---
Not sure if this will solve all your problems but this will force maven to execute the plugin in the clean phase like expected.
However the release plugin needs a lot of special settings (like a scm connection) when used for only changing the version. So I suggest to use the versions-maven-plugin
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<goals>
<goal>set</goal>
</goals>
<phase>clean</phase>
<configuration>
<newVersion>1.1.8</newVersion>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
In the end, I gave up.
That Stack Overflow et all is littered with unanswered questions just like this one, and that the plugin documentation fails to provide usage examples in POM format, tells me everything that I need to know about this plugin.
My workaround was to set the parent POM's version to "latest-SNAPSHOT" and introduce a property called <myproject.release.version>, which I used everywhere that I wanted to print the release number.
In particular, I wanted to print the release number in the WAR file's manifest. I did so as below:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>${myproject.release.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<filters>
<filter>${project.parent.basedir}/filter/${webapp.filter}.properties</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Using the above configuration, I drop the release number, as a Maven property, into my manifest.
In my application, I pick it up from there and draw it on the screen.

Set directory in Maven Antrun Plugin

I've downloaded jquery-ui to my webapp which has a build.xml for compressing and minifying.
Now I would like to run this build.xml from within my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<ant antfile="src/main/webapp/resources/js/jquery-ui/build/build.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
But now the behavior for this buildfile is wrong. It creates a dist folder on the wrong place. Here's thebuild.xml` from jquery-ui: https://github.com/jquery/jquery-ui/blob/master/build/build.xml
It creates the dist folder on the same place where pom.xml is (same place i run mvn clean package) and it should create it in src/main/webapp/resources/js/jquery-ui/build
Is it possible to run build.xml from a specified directory (working directory)?
Can't access the documentation for the Ant task: http://ant.apache.org/manual/CoreTasks/ant.html
EDIT: 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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.myproject</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>myproject</name>
<dependencies>
<!-- ... -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- ... -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>myproject</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<executable>make</executable>
<workingDirectory>src/main/webapp/resources/js/jquery</workingDirectory>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<ant antfile="build.xml" dir="src/main/webapp/resources/js/jquery-ui/build" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
On running mvn clean package I'm getting the following errors in minify target of jquery-ui's build.xml:
[apply] build/minify-js.sh: Line 3: /home/danny/myproject/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js: File or directory not found
The correct path should be ${basedir}/src/main/webapp/resources/js/jquery-ui/build/dist/jquery-ui-1.9pre/ui/minified/jquery-ui.min.js instead of the above mentioned...
According to http://ant.apache.org/manual/Tasks/ant.html, you can use the dir attribute:
<mkdir dir="${project.build.directory}/jquery-ui" />
<ant antfile="src/main/webapp/resources/js/jquery-ui/build/build.xml" dir="${project.build.directory}/jquery-ui" />
On the other hand, are you really sure you want to create the build directory underneath your src directory? Shouldn't this go into target rather?
I would recommend to use the maven plugin instead of Ant calls. Based on the docs maven-minify-plugin to do what you need. The plugin can be found in Maven Central. And furthermore you will find the maven-plugin-documention how to use the maven-plugin.

Resources