I need a solution to pack all lib-files into the executable jar-file.I use Maven and the Maven plugins javafx-maven-plugin, maven-compiler-plugin and maven-surefire-plugin. I haven't found a solution for my problem based on these plugins yet.
I hope someone can help me. Here are the configurations of the plugins.
<build>
<plugins>
<!-- https://github.com/javafx-maven-plugin/javafx-maven-plugin -->
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.4</version>
<configuration>
<mainClass>${exec.mainClass}</mainClass>
<verbose>true</verbose>
<jfxAppOutputDir>${project.basedir}/target/output</jfxAppOutputDir>
<jfxMainAppJarName>${project.name}.jar</jfxMainAppJarName>
<allPermissions>true</allPermissions>
<manifestAttributes>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Specification-Vendor>${project.organization.name}</Specification-Vendor>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${build.number}</Implementation-Version>
<Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
<Implementation-URL>${project.organization.url}</Implementation-URL>
</manifestAttributes>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>false</skipTests>
<properties>
<property>
<name>listener</name>
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
What you are looking for is called uber-jar or shaded jar. You can use the following maven-plugin:
Maven Shade Plugin
Selecting Contents for Uber JAR
Related
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.idexx</groupId>
<artifactId>qe-lynxx-automation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<serenity.version>2.0.27</serenity.version>
<lean.ft.version>14.50.0</lean.ft.version>
<test.directory>${project.build.testSourceDirectory}/tests</test.directory>
<tags></tags>
</properties>
<dependencies>
I have all the required dependencies but not including here.
I am unable to run test parallelly with forkCount or methods. It works fine would the sureFire plugin but I cannot use the surefire plugin to generate serenity reports.
I have tried a combination of forkCount and parallel that didn't work either.
I was able to fork multiple Java VMs using the sureFire.
I am trying to run test parallelly in multiple virtual machines. Our application is swing based java application and we are using LeanFt to automate the testing process.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<forkCount>2</forkCount>
<reuseForks>false</reuseForks>
<includes>
<!-- Run every java class in the 'tests' package -->
<include>${test.directory}/*.java</include>
</includes>
<systemPropertyVariables>
<tags>${tags}</tags>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I figured out how it actually works. All you have to do is add Surefire plugin with Failsafe plugin when you use both of them. It works like a charm.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<includes>
<!-- Run every java class in the 'tests' package -->
<include>${test.directory}/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<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>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>enter code here
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I try to build my java Project with the maven:site plugin.
For that I use a Jenkins Server and configure the mvn goals: clean install site
My Pom has the following Plugins:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.5</version>
<configuration>
<goal>generate-sources</goal>
<generateReports>true</generateReports>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<show>private</show>
</configuration>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
..
The Programm runs and the generated Classes are available. But if i made a site-build i get the error that the generated package doesn't exist.
Thank you for your help
I used this in pom where jaxb is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>target/generated-sources/jaxb/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
We have a multi-module maven project, which has to be deployed in Jboss 7.1.1 server. It takes most of our time redeploying for code changes. Have seen to use Jrebel for hot deployment, but the expense will not meet to us with 20 developers.
So is there any workaround for hot deployment of maven-multi-module project in Jboss?
Here is build configuration of our project in POM:
<build>
<pluginManagement>
<plugins>
<plugin>
<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>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.0.Beta1b</version>
<inherited>true</inherited>
<configuration>
<hostname>localhost</hostname>
<port>9999</port>
<filename>${project.build.finalName}.ear</filename>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
I am using Maven2 to build my project. I want my build to automatically download dependency source jars when it is compiled. Dependency executable jars are downloading correctly. My dependency looks like this:
...
<dependencies>
<dependency>
<groupId>id.name</groupId>
<artifactId>artifact-name</artifactId>
<version>1403.00</version>
</dependency>
</dependencies>
...
I do have the maven source plugin:
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
I've also tried adding this configuration to the pom under the maven-source-plugin:
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
What do I need to add to my pom file to make this happen?
Add this to your POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>download-sources</id>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
I would like use Maven for creating site for my application. This is a multi-module app, the parent module is simple site module, and first child is a core of app, the second is a GUI (Swing).
I now use follow for parent pom.xml
<modules>
<module>core</module>
<module>kayako-desktop</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.2</version>
<configuration>
<locales>en</locales>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-changes-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</reporting>
My core's pom:
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>package</phase>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<links>
<link>http://download.oracle.com/javase/6/docs/api/</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
(I stripped out unrelated parts from both)
The problem: I tried mvn site:stage, but javadoc is not collected from core module. What do I wrong?
Configure the javadoc plugin in the <reportPlugins> section of the configuration for the maven-site-plugin, in the parent pom.
Here's what worked for me.
In the parent pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<id>aggregate</id>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<!-- Here you can add special configurations for your javadoc, if needed -->
</configuration>
</plugin>
<!-- Here you can also configure more report plugins -->
<!-- for your site, such as maven-project-info-reports-plugin -->
</reportPlugins>
</configuration>
</plugin>
<!-- ... -->
</plugins>
</build>
<!-- ... -->
<distributionManagement>
<site>
<id>website</id>
<url>http://site.url/can/be/tentative/or/hypothetical</url>
</site>
</distributionManagement>
In each of the child poms, you can also configure specific reports for the site plugin, for example, surefire test reports or project info. However, you shouldn't need to place any javadoc plugin configurations there (unless you also want non-aggregated javadocs for your child modules).
You should then be able to do mvn site site:stage from the parent directory. To view your aggregated javadocs, point your browser to target/staging/index.html in that directory, and click "Project Reports" and then "JavaDocs" in the index on the left-hand side of the page.
Additional tip:
Sometimes I want to look quickly at the aggregated javadocs without having to do an entire site site:stage, which does more stuff and takes longer. So I also include a configuration for the maven-javadoc-plugin directly in the <plugin> section of the parent pom. That way, I can run mvn javadoc:aggregate and quickly get the aggregated javadocs in target/site/apidocs/index.html.