How to get Maven report in html format? - java

i have a maven project with eclipse with some selenium tests.
I can run them in command line and i got the report in my target folder in txt and xml format.
But i want the report in html format.
Whatt should i add in my POM file.
Thank you very much.
Here is my POM.xml
....
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.3</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

See this question, as the 2nd answer points out, you should be able to use the Maven Surefire Report plugin.
"The Surefire Report Plugin parses the generated TEST-*.xml files under ${basedir}/target/surefire-reports and renders them using DOXIA, which creates the web interface version of the test results."
Here is the XML to configure it:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18</version>
</plugin>
</plugins>
</reporting>
Either of the following commands will invoke it:
mvn site
mvn surefire-report:report

Related

junit jupiter run configuration

I'm learn java, and now i have a mistake: cannot find class 'org.junit.platform.commons.annotation.testable' on project build path
I don't understand what i'm doing wrong. in other projects junit work successful
My project explorer ProjectExplorer
I'm tryed to add junit in build path, change test runner to Junit4 and add other version of Junit in dependency, but it did not working to me.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<exec.version>3.0.0</exec.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<junit.version>5.7.0</junit.version>
<junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version>
<!-- some other things -->
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.version}</version>
</dependency> <!-- Test dependency -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform-surefire-provider.version}</version>
</dependency>
<!-- some other dependency -->
<!-- Logger dependency -->
<!-- Services dependency -->
</dependencies>
<build>
<sourceDirectory>/src/main/java </sourceDirectory>
<testSourceDirectory>/src/test/java </testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId> org.apache.maven.plugins </groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</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>${maven-surefire-plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<includes>
<include>**\testWindowLogin.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform-surefire-provider.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
so. i can say that i fix it.
first: my IDE -- Eclipse version 4.19; Maven version 3.6.3, java version 11.0.10
second. simple import project from git didn't work in. For fix I import to local repository and then did import to IDE as maven project.
thanks for help

java.lang.NoSuchMethodError when compiling jar

Good day to all!
I work with google vision API and when I run my program in the IntelliJ Idea, it works great, but when I compile a jar file, it gives an error when processing photos
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
at io.grpc.Metadata$Key.validateName(Metadata.java:629)
at io.grpc.Metadata$Key.<init>(Metadata.java:637)
at io.grpc.Metadata$Key.<init>(Metadata.java:567)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:742)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:737)
at io.grpc.Metadata$Key.of(Metadata.java:593)
at io.grpc.Metadata$Key.of(Metadata.java:589)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.<init>(GrpcHeaderInterceptor.java:60)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:212)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:185)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:177)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:160)
at com.google.cloud.vision.v1.stub.GrpcImageAnnotatorStub.create(GrpcImageAnnotatorStub.java:114)
at com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings.createStub(ImageAnnotatorStubSettings.java:151)
at com.google.cloud.vision.v1.ImageAnnotatorClient.<init>(ImageAnnotatorClient.java:136)
at com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:117)
at allClasses.GoogleAPI.detectText(GoogleAPI.java:26)
at allClasses.MainClass.addMarkingPhoto(MainClass.java:129)
at allClasses.MainClass.dir(MainClass.java:95)
at allClasses.MainClass.dir(MainClass.java:86)
at allClasses.MainClass.main(MainClass.java:50)
I read that this may be due to dependencies, but in maven I am new to and can not understand why it works in intellij and does not work when creating a jar file
My pom :
<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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<poi.version>3.15</poi.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v3-rev110-1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.2-jre</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.8</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.2</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.2.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>1.84.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
<groupId>org.example</groupId>
<artifactId>MyProject</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
I deleted the manifest and inserted this:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>allClasses.MainClass</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
but nothing has changed
What could be the problem?
Why code works in intellij and don't work after creating jar file?
I see that you refer to a precise MANIFEST file, it would be useful to know what is written inside it because, as I think you know, inside the MANIFEST file there are both startup class and the list of dependencies and their location.
The POM file does not explicitly construct a "jar-with-dependency", therefore I would assume that the package you have built does not contain the necessary dependencies to use it
As a result, you have two choices:
1) create an "all-in-one" package, that contains all the dependencies necessary for its use, via maven plugin, replacing your "maven-jar-plugin" with "maven-assembly-plugin":
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>{full qualified name of main class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
2) referencing the external dependencies via the parameter -Djava.library.path, -cp or similar
When you compile the jar file you would need to package the required dependency with jar file. You can try to explore following configuration. What it does is that it adds required dependency with jar itself and when you try to run the jar it finds all the dependency with jar itself. Here api-all is dependency which I would like to include with jar itself. Which has maven dependency
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<scope>provided</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>com.your.package</Bundle-SymbolicName>
<Export-Package>com.your.package.*;org.apache.commons.beanutils.*</Export-Package>
<Embed-Dependency>api-all,commons-pool,mina-core,antlr</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<DynamicImport-Package>
org.dom4j, org.dom4j.io, org.jdom, org.jdom.input
</DynamicImport-Package>
<Import-Package>
!org.dom4j.*, !org.xmlpull.v1, !sun.net.util, *
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Alternatively you try to provide classpath to dependent jar in command line itself using java -cp .:<file_1_name>.jar:<file_2_name>.jar <prog_name>
Further reading How to include jar files with java file and compile in command prompt
I'm just create jar in eclipse =)

How to fix "NoClassDefFoundError KieServices.Factory"

