Build RPM or Deb or Both file through maven build - plugins

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.

Related

Eclipse RCP plugin code coverage with Jacoco and Tycho surefire

I have an Eclipse RCP application that is built via Maven using Tycho. It has some tests that are located in plugin fragments, so each plugin with operational code has its own fragment with the tests inside. The tests are executed during the maven build using Tycho Surefire. I want to measure the code coverage so I included the Sonarqube plugin which then uses Jacoco to collect the coverage data. This is where the problem is: The code coverage is recorded, but only for the test fragments. The plugins with the code under test are reported as having 0% code coverage. I suspect the issue is that Jacoco does not instrument the plugins that don't contain the tests, but I couldn't find any documentation on how to force instrumentation of code.
This is the parent pom with the relevant Sonarqube/Jacoco configuration:
<?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>my-project</groupId>
<artifactId>my-project-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<tycho-version>1.4.0</tycho-version>
<tycho-eclipserun-version>${tycho-version}</tycho-eclipserun-version>
<maven-surefire-plugin-version>2.22.2</maven-surefire-plugin-version>
<maven-compiler-plugin-version>3.8.1</maven-compiler-plugin-version>
<maven-clean-plugin-version>2.6.1</maven-clean-plugin-version>
<maven-dependency-plugin-version>2.10</maven-dependency-plugin-version>
<maven-resources-plugin-version>2.7</maven-resources-plugin-version>
<m2e-lifecycle-mapping-plugin-version>1.0.0</m2e-lifecycle-mapping-plugin-version>
<junit-version>4.12</junit-version>
<maven-checkstyle-plugin-version>3.1.0</maven-checkstyle-plugin-version>
<spotbugs-maven-plugin-version>3.1.12</spotbugs-maven-plugin-version>
<jacoco-maven-plugin-version>0.8.4</jacoco-maven-plugin-version>
<findbugs-maven-plugin-version>3.0.5</findbugs-maven-plugin-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
<configuration>
<stagingProfileId>${stagingProfileId}</stagingProfileId>
<serverId>${project.staging.repository.id}</serverId>
<nexusUrl>${project.staging.repository.url}</nexusUrl>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
<target>
<artifact>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<classifier>${root-path}/dev/org.my-project/targetPlatforms/my-project</classifier>
</artifact>
</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin-version}</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<version>${tycho-eclipserun-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>${m2e-lifecycle-mapping-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${maven-project-info-reports-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin-version}</version>
<configuration>
<configLocation>${project.basedir}/${root-path}/dev/templates/checkstyle/Project Checkstyle Set v1.0.xml</configLocation>
<propertyExpansion>samedir=${project.basedir}/${root-path}/dev/templates/checkstyle</propertyExpansion>
<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>
<omitIgnoredModules>true</omitIgnoredModules>
<encoding>UTF-8</encoding>
<consoleOutput>false</consoleOutput>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
<outputFileFormat>xml</outputFileFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin-version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>sonarqube-analysis</id>
<properties>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.java.checkstyle.reportPaths>${project.build.directory}/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
<sonar.java.spotbugs.reportPaths>${project.build.directory}/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<generatedSiteDirectory>false</generatedSiteDirectory>
<generateProjectInfo>false</generateProjectInfo>
<generateReports>true</generateReports>
<generateSitemap>false</generateSitemap>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<argLine>${tycho.testArgLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<includes>my.project.base.package.*</includes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<configuration></configuration>
<reportSets>
<reportSet>
<reports></reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<reportSets>
<reportSet>
<id>checkstyle-report</id>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<reportSets>
<reportSet>
<id>spotbugs-report</id>
<reports>
<report>spotbugs</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<id>jacoco-report</id>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>
I tried adding the base package for instrumentation in the jacoco plugin configuration...
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<includes>my.base.package.*</includes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
...but Sonarqube still reports 0% coverage. As I said, there doesn't seem to be any documentation anywhere on how to configure this. Does someone know how to make this work?

Maven cucumber reporting from eclipse not generating the reports as per this plugin

Trying to generate the reports as per the maven cucumber reporting
Link to maven cucumber reporting
Made the necessary changes in the pom.xml file as explained here tutorial on configuring reports
But the reports are getting generated in the simple html file but not as per the cucumber reports.
pom.xml
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.${java.version}</source>
<target>1.${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<!-- <testFailureIgnore>true</testFailureIgnore> -->
<includes>
<exclude>**/*RunCukesTest.java</exclude>
<!-- <include>**/*RunCukesTest.java</include> -->
</includes>
<!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
</configuration>
</plugin>
<!-- This is for Cucumber Custom Report plug in we specify the configuration
details under configuration tag. -->
<!-- http://startingwithseleniumwebdriver.blogspot.com/2016/05/custom-cucumber-reporting-using-maven.html -->
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.11.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>CucumberReport</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<!-- <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput> -->
<jsonFiles>
<param>${project.build.directory}/cucumber.json</param>
</jsonFiles>
<!-- <parallelTesting>false</parallelTesting> -->
<buildNumber>1</buildNumber>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
RunCukesTest.java
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:features"},
plugin = {"html:target/site/cucumber-pretty","json:target/cucumber.json"},
tags = {"#currentTest"},
glue={"helpers","stepDefinitions"},
monochrome = true
)
public class RunCukesTest{
}
Reports are generated like this
which are different from expected
POM.XML::
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<include>**/TestRunner.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>4.5.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- <projectName>imademethink_cucumber_advanced_reporting</projectName> -->
<outputDirectory>${project.build.directory}/site/cucumber-reports-advanced</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber/cucumber.json</cucumberOutput>
<skippedFails>true</skippedFails>
<enableFlashCharts>false</enableFlashCharts>
<!-- <buildNumber>885</buildNumber> -->
<buildNumber>8.4.1.2</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
all configuration was good,
made two changes.
removed pluginManagement tag in pom
Used cucumberOutput output directory instead of jsonFiles. For some reason jsonFiles was generating duplicate reports.
pom file,
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.${java.version}</source>
<target>1.${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<exclude>**/*RunCukesTest.java</exclude>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.13.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Simplify360 Automation Test Report</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<buildNumber>8.4.1.2</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You need to set flag as below
<checkBuildResult>true</checkBuildResult>
Find my answer in below question URL
Reports are not generated when the build is failed in Maven Cucumber Reports
Just make 2 changes, and there you go
remove the tag from pom.xml file.
provide the version explicitly for the maven-surefire-plugin.
ex:version: 2.22.1

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>

Can the yui compressor maven plugin work with WTP?

I am using Eclipse Indigo with M2E to deploy a local web app using WTP. I am also using the yui-compressor plugin, which seems to work fine on the exploded war directory under target, but doesn't work with eclipse WTP. Is there a recommended way to set this up so I can develop locally and use the minified files?
Here is my yui config:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
<force>true</force>
<jswarn>false</jswarn>
<linebreakpos>-1</linebreakpos>
<excludes>
<exclude>**/lib/*</exclude>
</excludes>
<aggregations>
<aggregation>
<insertNewLine>true</insertNewLine>
<output>${project.build.directory}/${project.build.finalName}/static/js/script-${timestamp}.min.js</output>
<includes>
<include>**/script/*.js</include>
</includes>
<excludes>
<exclude>**/lib/*</exclude>
</excludes>
</aggregation>
</aggregations>
</configuration>
</plugin>
<pluginManagement>
<plugins>
<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.2,)</versionRange>
<goals>
<goal>compress</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The problem, I think, is that you are not telling to maven-war-plugin where to find generated resources.
You should try to add webResources section to the maven-war-plugin configuration, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/webapp</directory>
<excludes>
<exclude>**/pattern-for-non-minified-scripts</exclude>
</excludes>
</resource>
<resource>
<filtering>true</filtering>
<directory>${project.build.directory}/${project.build.finalName}</directory>
<includes>
<include>static/js/script-${timestamp}.min.js</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
To see that WTP has picked up the minified files, check .settings/org.eclipse.wst.common.component file has the following line:
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
Did you try <runOnIncremental>true</runOnIncremental>?
<pluginManagement>
<plugins>
<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.3.0,)</versionRange>
<goals>
<goal>compress</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
To have M2E output the files into the /src/ directory rather than the /target/ directory, I use the following:
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>${project.basedir}/src/main/webapp/resources/js</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/webapp/resources/js-min</outputDirectory>
</configuration>
</plugin>
</plugins>
In my HTML I then reference the JavaScript file(s) in [...]/resources/js-min/.

gwt maven war plugin configuration problem

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>