as always, excuse me if I make a silly query or one that is easily resolved. In a project I'm working on I was asked to find out if it's possible to build two wars from one webapp. This I could solve in the following way:
WebProject
<artifactId>FacturaElectronica</artifactId>
<packaging>war</packaging>
<name>factElectronica - web</name>
<description>This is the web POM file</description>
<groupId>factElectronica-web</groupId>
<version>1.0-SNAPSHOT</version>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>facturaelectronicafija</id>
<phase>install</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.santuario.xmlsec,org.apache.commons.codec,javax.ws.rs.api</Dependencies>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>facturaelectronicamovil</id>
<phase>install</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**</include>
</includes>
</resource>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.santuario.xmlsec,org.apache.commons.codec,javax.ws.rs.api</Dependencies>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java/resources</directory>
</resource>
</resources>
</build>
Each of these war has the same classes but differs in the xhtml files. One points to mobile phone components and the other points to landline phone components.
After doing this, I realized that it was necessary to build an ear for each one of them, each one with its root context and perform the deploy in wildfly. But I can't find the way to do it. On the one hand I don't know how to point to the wars that are built in the execution in the webapp, and on the other hand I don't know if the way is only with one ear for both or it is necessary to build two. I would be very grateful if someone could give me a hand with this. Thank you very much!
Update
Taking the example I found in this link: Maven ear plugin multiple artifacts content
I made the following changes:
WebProject
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicafija</webappDirectory>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicamovil</webappDirectory>
<webResources>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<finalName>FacturaElectronica</finalName>
</build>
</project>
EarProject
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>factElectronicaWeb-ear</groupId>
<artifactId>factElectronicaWeb-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>facturaelectronicafija</classifier>
<scope>provided</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicafija</workDirectory>
<classifier>facturaelectronicafija</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica.war</bundleFileName>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicamovil</workDirectory>
<classifier>facturaelectronicamovil</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica.war</bundleFileName>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>FacturaElectronica</finalName>
</build>
</project>
Now the executions are done and maven creates three ears, the first one, which is called "FacturaElectronica" I created it to test that it actually works. The problem is that the three ears have exactly the same content as "FacturaElectronica". I think it is because maven does not find the dependence towards "facturaelectronicafija" and "facturaelectronicafija". Maybe because when I create these WARs in executions I can't add a version to them. Somebody could clarify me this please? Thank you very much!
I would create a multi-module project where each WAR and each EAR are separate modules.
The classes would be a JAR module that is used in the two WAR modules
I had to make some corrections, but I managed to leave it working as expected.
WebProject
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicafija</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicafija</webappDirectory>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<classifier>facturaelectronicamovil</classifier>
<webappDirectory>${project.build.directory}/${project.build.finalName}-facturaelectronicamovil</webappDirectory>
<webResources>
<resource>
<directory>src/main/webappFant</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<finalName>FacturaElectronica</finalName>
</build>
The default install run is there so that the default war base is not created.
EarProject
<modelVersion>4.0.0</modelVersion>
<groupId>factElectronicaWeb-ear</groupId>
<artifactId>factElectronicaWeb-ear</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>facturaelectronicafija</classifier>
<scope>compile</scope>
<type>war</type>
</dependency>
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>default-ear</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
<execution>
<id>package-facturaelectronicafija</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicafija</workDirectory>
<classifier>facturaelectronicafija</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<contextRoot>/FacturaElectronica</contextRoot>
<bundleFileName>/FacturaElectronica-facturaelectronicafija.war</bundleFileName>
</webModule>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<excluded>true</excluded>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
<execution>
<id>package-facturaelectronicamovil</id>
<phase>package</phase>
<configuration>
<workDirectory>target/facturaelectronicamovil</workDirectory>
<classifier>facturaelectronicamovil</classifier>
<version>8</version>
<modules>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<contextRoot>/DetalleFactura</contextRoot>
<bundleFileName>/FacturaElectronica-facturaelectronicamovil.war</bundleFileName>
</webModule>
<webModule>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicafija</classifier>
<excluded>true</excluded>
</webModule>
</modules>
</configuration>
<goals>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>FacturaElectronica</finalName>
</build>
Previously the dependencies generated only a meta inf file, this was because they were with a scope provided, when you switch to compile it works correctly.
<dependency>
<groupId>factElectronica-web</groupId>
<artifactId>FacturaElectronica</artifactId>
<classifier>facturaelectronicamovil</classifier>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
<type>war</type>
</dependency>
Related
Project build error: Non-resolvable parent POM for org.kurento.tutorial:kurento-group-call:6.5.0: Failure to find
org.kurento.tutorial:kurento-tutorial:pom:6.5.0 in https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and
'parent.relativePath' points at wrong local POM
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent> .........................................showing the error in parent
<groupId>org.kurento.tutorial</groupId>
<artifactId>kurento-tutorial</artifactId>
<version>6.5.0</version>
</parent>
<artifactId>kurento-group-call</artifactId>
<packaging>jar</packaging>
<name>Kurento Java Tutorial - Group Call</name>
<description>WebRTC many to many video call</description>
<url>http://www.kurento.org/docs/${project.version}</url>
<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<organization>
<name>Kurento</name>
<url>http://www.kurento.org</url>
</organization>
<scm>
<url>https://github.com/Kurento/kurento-tutorial-java</url>
<connection>scm:git:https://github.com/Kurento/kurento-tutorial-java</connection>
<developerConnection>scm:git://git#github.com:Kurento/kurento-tutorial-java</developerConnection>
<tag>develop</tag>
</scm>
<developers>
<developer>
<id>kurento.org</id>
<name>-kurento.org Community</name>
<organization>Kurento.org</organization>
<organizationUrl>http://www.kurento.org</organizationUrl>
</developer>
</developers>
<properties>
<demo.port>8086</demo.port>
<!-- Main class -->
<start-class>org.kurento.tutorial.groupcall.GroupCallApp</start-class>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.3.0.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- Kurento -->
<dependency>
<groupId>org.kurento</groupId>
<artifactId>kurento-client</artifactId>
<version>6.5.0</version>
</dependency>
<dependency>
<groupId>org.kurento</groupId>
<artifactId>kurento-utils-js</artifactId>
<version>6.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-bower-install</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bower</executable>
<workingDirectory>${project.build.directory}/classes</workingDirectory>
<arguments>
<argument>install</argument>
<argument>--allow-root</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/resources/static/bower_components</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.kurento.tutorial</groupId>
<artifactId>kurentu-group-call</artifactId>
<version>6.5.0</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>banner.txt</include>
</includes>
</resource>
<resource>
<directory>.</directory>
<filtering>true</filtering>
<includes>
<include>bower.json</include>
</includes>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/assembly/bin.xml</descriptor>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy
file="${project.build.directory}/target/${project.artifactId}-${project.version}-bin.zip"
tofile="${project.build.directory}/target/${project.artifactId}-${project.version}.zip" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>no-assembly</id>
</profile>
</profiles>
This means that the parent POM org.kurento.tutorial:kurento-tutorial:pom:6.5.0 cannot be found in the configured repositories.
Looking at https://mvnrepository.com/artifact/org.kurento.tutorial/kurento-group-call, you can see that the version, 6.5.0 that you are trying to download is not available. To fix this problem, navigate to https://mvnrepository.com/artifact/org.kurento.tutorial/kurento-group-call and look at the available repository versions and use. You can use it by changing 6.5.0 in the pom.xml file with an available version like 6.11.0
I am trying to get sonar report for one of my project.
I have run mvn clean install
Running blah.blah.BlahTest1
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running blah.blah.BlahTest2
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec
When I run mvn sonar:sonar I get the bellow error.
[INFO] ------------------------------------------------------------------------
[INFO] Building Component name
[INFO] task-segment: [org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test]
[INFO] ------------------------------------------------------------------------
[INFO] [surefire:test {execution: default-cli}]
[INFO] Surefire report directory: D:\CodeBase\Project\module\target\surefire-reports
java.lang.NoClassDefFoundError: null
Caused by: java.lang.ClassNotFoundException: null
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: null. Program will exit.
Exception in thread "main"
[ERROR] There are test failures.
I am not sure where to start looking to. I tried searching in google couldn't find anything similar to my issue.
Please help me in understanding which can be a possible cause to look for.
Thanks.
Adding pom file : Removed few details to shorten the 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>
<!--============================================================= -->
<!--The Basics -->
<!--============================================================= -->
<groupId>###</groupId>
<artifactId>###</artifactId>
<packaging>pom</packaging>
<version>###</version>
<url>###</url>
<!--============================================================= -->
<!--Project Information -->
<!--============================================================= -->
<!--============================================================= -->
<!--Properties -->
<!--============================================================= -->
<properties>
<!--general properties -->
<svn-base-url>###</svn-base-url>
<!--versions of 3rd party libraries -->
<!--plug in versions -->
<version.jacoco.plugin>0.7.4.201502262128</version.jacoco.plugin>
</properties>
<scm>
</scm>
<!--============================================================= -->
<!--Modules -->
<!--============================================================= -->
<modules>
</modules>
<!--============================================================= -->
<!--Distribution Management -->
<!--============================================================= -->
<distributionManagement>
</distributionManagement>
<!--============================================================= -->
<!--Plugin Repository -->
<!--============================================================= -->
<pluginRepositories>
</pluginRepositories>
<!--============================================================= -->
<!--Dependency Management -->
<!--============================================================= -->
<dependencyManagement>
<!--3rd part libraries -->
</dependencyManagement>
<!--============================================================= -->
<!--Dependencies -->
<!--============================================================= -->
<dependencies>
</dependencies>
<!--============================================================= -->
<!--Build Information -->
<!--============================================================= -->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${version.clean.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<compilerArgument>-Xlint:-serial -Xmaxwarns 9999 -Xmaxerrs 9999</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco.plugin}</version>
<configuration>
<append>true</append>
<destFile>target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>target/coverage-reports/jacoco-unit.exec</dataFile>
<includes>
<include>path</include>
</includes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${version.enforcer.plugin}</version>
<configuration>
<rules>
<requireJavaVersion>
<version>1.6</version>
</requireJavaVersion>
<requireMavenVersion>
<version>2.2.0</version>
</requireMavenVersion>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${version.versions.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
<configuration>
<descriptors>
<!-- descriptors -->
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${version.release.plugin}</version>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.resources.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${version.install.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${version.site.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${version.jxr.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${version.cobertura.plugin}</version>
<configuration>
<formats>
<format>xml</format>
</formats>
<instrumentation>
<!--Include and exclude -->
</instrumentation>
<maxmem>512M</maxmem>
</configuration>
<executions>
<execution>
<id>clean</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${version.pmd.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${version.findbugs.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${version.checkstyle.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
<version>${version.dashboard.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.buildhelper.plugin}</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${version.jaxb2.plugin}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>${version.taglist.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>${version.changelog.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.2</version>
<configuration>
<connectionType>developerConnection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.jar.plugin}</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec-maven.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${version.antrun.plugin}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>remove-project-artifact</id>
<phase>clean</phase>
<goals>
<goal>remove-project-artifact</goal>
</goals>
<configuration>
<removeAll>false</removeAll>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<!-- Need the argLine in the configuration here otherwise jacoco hook into surefire correctly for unit test coverage -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>${argLine} -XX:MaxPermSize=256M -Xmx892M -client</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm not a Maven expert, though but, I have implementation wherein, during the maven lifecycle, I execute some of the JUnits to find the Code Coverage and Sonar, of course. I'm attaching my pom. Maybe this helps.
<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>
<!-- Project Parent POM -->
<parent>
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
<version>2.0</version>
</parent>
<!-- Artifacts for the WAR -->
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<name>XXX</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.3.201107060350</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
...
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<destFile>${sonar.jacoco.itReportPath}</destFile>
</configuration>
<executions>
<execution>
<id>pre-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<argLine>
${argLine} -DAdditional Arguments
</argLine>
<includes>
<include>**/TestSuite.java</include>
</includes>
<skipTests>false</skipTests>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--Dependencies -->
</dependencies>
<!-- Properties of the dependencies defined above -->
<properties>
<!-- Versions -->
<!-- Sonar Properties -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.itReportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
</properties>
This is a project that uses both TestNG and JUnit4. I am not able to run the TestNG test suite for any reason. The error stack trace is given below.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Exception in thread "ThreadedStreamConsumer" java.lang.NoSuchMethodError: org.ap
ache.maven.surefire.report.StackTraceWriter.getThrowable()Ljava/lang/Throwable;
at org.apache.maven.surefire.report.XMLReporter.writeTestProblems(XMLRep
orter.java:272)
at org.apache.maven.surefire.report.XMLReporter.testFailed(XMLReporter.j
ava:249)
at org.apache.maven.surefire.report.MulticastingReporter.testFailed(Mult
icastingReporter.java:80)
at org.apache.maven.surefire.report.TestSetRunListener.testFailed(TestSe
tRunListener.java:157)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consu
meLine(ForkClient.java:106)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamCo
nsumer$Pumper.run(ThreadedStreamConsumer.java:67)
at java.lang.Thread.run(Thread.java:722)
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
My pom set up is given below
<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>
<prerequisites>
<maven>3.0.4</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.version>2.13</surefire.version>
</properties>
<parent>
<groupId>com.google</groupId>
<artifactId>google</artifactId>
<version>1</version>
</parent>
<groupId>com.google.testing</groupId>
<artifactId>test-libraries-for-java</artifactId>
<version>1.2</version>
<profiles>
<profile>
<id>junit4-only</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>junit4-only-${project.version}</classifier>
<includes>
<include>**/junit4/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>agnostic</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>agnostic-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>junit4</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>junit4-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
<include>**/junit4/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>testng</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>testng-${project.version}</classifier>
<includes>
<include>**/common/testing/*.class</include>
<include>**/testng/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>testng-only</id>
<build>
<finalName>tl4j</finalName>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>testng-${project.version}</classifier>
<includes>
<include>**/testng/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<build>
<!-- <finalName>tl4j</finalName> -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<outputDirectory>${basedir}/target-eclipse/classes</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<configuration>
<tasks>
<echo
message="Please follow directions at doc/HOW_TO_RELEASE.txt to make the release" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</reporting>
My unit test
import org.testng.Assert;
import org.testng.annotations.Test;
public class TearDownTestCaseTest {
#Test
public void assertTrue() {
Assert.assertTrue(true);
}
}
Funny thing is that if I configure this test to run as JUnit 3 test case, it works, but not JUnit 4.x or Testng.
I am new to GWT. I tried to make a web application and uses the following maven config to config gwt. I put it in a profile so only when the profile is invoked will the gwt being compiled.
The profile is like:
<profiles>
<profile>
<id>gwtCompile</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k </extraJvmArgs>
<module>com.mycompany.MyMainModule</module>
<inplace>true</inplace>
<force>true</force>
<disableCastChecking>true</disableCastChecking>
<style>PRETTY</style>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>compileJS</id>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
When I run the command:
mvn clean install -Dmaven.test.skip=true -PgwtCompile
it gave me error message:
GWT Module com.mycompany.MyMainModule not found in project sources or resources.
My MyMainModule.gwt.xml is like this:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name='com.google.gwt.user.User' />
<entry-point class='com.mycompany.MyMainModule' />
<source path='client' />
<source path='shared' />
</module>
I can see some online documents said multiple module project is supposed to have this error. But mime is not a multi-module project.
Can someone let me know what possibly went wrong with this?
Many thanks.
EDIT:
I have got this in place:
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/client/**</include>
<include>**/*.gwt.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
Try adding resources tag in your build tag.
<build>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<!-- **Other build tags** -->
</build>
I found the solution to this. The problem was that the module specified in the gwt-maven-plugin has to be the exact path name of the .gwt.xml file, not the entry point file.
So the configuration file has to be:
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k </extraJvmArgs>
<module>com.mycompany.myoroject.MyMainModule</module>
<inplace>true</inplace>
<force>true</force>
<disableCastChecking>true</disableCastChecking>
<style>PRETTY</style>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
</configuration>
becasue my MyMainModule.gwt.xml is under src/main/com/mycompany/myproject/MyMainModule.gwt.xml.
Many thanks for your answers.
Important config vars are outputDirectory and webappDirectory. See 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>com.gwt</groupId>
<artifactId>gwt-ui-sandbox</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>GWT UI Sandbox</name>
<properties>
<license.licenseName>apache_v2</license.licenseName>
<license.inceptionYear>2012</license.inceptionYear>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<default.encoding>UTF-8</default.encoding>
<project.build.sourceEncoding>${default.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${default.encoding}</project.reporting.outputEncoding>
<maven.compiler.plugin.encoding>${default.encoding}</maven.compiler.plugin.encoding>
<gwt.version>2.5.0</gwt.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.css</exclude>
<exclude>**/Messages.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>first</id>
<goals>
<goal>update-file-header</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.9.v20130131</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
<configuration>
<daemon>true</daemon>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<systemProperties>
<systemProperty>
<name>some.prop</name>
<value>false</value>
</systemProperty>
</systemProperties>
<stopKey>stop</stopKey>
<stopPort>8079</stopPort>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>css</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
<!-- package source files with .class files: -->
<!-- (this is not good for dev mode incremental parsing) -->
<!-- <goal>resources</goal> -->
</goals>
</execution>
</executions>
<configuration>
<runTarget>index.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<compileReport>false</compileReport>
<style>PRETTY</style>
<draftCompile>true</draftCompile>
<logLevel>INFO</logLevel>
<mode>manual</mode>
<productionMode>true</productionMode>
<remoteweb>rmi://127.0.0.1/chromium</remoteweb>
<browser>/usr/bin/chromium-browser</browser>
<timeOut>${gwt.timeout}</timeOut>
<i18nMessagesBundles>
<!-- need to compile only one language in order to make the compiler happy... -->
<!-- My guess: GWT seems to directly use the properties files when using translations from sub-modules -->
<i18nMessagesBundle>com.gwt.uisandbox.Messages</i18nMessagesBundle>
</i18nMessagesBundles>
<cssFiles>
<cssFile>com/gwt/uisandbox/Style.css</cssFile>
</cssFiles>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<!-- http://code.google.com/p/google-web-toolkit/issues/detail?id=4599 -->
<replace dir="${basedir}">
<include name="target/generated-sources/gwt/com/gwt/uisandbox/Style.java"/>
<replacetoken>interface Style extends CssResource {</replacetoken>
<replacevalue>public interface Style extends CssResource {</replacevalue>
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- http://maven.apache.org/plugins/maven-enforcer-plugin/plugin-info.html -->
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-sane-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requirePluginVersions />
<DependencyConvergence />
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.2</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<!-- netbeans needs provided scope to find gwt sources (when debuggung) -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
(See here)
BTW: you should only put java files into the end result (like the other response suggests) when building a module that gets included in another, final, compiled UI module. Otherwise, it breaks the incremental java-parsing mechanism of gwt:run.
I'm new to JavaFX and I'm trying to build my first application, using Maven. Well, since I don't really like to mix ant with maven, I got an alternative solution, using exec-maven-plugin and javafxpackager, found here: http://www.oracle.com/technetwork/articles/java/enterprisefxpt3-1735081.html
Problem is, I don't like the way it unpacks all my dependencies inside the jar, so I modified it a "little", resulting on this:
<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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>2.2</javafx.version>
</properties>
<build>
<finalName>test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-appclass</argument>
<argument>test.HelloWorldApp</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}/dist</argument>
<argument>-outfile</argument>
<argument>${project.name}.jar</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<scope>system</scope>
<systemPath>${java.home}/lib/jfxrt.jar</systemPath>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Well, I think it really looks good, more than expected! Well, all but one "little" problem: I don't have the classpath entry on the Manifest.MF, so any dependencies added aren't found on runtime, and I have no clue how to add it. Any ideas?
Thanks all for the help!
EDIT: Maybe this can help, javafxpackager has an argument classpath that I can pass a list of dependencies. So what I need is the classpath, maybe as a String, just to add it to javafxpackager.
If you look at the exec-maven-plugin POM configuration you see that you can add a <classpath/> tag. I haven't tried it but it should do it.
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-appclass</argument>
<argument>test.HelloWorldApp</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}/dist</argument>
<argument>-outfile</argument>
<argument>${project.name}.jar</argument>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
</arguments>
</configuration>
check out this pom.xml for a personal javafx application
it does not use javafxpackager / javapackager, but is a perfect runnable jar. jar will be under target/${project.name}-${version}-jar-with-dependencies.jar
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/dependency</outputDirectory>
<resources>
<resource>
<directory>lib</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>application.WeatherFXApplication</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-apache-log4j</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
</dependencies>
also is possible to obtain the same thing with shade plugin
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>application.WeatherFXApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-apache-log4j</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
</dependencies>