Multiple MAVEN modules sharing a common source folder - maven

A central POM defines multiple JAR modules what must package parts of a central, common source folder. This is a legacy project and I want to keep the source files in one single place. Is it possible to set up MAVEN to compile and package only parts of this source folder?
SK

You are right, this is the solution:
...
<build>
<sourceDirectory>../src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.build.helper.maven.plugin}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>sk/maven/api/**/*.*</source>
<source>sk/ext/lib/**/*.*</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven.compile.plugin}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<includes>
<include>sk/maven/api/**/*.*</include>
<include>sk/ext/lib/**/*.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<includes>
<include>sk/maven/api/**/*.*</include>
</includes>
</configuration>
</plugin>

Related

Exclude log4j.properties in the generated jar

I am using maven-compiler-plugin to build a JAR from one of my module, and I am not able to exclude log4j.properties from the generated JAR.
I tried:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>8</source>
<target>8</target>
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
But this does not work. I can exclude the file globally:
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>log4j.properties</exclude>
</excludes>
</resource>
</resources>
But I don't want to do this as this impact the Eclipse build, and makes it impossible to run code from Eclipse that uses log4j.
I tried to see if the included log4j.properties was mine and not from another module, and it is mine. I've read numerous posts on the issue, including some here, but I still cannot solve it...
If this matters, this module is a submodule of a parent package, with the following <build>:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
<executions>
<execution>
<id>create-javadoc</id>
<phase>javadoc</phase>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
</build>

Maven does not copy resource files

I have a maven web application project that follows the maven standard directory layout so I have my resource files placed in src/main/resources/.
As this follows the standard I was expecting maven to automatically add the resource files to /WEB-INF/classes of the web application during the build but no files are copied.
I have to add the following lines to the build section of the pom file to get maven to copy the files:
<resources>
<resource>
<directory>src/main/resources/</directory>
</resource>
</resources>
My question is: is this supposed to be necessary?
I was wondering if any of the build section plugins I use could somehow interfere with the copying of the resources. Are there any plugins that are known to do this?
The build section of my pom file is here:
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>${tests.to.include}</include>
</includes>
<excludes>
<exclude>${tests.to.exclude}</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<includes>
<include>**/ITSelenium*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>add extra source directories</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${project.basedir}/generated/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add extra test directories</id>
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>${project.basedir}/generated/src/test/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add integration test sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/it/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>res</warName>
<webResources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
</plugins>
</build>
Any help or information will be much appreciated.

Maven: Reporting warnings during regular compile, but not for generated sources

