Eclipse RCP plugin code coverage with Jacoco and Tycho surefire - eclipse-rcp

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?

Related

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

How to generate xml report with scoverage maven plugin?

I'm trying to generate scoverage xml report to use it in Jenkins. But all I can get is the folder scoverage-classes with my .scala files. Here is a part of my pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>${scalatest.plugin.version}</version>
<configuration>
<junitxml>surefire-reports</junitxml>
<stdout>W</stdout>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>report
</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Scalatest generates xml reports, but Scoverage does not. I've tried to run maven with different args like mvn scoverage:report, mvn scoverage:report site and so on. Nothing helps. What should I change in my pom to make it work?
It turned out that I have scala compiler plugin that is not supported by scoverage plugin. Also it looks like maven scala compiler plugin from org.scala-tools is outdated. Supported by scoverage plugins are:
net.alchim31.maven:scala-maven-plugin
com.google.code.sbt-compiler-maven-plugin:sbt-compiler-maven-plugin

pom configuration to force usage of jvm 7 with scala maven plugin

Because of an incompatibility between a scala 2.9.2 project and the java 8 version, i need to manually specify jvm usage in my maven project.
The pom.xml i make, using documentation here :
<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>org.netlogo.extension</groupId>
<packaging>jar</packaging>
<artifactId>rungekuta</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${lib.org.scala-lang.scala.version}</version>
</dependency>
<dependency>
<groupId>org.nlogo</groupId>
<artifactId>netlogo</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<lib.org.scala-lang.scala.version>2.9.3</lib.org.scala-lang.scala.version>
<maven.scala.version>${lib.org.scala-lang.scala.version}</maven.scala.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifestEntries>
<Extension-Name>rungekuta</Extension-Name>
<Class-Manager>org.netlogo.extension.rungeKuta.RungeKutaExtension</Class-Manager>
<NetLogo-Extension-API-Version>5.0</NetLogo-Extension-API-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>/home/reyman/Logiciels/jdk1.7.0_80/bin/javac</executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
</plugins>
</build>
<name>${project.artifactId} ${project.version}</name>
<repositories>
<repository>
<id>snapshots.scala-tools.org</id>
<name>Scala snapshots repository</name>
<url>http://scala-tools.org/repo-snapshots/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
</repositories>
</project>
I try this without success, maven continue to use my current jvm 8 and not the jvm given in maven-compiler-plugin : <executable>/home/reyman/Logiciels/jdk1.7.0_80/bin/javac</executable>
How can i force usage of the jvm 7 during mvn compile of my mixed scala/java sources project ?
This worked for me:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Use Something like this:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
modify it per your need.
Here is my complete Build , I don't know if it will help you.
I'm pasting it here because it's too long for comment:
<build>
<finalName>KAIBICHI</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
I had the same problem trying to use minify-maven-plugin 1.7 with java6. It needs Java7.
The problem is that Maven needs to run with the proper JVM to use the plugins, so the only solution I found was to export JAVA_HOME before running maven:
ORIGINAL_JAVA_HOME=$JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_79
mvn jetty:run
export JAVA_HOME=$ORIGINAL_JAVA_HOME
if you need to do this frequently maybe you can add to your bashrc an alias like
alias mvn7='ORIGINAL_JAVA_HOME=$JAVA_HOME; export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_79; mvn jetty:run; export JAVA_HOME=$ORIGINAL_JAVA_HOME'
This worked for me, but I had to allow Eclipse (Mars) to adjust plugin configuration. I tested my pom.xml with an empty project and it seems to build without incident.
I am using jenv to manage my Java environment outside of Eclipse which is much easier when you have many Java versions installed.
Here is the pom.xml I am using:
<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>org.netlogo.extension</groupId>
<packaging>jar</packaging>
<artifactId>rungekuta</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${lib.org.scala-lang.scala.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.nlogo</groupId>
<artifactId>netlogo</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
-->
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lib.org.scala-lang.scala.version>2.9.3</lib.org.scala-lang.scala.version>
<maven.scala.version>${lib.org.scala-lang.scala.version}</maven.scala.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</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>
net.alchim31.maven
</groupId>
<artifactId>
scala-maven-plugin
</artifactId>
<versionRange>
[3.2.1,)
</versionRange>
<goals>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifestEntries>
<Extension-Name>rungekuta</Extension-Name>
<Class-Manager>org.netlogo.extension.rungeKuta.RungeKutaExtension</Class-Manager>
<NetLogo-Extension-API-Version>5.0</NetLogo-Extension-API-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<name>${project.artifactId} ${project.version}</name>
<repositories>
<repository>
<id>snapshots.scala-tools.org</id>
<name>Scala snapshots repository</name>
<url>http://scala-tools.org/repo-snapshots/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
</repositories>
</project>

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.

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>