2

When I try to create a jar build using gradle and jdk 11, the following error always occurs:

10:53:41: Executing task 'build'...

> Task :compileJava
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootJar UP-TO-DATE
> Task :jar SKIPPED
> Task :assemble UP-TO-DATE
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test FAILED
> Task :jacocoTestReport UP-TO-DATE

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> failed to read class file /home/rodrigo/Projetos/Gaia/apipessoas/build/classes/java/test/com/rjdesenvolvimento/apipessoas/ApipessoasApplicationTests.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 9s
6 actionable tasks: 1 executed, 5 up-to-date
Unsupported class file major version 55
10:54:50: Task execution finished 'build'.

I'm lost and need help. I have tried to change the mavencentral () repository to jcenter and without success.

When I use jdk 1.8 the error does not occur, however I need jdk 11, boss orders = (

ADD NEW INFO**************************

13:29:00: Executing task 'build'...

Task :compileJava UP-TO-DATE

Task :processResources UP-TO-DATE

Task :classes UP-TO-DATE

Task :bootJar UP-TO-DATE

Task :jar

Task :assemble

Task :compileTestJava UP-TO-DATE

Task :processTestResources NO-SOURCE

Task :testClasses UP-TO-DATE

Task :test

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/home/rodrigo/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.9.RELEASE/9f9a828936d81afd49a603bda9cc1aed863a0d85/spring-core-5.0.9.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

com.rjdesenvolvimento.apipessoas.ApipessoasApplicationTests > contextLoads FAILED

java.lang.IllegalStateException

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException

Caused by: org.springframework.beans.factory.BeanCreationException

Caused by: org.springframework.beans.factory.BeanCreationException

Caused by: org.springframework.beans.factory.BeanCreationException

Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException

Caused by: org.postgresql.util.PSQLException

1 test completed, 1 failed

Task :test FAILED Task :jacocoTestReport

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':test'. There were failing tests. See the report at: file:///home/rodrigo/Projetos/Gaia/apipessoas/build/reports/tests/test/index.html

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 10s 7 actionable tasks: 3 executed, 4 up-to-date There were failing tests. See the report at: file:///home/rodrigo/Projetos/Gaia/apipessoas/build/reports/tests/test/index.html 13:29:11: Task execution finished 'build'.

Rodrigo Batista
  • 151
  • 2
  • 12

1 Answers1

6

Which version of the Gradle are you using? By looking at your log, I can guess it's 4.8.1. According to the issues on GitHub, they fixed Gradle to make it work with Java 11 in 4.10.2 version, so all you should do, is to bump Gradle to this version or later version. If you are using Gradle wrapper, you can just edit gradle/wrapper/gradle-wrapper.properties file in your project and then update distributionUrl to the following one:

distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip

Probably, you can also do it in the following way in your project directory:

gradle wrapper --gradle-version 4.10.2

and it should update or create your gradle-wrapper.properties file.

Once it's done, you can call the wrapper:

./gradlew clean build
Piotr Wittchen
  • 3,853
  • 4
  • 26
  • 39
  • Thanks for your answer. Show new errors now. I added more details to the question. – Rodrigo Batista Oct 25 '18 at 16:31
  • 1
    It seems like you need to upgrade Spring version to `5.1` or higher or add additional parameters to your build to fix this. Right now you have Spring `5.0.9`. See this answer: https://stackoverflow.com/a/46671473/1150795 – Piotr Wittchen Oct 25 '18 at 16:58
  • The warning gone. But the error with contextloads remains. – Rodrigo Batista Oct 25 '18 at 17:56
  • 1
    Have a look at the log. It says: `com.rjdesenvolvimento.apipessoas.ApipessoasApplicationTests > contextLoads FAILED java.lang.IllegalStateException Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException`. It's a failing test in your project. I don't know what's wrong there because I haven't seen the source code. I suppose you have to add a dependency to some bean. I don't know if it's integration or unit test. In the unit test, this dependency can be mocked - e.g. with Mockito. – Piotr Wittchen Oct 25 '18 at 19:07