gwt maven war plugin configuration problem - gwt

I am developing a gwt application in maven. In this I am using maven war plugin. Everything works fine. When I give mvn install command it builds abc.war file in target folder. But it is not copying compiled javascript files ("module1" and "module2" directories present in target) to war directory. I want to get newly compiled javascript files in war directory. How to achieve this?
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>example</artifactId>
<packaging>war</packaging>
<version>12</version>
<name>gwt-maven-archetype-project</name>
<properties>
<!-- convenience to define GWT version in one place -->
<gwt.version>2.1.0</gwt.version>
<noServer>false</noServer>
<skipTest>true</skipTest>
<gwt.localWorkers>1</gwt.localWorkers>
<JAVA_HOME>C:\Program Files\Java\jdk1.6.0_22</JAVA_HOME>
<!-- convenience to define Spring version in one place -->
</properties>
<dependencies>
<!-- Required dependencies-->
</dependencies>
<build>
<finalName>abc</finalName>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<executable>${JAVA_HOME}\bin\java.exe</executable>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>mergewebxml</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<servicePattern>**/client/**/*Service.java</servicePattern>
<noServer>${noServer}</noServer>
<noserver>${noServer}</noserver>
<modules>
<module>com.abc.example.Module1</module>
<module>com.abc.example.Module2</module>
</modules>
<runTarget>com.abc.example.Module1/module1.jsp</runTarget>
<port>8080</port>
<extraJvmArgs>-Xmx1024m -Xms1024m -Xss1024k -Dgwt.jjs.permutationWorkerFactory=com.google.gwt.dev.ThreadedPermutationWorkerFactory</extraJvmArgs>
<hostedWebapp>war</hostedWebapp>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
<!--<webXml>src/main/webapp/WEB-INF/web.xml</webXml>-->
<containerConfigXML>war/WEB-INF/classes/context/context.xml</containerConfigXML>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<argLine>-Xmx1024m</argLine>
<skipTests>${skipTest}</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
<configuration>
<filesets>
<fileset>
<directory>war/module1</directory>
</fileset>
<fileset>
<directory>war/module2</directory>
</fileset>
<fileset>
<directory>war/WEB-INF/lib</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/public/resources/**</exclude>
<exclude>**/public/images/**</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/resources/build/build-${env}.properties</filter>
</filters>
</build>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>

Adding
<inplace>true</inplace>
in the gwt-maven-plugin configuration tags solved the issue.

While I am unfamiliar with gwt based application using maven, maven war plugin allows adding of external web resources. You could add something similar to the below in the section of maven-war-plugin.
<webResources>
<resource>
<directory>${project.build.directory}</directory>
<targetPath>war</targetPath>
<includes>
<include>module1/**</include>
<include>module2/**</include>
</includes>
</resource>
</webResources>

Related

Why isn't my dependency listed in my manifest.mf?

I have an EJB project that requires org.apache.commons.lang3. I have in my 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.kable.newsstand.kdsejb</groupId>
<artifactId>kds-ejb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>com.kable.maven</groupId>
<artifactId>kable-super-pom</artifactId>
<version>[0.1,1.0)</version>
</parent>
<dependencies>
....
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>ejbModule</sourceDirectory>
<resources>
<resource>
<directory>ejbModule</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<archive>
<manifestEntries>
<Dependencies>org.apache.commons.lang3</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I Project > Export > EJB Jar File, the dependency isn't listed in the MANIFEST.MF
Manifest-Version: 1.0
Built-By: BRay
Build-Jdk: 9.0.1
Created-By: Maven Integration for Eclipse
I have included the maven-ejb-plugin
I also included the archive -> manifestEntries -> dependencies nodes for the plug-in
Ok, #khmarbaise 's response, lead me to look at some stuff and my results are as follows.
Change the maven-ejb-plugin configuration in the pom.xml as follows.
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<jarName>kdsSession</jarName> <!-- I need a different jar name -->
<outputDirectory>${basedir}</outputDirectory> <!-- I want my jar in the root, not the /target -->
<ejbVersion>3.1</ejbVersion>
<archive>
<manifestEntries>
<Dependencies>org.apache.commons.lang3</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
Then I created a new Run Configuration "Run as maven build..." with ejb:ejb for the goal.
I use the new Runtime configuration to build the ejb.jar instead of the Export -> EJB Jar.

Eclipse m2e overwrites buildNumber from buildnumber-maven-plugin

I'm using Eclipse m2e, buildnumber-maven-plugin, and templating-maven-plugin to create a filtered java file with ${buildNumber}.
Here is a sample from the src/main/java-templates/build.java file:
public static final String BUILDNUMBER = "${buildNumber}";
If I run "mvn generate-sources" on the command line, my filtered java file contains the generated buildNumber value. If I run "generate-sources" from within Eclipse using m2e, the filtered java file briefly contains the actual buildNumber but is quickly replaced with the original string "${buildNumber}"
The structure of the project is
CmbProduct/pom.xml
+-- Model/pom.xml
+-- other modules
The buildnumber-maven-plugin is run in the parent pom.xml because I use buildNumber to set a general <finalName> value for all sub-modules.
I have tried it with and without lifecycle-mapping for org.eclipse.m2e.
I did not notice any change.
I have several "echo" tasks in both pom.xml files for debug purposes. These show the correct/actual buildNumber when run.
Here is an abbreviated CmbProduct/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.magnicomp</groupId>
<artifactId>Product</artifactId>
<!-- Do not change version EVER. This is used by MagniCompCommon and all other sub modules. -->
<version>1.0</version>
<packaging>pom</packaging>
<name>CMB Product</name>
<modules>
<module>Model</module>
<module>Common</module>
</modules>
<scm>
<!-- SCM used by buildnumber-maven-plugin and others -->
<connection>scm:git:git://sol:/vol/git/cmb.git</connection>
</scm>
<properties>
<!--
The canonical Product Version is defined below. This value is
automatically propagated to Java via plugin in the Modelproject.
The ${buildNumber} is automatically generated on-the-fly by
buildnumber-maven-plugin
-->
<!--
Product version defined primary version of product.
This is used instead of project.version because the later must
remain the same.
-->
<product.version.base>1.0.0</product.version.base>
<product.version.status>alpha1</product.version.status>
<product.version>${product.version.base}.${buildNumber}-${product.version.status}</product.version>
<!-- Version in 4 dot (digits + dot) format suitable for Windows file Version -->
<product.version.4dot>${product.version.base}.${buildNumber}</product.version.4dot>
<!-- Java version -->
<project.source.version>1.8</project.source.version>
<project.target.version>1.8</project.target.version>
<!-- MagniComp common -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<hibernate.version>4.3.11.Final</hibernate.version> <!-- was 4.3.10.Final -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<texo.version>0.9.0-v201501182340</texo.version>
<emf.version>2.11.0-v20150123-0347</emf.version>
<!-- Vaadin -->
<vaadin.version>7.5.7</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<vaadin.icons.version>1.0.1</vaadin.icons.version>
<!-- Product specific -->
<javax.servlet.version>3.1</javax.servlet.version>
<jersey.glassfish.version>2.21</jersey.glassfish.version>
<bouncy.version>1.51</bouncy.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<maven.shade.plugin.version>2.4.1</maven.shade.plugin.version>
<jna.version>4.1.0</jna.version>
</properties>
<build>
<finalName>${project.artifactId}-${product.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<!-- We do not need a default assembly.xml
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
-->
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.4,)</versionRange>
<goals>
<goal>create</goal>
<goal>create-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>${project.encoding}</encoding>
<source>${project.source.version}</source>
<target>${project.target.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version> <!-- Keep in sync with pluginsManagement -->
<inherited>false</inherited> <!-- Run only for this level project -->
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal> <!-- Create buildNumber -->
<goal>create-metadata</goal> <!-- Create build.properties -->
</goals>
</execution>
</executions>
<configuration>
<!--
Auto update incremental integer as build number.
Without this it uses git revision.
-->
<format>{0,number,integer}</format>
<items>
<item>buildNumber</item>
</items>
<!-- Store buildNumber in given file. Use product.version so it resets each time version changes -->
<buildNumberPropertiesFileLocation>${basedir}/buildinfo/buildNumber-${product.version.base}-${product.version.status}.properties</buildNumberPropertiesFileLocation>
<!-- WORKAROUND: Make ${buildNumber} available to child modules -->
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
</configuration>
</plugin>
<plugin> <!-- Help identify buildNumber -->
<artifactId>maven-antrun-plugin</artifactId>
<inherited>false</inherited> <!-- Run only for this level project -->
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build Number (buildNumber) is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- This plugin allows us to add "src-gen" as another source dir -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build.helper.maven.plugin.version}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>src-gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng-unit.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
... snip ....
Here is Model/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>
<parent>
<groupId>com.magnicomp</groupId>
<artifactId>Product</artifactId>
<version>1.0</version>
</parent>
<artifactId>Model</artifactId>
<packaging>jar</packaging>
<build>
<resources> <!-- XXX ARE WE GOING TO USE THIS? -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>version.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<!-- Override eclipse error about "create-metadata" goal from above plugin -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>filter-sources</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.4,)</versionRange>
<goals>
<goal>create</goal>
<goal>create-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.3,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin> <!-- Aid with making sure buildNumber is available -->
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo-buildnumber-1</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build number during validate is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
<execution>
<id>echo-buildnumber-2</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build number during generate-sources is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <!-- Must be after buildnumber-maven-plugin due to ${buildNumber} -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<executions>
<!-- Take files in sourceDirectory and filter them to outputDirectory -->
<execution>
<id>filter-src</id>
<phase>generate-sources</phase>
<goals>
<goal>filter-sources</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}/src/main/java-templates</sourceDirectory>
<outputDirectory>${basedir}/src-generated</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- Copy the build.properties created by buildnumber-maven-plugin -->
<id>copy-build-properties</id>
<phase>validate</phase>
<goals> <goal>copy-resources</goal> </goals>
<configuration>
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/target/generated/build-metadata</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
... snip ...
Its been a while, but I got this work with the create-timestamp goal with the timestampFormat and timestampPropertyName configuration properties, and the by adding the runOnConfiguration true on the Eclipse m2e lifecycle mapping.
Build number plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<revisionOnScmFailure>just.say.no.scm.config.in.pom</revisionOnScmFailure>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampFormat>yyyyMMddHHmmssS</timestampFormat>
<timestampPropertyName>myBuildNumberVariable</timestampPropertyName>
<!-- formats the timestamp all together like 20160404141705123 and puts
it in the ${myBuildNumberVariable} buildProperty -->
</configuration>
</execution>
</executions>
</plugin>

Build RPM or Deb or Both file through maven build

I would like to create an OS package from a Maven project file according to the OS in question. The package may be RPM , Deb or something else. In the case of Deb packages, this could be done for example with the jdeb plugin.
We can use profile in pom.xml to creates one of file from deb or rpm .The profile structure are as follows:-
<profiles>
<profile>
<id>rpm</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<build>
<finalName>Finalname</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<version>1.0.0.M1B</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<descriptorRefs>
<descriptorRef>project</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/test/java</directory>
<!-- <excludes> <exclude>**/*Test.java</exclude> <exclude>**/*AllTests.java</exclude>
<exclude>**/*.java</exclude> </excludes> -->
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
<includes>
<include>**/*.java</include>
</includes>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<printSummary>true</printSummary>
<useFile>true</useFile>
<forkMode>pertest</forkMode>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>
org.springframework.batch.core.launch.support.CommandLineJobRunner
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<phase>package</phase>
<id>package-development</id>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<copyright>No body</copyright>
<group>Development</group>
<description>MavenRecipe:RPMPackage.</description>
<mappings>
<mapping>
<directory>/opt/tomcat/webapps/${project.build.finalName}</directory>
<sources>
<source>
<location>target/${project.build.finalName}</location>
</source>
</sources>
</mapping>
</mappings>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deb</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<build>
<finalName>FinalName</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<version>1.0.0.M1B</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<descriptorRefs>
<descriptorRef>project</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>deb</id>
<phase>install</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<verbose>true</verbose>
<deb>target/${project.build.finalName}${project.version}.deb</deb>
<controlDir>/home/dbobra/Workspace/project-workspace/projectname/src/deb/control</controlDir>
<dataSet>
<data>
<src>${project.build.directory}/${project.build.finalName}</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>/home/dbobra/installed/tomcat/webapps/${project.build.finalName}</prefix>
</mapper>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
If you need to create both file you have build with this command
mvn clean install -e
If you need to create deb file only then you use command
mvn clean install -P '!rpm' -e
If you need to create rpm file only then you use command
mvn clean install -P '!deb' -e
Hope this stuff works on your problems.

C:\Users\defaultu\.m2\repository\...plugins\maven-resources-plugin\2.5\maven-resources-plugin-2.5.pom. (The system cannot find the path specified)

I converted my web project into maven using eclipse. I am getting following error in my pom.xml at line number one
C:\Users\defaultu.m2\repository\org\apache\maven\plugins\maven-resources-plugin\2.5\maven-resources-plugin-2.5.pom. (The system cannot find the path specified)
My 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AppName</groupId>
<artifactId>FRC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<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>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<versionRange>[3.0,)</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
did u set Maven environment variables?
In command line mvn -version worked?

Maven filtered file in jar is out of date

I have a strange problem with maven. I am using the filtering option to put some version information into a properties file. I then include that in the jar file, so that "Help/About" can tell me something useful. The problem I am having is that the version in the jar file is the previous version. So, if, for example I run a build at 0930, and another at 0940, then the version of the properties file in the jar generated at 0940 will have a build time of 0930. I am using the buildNumber plugin as well, but this issue is present whether or not I enable it.
What is even stranger is that when I run my build from within eclipse and run the program, the "old" file shows up on help/about, but then when I "Refresh" (F5) the eclipse project and re-run the program, I get the correct version. So could it be that maven is taking the eclipse version somehow? And why do you need to "refresh" in eclipse to get it to have the most up to date version.
Anyway, my pom.xml is
<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>
<scm>
<url>scm:git:https://github.com/gregryork/DayOneViewer</url>
<developerConnection>scm:git:https://github.com/gregryork/DayOneViewer</developerConnection>
<tag>master</tag>
</scm>
<groupId>uk.co.gregreynolds</groupId>
<artifactId>dayone</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dayone</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.template.file>src/main/resources/uk/co/gregreynolds/dayone/Version.properties.template</version.template.file>
<version.file>src/main/resources/uk/co/gregreynolds/dayone/Version.properties</version.file>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>true</revisionOnScmFailure>
<format>{0,date,yyyy-MM-dd_HH-mm}_{1}</format>
<items>
<item>timestamp</item>
<item>${user.name}</item>
</items>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>uk.co.gregreynolds.dayone.DayOneViewer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${version.template.file}</file>
<outputFile>${version.file}</outputFile>
<replacements>
<replacement>
<token>#buildnumber#</token>
<value>${buildNumber}</value>
</replacement>
<replacement>
<token>#buildtime#</token>
<value>${maven.build.timestamp}</value>
</replacement>
<replacement>
<token>#pomversion#</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
<!--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>
com.google.code.maven-replacer-plugin
</groupId>
<artifactId>
maven-replacer-plugin
</artifactId>
<versionRange>
[1.4.0,)
</versionRange>
<goals>
<goal>replace</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<distributionManagement>
<site>
<id>langurmonkey.no-ip.org</id>
<url>scp://langurmonkey.no-ip.org/var/www/dayone/</url>
</site>
</distributionManagement>
</project>
The first thing is to activate the filtering of your resources like this:
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
This will activate the filtering for all files which are in the folder (and subfolders) of src/main/resources. Sometimes you need the filtering only for a limited number of files. In such sutuations just put those files into a subfolder and change the above configuration appropriately.
Next is to define a property file (in src/main/resources folder) which contains all information you need like this:
version=${project.version}
buildNumber=${buildNumber}
buildTime=${maven.build.timestamp}
Furthermore do the configuration for the buildnumber-maven-plugin like this:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
<format>{0,date,yyyy-MM-dd_HH-mm}_{1}</format>
<items>
<item>timestamp</item>
<item>${user.name}</item>
</items>
</configuration>
</plugin>
After that you can simple remove the usuage of the maven-replacer-plugin which you don't need in such simple scenarios.