I have a project (Spring Boot application), in which I mix Java and Groovy.
I can compile and run the project without problems inside IntelliJ Idea.
But I can't compile it with Maven.
Java 12 works fine, but when switching to 13 version it shows me next errors:
Example of POM.xml configuration:
<properties>
<java.version>13</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<javax.version>1.5.4</javax.version>
<groovy.version>2.5.8</groovy.version>
<lombok.version>1.18.10</lombok.version>
....
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>{java.version}</source>
<target>{java.version}</target>
<verbose>true</verbose>
<fork>true</fork>
<compilerArguments>
<javaAgentClass>lombok.launch.Agent</javaAgentClass>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.6.0-03</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>${groovy.version}-01</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
Does anyone know which compiler/plugin compiles java and groovy code with the java 13 version?
Java 13 support starts in groovy-eclipse-batch 2.5.8-03, which is based upon Eclipse 4.14. https://www.eclipse.org/eclipse/news/4.13/jdt.php#Java_13
You are using 2.5.8-01. At this time, Groovy 2.5.10 is the latest release and groovy-eclipse-batch:2.5.10-01 matches that. And both offer support for Java 13.
Related
I have this problem. I have just started a new Maven project and, after adding this code:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
The project is freezed on "Updating Maven Project 75", I am trying to search a solution, but no one is working. The funniest thing is I am following a course on line about Spring and it is just the first attempt to use Maven.
Tried to restart Eclipse, to delete and create a new project...
When i start mvn clean test site and test failure, allure need attach screenshot and body,but on the Java 11 body and attachements not creating.
That is also for Steps.Probably it depends on Java version and aspectJ library.
On the Java 8 it's working
No exceptions is shown.
Maybe some ideas how to configure with Java 11
Here pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>11</compiler.version>
<maven.surefire.version>2.22.0</maven.surefire.version>
<maven.compiler.version>3.8.0</maven.compiler.version>
<appium.version>7.0.0</appium.version>
<selenium.version>3.141.59</selenium.version>
<allure.testng.version>2.8.1</allure.testng.version>
<allure.maven.plugin.version>2.9</allure.maven.plugin.version>
<allure.report.version>2.7.0</allure.report.version>
<aspectj.version>1.9.1</aspectj.version>
<jetty.maven.plugin.version>9.4.12.RC2</jetty.maven.plugin.version>
<exclude.tag></exclude.tag>
</properties>
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.testng.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>
src/test/resources/testng.xml
</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
--illegal-access=permit
</argLine>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<excludedGroups>${exclude.tag}</excludedGroups>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.plugin.version}</version>
<configuration>
<webAppSourceDirectory>
${project.build.directory}\site\allure-maven-plugin
</webAppSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.plugin.version}</version>
</plugin>
</plugins>
</reporting>
The problem is that AspectJ supports Java 11 since version 1.9.2. You are using 1.9.1.
I am trying to use Sigar in my Java Maven application, i added the following dependencies:
<dependency>
<groupId>org.fusesource</groupId>
<artifactId>sigar</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.4.0</version>
</dependency>
but it was throwing thr following exception:
org.hyperic.sigar.SigarException: no libsigar-amd64-linux.so in java.library.path
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
at com.ro.terminal.model.utils.TerminalUtils.<clinit>(TerminalUtils.java:28)
at com.ro.terminal.model.service.SyncModule.init(SyncModule.java:187)
at com.ro.terminal.main.Terminalinitializer.<init>(Terminalinitializer.java:124)
at com.ro.terminal.main.Terminalinitializer$3.call(Terminalinitializer.java:339)
at com.ro.terminal.main.Terminalinitializer$3.call(Terminalinitializer.java:1)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
after googling i knew that i have to add the needed .ddl and .so files in the application and add the path to java.library.path,
i downloaded the files from here and added them under resources/sigar-lib and tried adding the following to my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<systemPropertyVariables>
<org.hyperic.sigar.path>${sigar.libs}</org.hyperic.sigar.path>
</systemPropertyVariables>
<parallel>classes</parallel>
</configuration>
</plugin>
___________________________
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.library.path>${sigar.libs}</java.library.path>
</systemPropertyVariables>
</configuration>
</plugin>
______________________
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.library.path=${sigar.libs}:${java.library.path}</argLine>
</configuration>
</plugin>
the ${sigar.libs} is defined as follows:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sigar.libs>${basedir}/src/main/resources/sigar-lib</sigar.libs>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>
what am i doing wrong? i am running eclipse oxygen on Ubuntu 17.10
project screenshot:
I'm creating maven application where I'm getting information from website.
I created maven package, but when I run jar using command:
"java -jar app-1.0-SNAPSHOT.jar" I get this error:
"java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver"
It works good when I'm running it in IntelliJ.
This is my pom:
<groupId>app</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.0.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Please help me find out what is wrong. Thanks!
there may be a chance of version mismatch as follows:
Starting with 2.53.0 you need to explicitly include HtmlUnitDriver as a dependency to include it. Version number of the driver is now tracking HtmlUnit itself.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.53.1</version>
</dependency>
Keep same versions of Selenium-Java and HTMLUnitDriver.
OR
There might be a dependency on selenium-server-standalone.jar
If you are using DefaultSelenium (or the RemoteWebDriver implementation), you still need to start a Selenium server. The best way is to download the selenium-server-standalone.jar from the Selenium Downloads page and just use it. Furthermore you can also embed the Selenium server into your own project, if you add the following dependency to your pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
Note: Be aware, that the selenium-server artifact has a dependency to the servlet-api-2.5 artifact, which you should exclude, if your project will be run inside a web application container.
Reference:
http://www.seleniumhq.org/download/maven.jsp
My application is split between users on Java 1.6u45 and Java 1.8. Our problem is that we cannot specify the project system library and have two different compiler settings for the code at the same time.
Project Structure:
Project >
> src/main/java/com/us/javafx/... (Java 8 code)
> src/main/java/com/us/... (Java 6 code)
> src/main/resources/...
Our 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.us</groupId>
<artifactId>PROJECT</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>PROJECT</name>
<description>DESCR</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<!-- Copy all dependencies to jars directory -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jars</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Maven Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- Necessary to avoid setting JRE on Maven project update! -->
<!-- SEE PHOTO FOR WHY THIS IS HERE -->
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<!-- Compile Java 6 directory -->
<execution>
<id>java6</id>
<configuration>
<excludes>
<exclude>com/us/javafx/**/*</exclude>
</excludes>
<!-- Non working attempt to set compiler version -->
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
<!-- Compile Java 8 directory -->
<execution>
<id>java8</id>
<configuration>
<includes>
<include>com/us/javafx/**/*</include>
</includes>
<!-- Non working attempt to set compiler version -->
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- Create JAR in jars folder -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>${project.build.directory}/jars</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
If we tell the Maven compiler plugin to use Java 1.8, Java 1.6 users get the unsupported major minor version error. Or we tell the Maven compiler plugin to use Java 1.6 but our Java 8 code will complain about errors when performing Right Click Project > Maven > Update Project... (which causes the screen shot below):
Is there a way we can achieve both:
1) Compile Java 6 and 8 code with their respective compilers
2) Choose Java 8 as our project's JRE System Library
I recently learned about toolchains.xml. Maven has it even documented and supports it from 2.0.9! See toolchains documentation
So I added a toolchain.xml file to my ~/.m2/ folder with following content:
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/opt/java8</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/opt/java7</jdkHome>
</configuration>
</toolchain>
</toolchains>
It allows you to define what different JDKs Maven can use to build the project irrespective of the JDK Maven runs with. Sort of like when you define JDK on project level in IDE. I used it when I needed to build another project with Java 7 while having Java 8 as a default.
I guess this can solve your issue.
Maven profiles is the simplest and most effective one.
You can elect and run them from your IDE too.
You design a profile for each different JDK you need. You put in each different JDK profile :
properties like source code target
dependencies that are specialised for that profile.
Project
+properties
+dependencies
+Profiles
Profile JDK8
+jdk8-properties
jdk.version
maven.compiler.source
maven.compiler.target
+jdk8-dependencies
Profile JDK11
+jdk11-properties
jdk.version
maven.compiler.source
maven.compiler.target
+jdk11-dependencies
Picture of maven profiles tree
And an example
<project>
<name>x</name>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.1.210</version>
</dependency>
</dependencies>
<profiles>
<!-- different Java versions -->
<profile>
<id>jdk8</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<jdk.version>1.8</jdk.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core-jakarta</artifactId>
<version>5.6.10.Final</version>
</dependency>
<!-- needed if jakarta is used -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.25</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>jdk11</id>
<properties>
<jdk.version>11</jdk.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.2.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.2</version>
</dependency>
</dependencies>
</profile>
</profiles>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<junit-version>4.13.2</junit-version>
</properties>
</project>