I am just starting learning JBoss Drools. So I have made a little application out from a book, Drools Jboss Rules 5.X. As I noticed soon, the initialisation of Drools 5.X is depricated and I rewrote the Code to Drools 6.2+ using the KieServices. Building the project finished without error.But running the jar I always got the NoClassDefFoundError: org/kie/api/KieServices$Factory. Then I began at the very beginning with a code, where nothing is in, just initialising the KieServices and got the same error. All suggestions of Stackoverflow and other discussion did not help. See below the code (nearly nothing) and the maven-file. Does anyone have a solution?
Main Class with initialisation of KieServices
import org.kie.api.KieServices;
public class App {
public static void main(String[] args) {
System.out.println("start");
KieServices ks = KieServices.Factory.get();
}
}
And here is my Maven-project
<properties>
<drools.version>6.3.0.Final</drools.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.kie.server/kie-server-api -->
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server-api</artifactId>
<version>${drools.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${drools.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<mainClass>App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Finally I added a Maven Shade Plugin to create an Uber jar. I guarantees, that all classes are there at runtime. It works. Maybe, there is a better solution, then please leave an answer. The maven project looks now like this:
<properties>
<drools.version>6.3.0.Final</drools.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
Maybe it helps some others.
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${drools.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<mainClass>App</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

How to force the dependency to include an artifact with a specific version number

I get this error when trying to build GWT project with maven:
Your project declares dependency on gwt-user 2.6.0. This plugin is
designed for at least gwt version 2.7.0
As I found out gwt-user 2.6.0 is downloaded with com.google.gwt.eventbinder.
How I can force com.google.gwt.eventbinder using gwt-user 2.7.0 instead 2.6.0?
The strange thing is that the build worked before I did 'git pull'.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.prognoz.ra.okhs</groupId>
<artifactId>gwtclient</artifactId>
<version>0.3.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gwt.version>2.7.0</gwt.version>
<maven.version>3.0.5</maven.version>
<jdk.version>1.7</jdk.version>
<version.org.codehaus.mojo.gwt.maven.plugin>2.7.0</version.org.codehaus.mojo.gwt.maven.plugin>
<webappDirectory>war</webappDirectory>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<skipTests>true</skipTests>
</properties>
<prerequisites>
<maven>${maven.version}</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>org.moxieapps.gwt</groupId>
<artifactId>highcharts</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/highcharts-1.7.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.prognoz.ra.dbutil</groupId>
<artifactId>dbutil</artifactId>
<scope>system</scope>
<version>1.0.1-SNAPSHOT</version>
<systemPath>${basedir}/out/artifacts/dbutil_jar/dbutil.jar</systemPath>
</dependency>
<dependency>
<groupId>com.liferay.org.apache.commons.fileupload</groupId>
<artifactId>com.liferay.org.apache.commons.fileupload</artifactId>
<version>6.2.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<version>${gwt.version}</version>
<artifactId>gwt-servlet</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.google.gwt.eventbinder</groupId>
<artifactId>eventbinder</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${version.org.codehaus.mojo.gwt.maven.plugin}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<compileReport>true</compileReport>
<logLevel>INFO</logLevel>
<copyWebapp>true</copyWebapp>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>Tomcat8_local</server>
<path>/ra-okhs</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Solution 1
The problem is eventbinder has dependency on gwt-user artifact. it uses 2.6.0 by default you can see it by using this command.
mvn dependency:tree
If you add this dependency block to your pom;
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.7.0</version>
</dependency>
It will look like this...
This means your project will have gwt-user 2.7.0 all the time, i haven't tested if everything is ok with version compatibility or something your problem will be solved..
Solution 2
Thanks for the #Thomas Broyer's comment we can force eventbinder to use 2.7.0 gwt-user or any gwt dependency. if we just add this dependency management to our pom
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
The result :

Pick up native JNI files in Maven test (lwjgl)

I'm creating a program with LWJGL and Maven, and I'm writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so that the tests can pick it up. I can't get past the error:
java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
I've gotten the binaries to unpack to target/libs/native/, but the tests won't pick them up.
Here's my pom:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ziroby.kata</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lwjgl.version>2.6</lwjgl.version>
</properties>
<repositories>
<repository>## Heading ##
<id>lwjgl</id>
<name>lwjgl</name>
<url>http://adterrasperaspera.com/lwjgl</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.2.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.5.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-util</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-native</artifactId>
<version>2.6</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-native</artifactId>
<version>${lwjgl.version}</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/libs/natives</outputDirectory>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
</configuration>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I've tried Maven - Add directory to classpath while executing tests , but that seems to be talking about resources, not JNI libraries (and it didn't work).
And Specifiy classpath for maven is the opposite problem: Specify things that are already on the classpath.
According to http://maven.40175.n5.nabble.com/Trouble-with-Java-Native-Libraries-td114063.html,
the surefire plugin starts the VM and then modifies the system properties before passing control to the junit test classes. This is too late for the VM, which needs to have the java.library.path set up at the time the VM is initialized.
So we need to give the path to Surefire at startup. The following worked:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.library.path=${project.build.directory}/libs/natives/win32:${project.build.directory}/libs/natives/linux:${project.build.directory}/libs/natives/macosx:${project.build.directory}/libs/natives/solaris</argLine>
</configuration>
</plugin>
Does surefire configuration include setting java library path
For example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.library.path</name>
<value>target/lib/natives/</value>
</property>
</systemProperties>
</configuration>
</plugin>

Categories