We have a Maven project that uses WSDL files that are turned into Java source files and later compiled.
When this project used Ant, we compiled the generated Java source file and the normal developer written Java source files separately. This allowed me to turn on deprecation and warnings on compiling the developer written Java files, but off for compiling the WSDL generated Java files. I want the developers to fix their warnings and deprecations, but I can't hold the developers responsible for code that the WSDLs generated.
Now, we've moved the project over to Maven, and I would like to do the same thing: Compile the WSDL generated Java source code without the warnings and compile the developer written Java source code with the warnings. Is it possible to do with Maven? (I mean without writing it in Ant and embedding that in the pom.xml).
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vegicorp</groupId>
<artifactId>crypto</artifactId>
<packaging>bundle</packaging>
<version>2.0.4</version> <!--package version-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<axis2.version>1.5.6</axis2.version>
<maven.dir>${project.build.directory}/maven/crypto.jar</maven.dir>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugins</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<debug>true</debug>
<debugLevel>lines,vars,source</debugLevel>
<compilerArgs>
<arg>-Xlint</arg>
<arg>Xmaxwarns</arg>
<arg>9999</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.7</version>
<configuration>
<archive>
<manifestSections>
<manifestSection>
<name>Build-Information</name>
<manifestEntries>
<Project-Name>${env.JOB_NAME}</Project-Name>
<Build-Number>${env.BUILD_NUMBER}</Build-Number>
<SVN-Revision>${env.SVN_REVISION}</SVN-Revision>
</manifestEntries>
</manifestSection>
<manifestSection>
<name>Module-Information</name>
<manifestEntries>
<Group-ID>${project.groupId}</Group-ID>
<Artifact-ID>${project.artifactId}</Artifact-ID>
<Version>${project.version}</Version>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>${axis2.version}</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<packageName>com.safenet.tokenization.wsclient</packageName>
<wsdlFile>src/main/wsdl/SafeNetTokenizer.wsdl</wsdlFile>
<databindingName>adb</databindingName>
<skipBuildXML>true</skipBuildXML>
<syncMode>sync</syncMode>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
<targetSourceFolderLocation>generated-sources</targetSourceFolderLocation>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<reuseFork>true</reuseFork>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<!-- COMPILE -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
...
</dependencies>
</project>
Okay, I figured out how to do this, but I am not enamored with the solution:
Define two separate maven-compiler-plugin executions. One called default-compile where I compile the WSDL code, and one called main-compile where I compile the rest of the code.
Use <includes/> and <excludes> in the main-compiler-plugin execution configurations to include and exclude the code I want to compile.
I still need the build-helper-maven-plugin to define two separate source.
The default-compile is always executed (I couldn't figure out a way to turn it off) even if I don't have a configuration default-compile. That would automatically compile everything before looking at my two defined maven-compile-plugin plugin executions. To get around this, I named the WSDL compile default-compile.
Here's the mavin-compiler-plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/com/safenet/**</include>
</includes>
<excludes>
<exclude>**/com/vegicorp/**</exclude>
</excludes>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>false</showDeprecation>
<showWarnings>false</showWarnings>
<debug>true</debug>
<debugLevel>lines,vars,source</debugLevel>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>main-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/com/vegicorp/**</include>
</includes>
<excludes>
<exclude>**/com/safenet/**</exclude>
</excludes>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<debug>true</debug>
<debugLevel>lines,vars,source</debugLevel>
<compilerArgs>
<arg>-Xlint</arg>
<arg>Xmaxwarns</arg>
<arg>9999</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
I found David W.'s answer very useful. Unfortunately, I could not find an easy way to separate generated-sources for my current project using <includes>/<excludes> (and <testIncludes>/<testExcludes> for default-testCompile), since they appear to be checked against paths relative to compileSourceRoots.
The solution that worked best for me is to specify <compileSourceRoots> for each <execution>:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${project.build.directory}/generated-sources/swagger/src/main/java</compileSourceRoot>
</compileSourceRoots>
<showWarnings>false</showWarnings>
</configuration>
</execution>
<execution>
<id>compile-with-warnings</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${project.build.sourceDirectory}</compileSourceRoot>
</compileSourceRoots>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
<compileSourceRoots>
<compileSourceRoot>${project.build.testSourceDirectory}</compileSourceRoot>
</compileSourceRoots>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
This has the advantage of no longer requiring build-helper-maven-plugin (since ${project.compileSourceRoots} is ignored), but the disadvantage that since ${project.compileSourceRoots} is ignored, compileSourceRoot for each generator plugin must be added to an <execution> explicitly or it will not be compiled.

yuicompressor maven plugin and maven-war-plugin

I've been struggling with getting this plugin to play nicely with the maven-war-plugin for a couple of hours now and I thought it was time to ask for help. I have the plugin defined as follows:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>compressyui</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<jswarn>false</jswarn>
</configuration>
</execution>
</executions>
</plugin>
If I remove nosuffix=true then I can see the compressed/minified -min.js files get into the war as expected, but with this flag on they are being overwritten by the maven-war-plugin (I'm assuming) when it builds the war file. I really need the file names to remain the same though ... does anyone have an idea of what I need to change in order to use the same filenames and still get the minified versions into the final war?
OK. I finally figured this out. You need to define a <webappDirectory> in the yuicompressor plugin that can then be referenced as a <resource> in the maven-war-plugin. In the example below I'm using <directory>${project.build.directory}/min</directory>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<id>compressyui</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<webappDirectory>${project.build.directory}/min</webappDirectory>
<jswarn>false</jswarn>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
<configuration>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<encoding>UTF-8</encoding>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
Just configure 'warSourceExcludes' on the WAR plugin.
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceExcludes>**/*.css,**/*.js</warSourceExcludes>
</configuration>
</plugin>
I would like to add the configuration which worked for me:
First, to fix m2e complaining about the 'Plugin execution not covered by lifecycle' I added the following in the parent pom taken from this post:
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>compress</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Then in the war pom I put:
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<linebreakpos>300</linebreakpos>
<excludes>
<exclude>**/*-min.js</exclude>
<exclude>**/*.min.js</exclude>
<exclude>**/*-min.css</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
<nosuffix>true</nosuffix>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceExcludes>**/*.css,**/*.js</warSourceExcludes>
</configuration>
</plugin>
</plugins>
</build>
This generates the minified css and js files in the project build target directory while excluding the original files.
I hope this saves someone time.
this is my configuration, and it works fine in my maven web project:
<!-- js/css compress -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<excludes>
<exclude>**/*-min.js</exclude>
<exclude>**/*.min.js</exclude>
<exclude>**/*-min.css</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
<jswarn>false</jswarn>
<nosuffix>true</nosuffix>
</configuration>
<executions>
<execution>
<id>compress_js_css</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- war -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}/resources</directory>
<targetPath>/resources</targetPath>
<filtering>false</filtering>
</resource>
</webResources>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
The approach I use is a bit different.
First, I've configured my IDE to run mvn process-resources before the compilation/packaging. This way the files are created before the war is assembled.
It is very important to set <nosuffix>false</nosuffix> and <outputDirectory>${basedir}/src/main/resources/</outputDirectory> so the files can be created in the same directory without replacing your original source files.
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<preProcessAggregates>false</preProcessAggregates>
<excludes>
<exclude>**/*-min.js</exclude>
<exclude>**/*.min.js</exclude>
<exclude>**/*-min.css</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
<jswarn>false</jswarn>
<nosuffix>false</nosuffix> <!-- VERY IMPORTANT WILL REPLACE YOUR FILES IF YOU SET nosuffix TO TRUE OR DONT SET IT AT ALL -->
<outputDirectory>${basedir}/src/main/resources/</outputDirectory> <!-- by default the plugin will copy the minimized version to target directory -->
<failOnWarning>false</failOnWarning>
</configuration>
<executions>
<execution>
<id>compress_js_css</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
</plugin>
As Jakob Kruse say, you must deal with the *.js, but no *.min.js, so my configurations is below, please notice the use of %regex[] :
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>compressyui</id>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<webappDirectory>${project.build.directory}/min</webappDirectory>
<jswarn>false</jswarn>
<excludes>
<exclude>**/*-min.js</exclude>
<exclude>**/*.min.js</exclude>
<exclude>**/*-min.css</exclude>
<exclude>**/*.min.css</exclude>
<exclude>**/jquery.window.js</exclude>
......
<exclude>**/compile.js</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<packagingExcludes>servlet-api*.jar,target/test-classes/*</packagingExcludes>
<warSourceExcludes>test/**,%regex[.*(!min).js],%regex[.*(!min).css]</warSourceExcludes>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
Without pom.xml change
mvn net.alchim31.maven:yuicompressor-maven-plugin:compress
To force compress every js and css files and fail if warning
mvn net.alchim31.maven:yuicompressor-maven-plugin:compress \
-Dmaven.yuicompressor.force=true \
-Dmaven.yuicompressor.failOnWarning=true \
For more options:
http://davidb.github.io/yuicompressor-maven-plugin/usage_compress.html

maven-compiler-plugin how to change the classes destination directory

By default the maven compiler plugin put the compiled classes into ${project.build.directory}/classes. I want to put them into ${project.build.directory}/myclasses. The argument -d changes the destination of the compiled classes. I configured the plugin but I got an error: javac: directory not found: C:\home\target/myclasses.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<showDeprecation>true</showDeprecation>
<compilerArguments>
<d>${project.build.directory}/myclasses</d>
</compilerArguments>
</configuration>
</plugin>
You should be able to do it like this:
<build>
<outputDirectory>${project.build.directory}/myclasses</outputDirectory>
</build>
The destination folder must exists. You can create it using a ant task:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>createClassesDir</id>
<phase>process-resources</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/myclasses" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

Resources