I'm running a build using Gradle with open JDK 9.
The gradlew shadow command fails with the exception:
java.lang.IllegalAccessException: class org.gradle.api.internal.tasks.compile.reflect.SourcepathIgnoringInvocationHandler cannot access class com.sun.tools.javac.file.BaseFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module #1c5af20
But I am running the java command with the option to export this module to all unnamed modules. My full java command:
exec /docker-java-home/bin/java --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -Dorg.gradle.appname=gradlew -classpath /test/IotDevice/Applications/AppInsightsDocker/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain --stacktrace shadow
Why am I still getting this exception?
Related
I am migrating project from Java 8 to newer version.
I am not using module info.
springBootVersion=2.5.7
springCloudVersion=2020.0.5
I have an error in Intellij during build:
Cannot cast object 'property(org.gradle.api.file.Directory, undefined)' with class 'org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar' to class 'java.io.File'
* Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cannot cast object 'property(org.gradle.api.file.Directory, undefined)' with class 'org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar' to class 'java.io.File'
This issue occurs while using gradle-7.3.3,
when changed to gradle-7.4 issue changes to:
Cannot query the value of this property because it has no value available.
On gradle 7.3 the issue is:
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar cannot be cast to class java.io.File (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #6a4f787b; java.io.File is in module java.base of loader 'bootstrap')
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar cannot be cast to class java.io.File (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #6a4f787b; java.io.File is in module java.base of loader 'bootstrap')
I think the issue comes from this gradle block (idea part) that worked fine before:
afterEvaluate {
contracts {
baseClassForTests = "(...).contract.ContractBaseSpec"
basePackageForTests = '(...).contract.tests'
//targetFramework = TestFramework.SPOCK some other error here
testMode = 'EXPLICIT'
baseClassMappings {
baseClassMapping('.*event.*', '(...).contract.EventContractBaseSpec')
}
}
idea {
module {
testSourceDirs += project.contracts.generatedTestSourcesDir
generatedSourceDirs += project.contracts.generatedTestSourcesDir
}
}
}
After commenting it - build is ok.
Intellij 2022.1 EAP,
the same in 2021.3.2.
Java version setting in IntelliJ's Project setting does not make difference, I tried both: java 11 and java 17.
The same with build tools - gradle JVM java version setting.
As of https://docs.gradle.org/current/userguide/compatibility.html
Java 17 is compatible from gradle 7.3.
Running from terminal and from jenkins i see other issue:
sdk use java 17.0.2-open
Using java version 17.0.2-open in this shell.
./gradlew --version
------------------------------------------------------------
Gradle 7.3
------------------------------------------------------------
./gradlew clean build
Issue:
> BUG! exception in phase 'semantic analysis' in source unit '(.some-path-here...)/contract/ClientBuilder.groovy' Unsupported class file major version 61
Stacktrace: https://pastebin.pl/view/1449e795
in gradle:
jacoco {
toolVersion = "0.8.7"
}
as for this issue updating groovy from 3.0.3 to 3.0.9 fixes it and shows another issue.
Still why IntelliJ shows different issue?
I am trying to build a Quarkus native executable using docker using the following command "mvn clean package "-Pnative" "-Dquarkus.native.container-build=true" "-Dquarkus.native.container-runtime=docker"
Quarkus version: 2.2.1.Final
Maven version : 3.8.1
Java version: 11
and I get the below error:
Error: Annotated class must be final: class io.quarkus.amazon.lambda.http.graal.LambdaContainerHandlerSubstitution
com.oracle.svm.core.util.UserError$UserException: Annotated class must be final: class io.quarkus.amazon.lambda.http.graal.LambdaContainerHandlerSubstitution
at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
at com.oracle.svm.core.util.UserError.guarantee(UserError.java:96)
at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:280)
at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:266)
at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:936)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:868)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:491)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:380)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)
It's a bug, please open an issue on https://github.com/quarkusio/quarkus/issues
Build is failing when I did a change in Java file
Android Gradle Plugin: 3.2.1
Gradle Version: 4.6
Please find the snapshot of error below:
17:58:31.131 [ERROR] [system.err] symbol: class FragmentNavigationManager
17:58:31.132 [ERROR] [system.err] location: package com.microsoft.office.officemobile.FragmentManagerInfra
17:58:31.138 [ERROR] [system.err] D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ActionsTab\ActionsAdapter.java:45: error: cannot find symbol
17:58:31.138 [ERROR] [system.err] import com.microsoft.office.officemobile.KaizalaPhoneauth.KaizalaPhoneAuthManager;
I checked the undefined symbols are present inside file FragmentNavigationManager.java file inside the sources.
Using debug logs, I found the class file FragmentNavigationManager.class is getting deleted before doing java build
gradle: 17:58:28.630 [DEBUG] [org.gradle.api.internal.file.delete.Deleter] Deleting d:\office\build\droidarm\ship\officemobile\android\java\intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobile\FragmentManagerInfra\FragmentNavigationManager.class
After deletion of above class, while doing Java incremental build, FragmentNavigationManager.java should be passed as an input for javac, but it is not happening, which is causing undefined symbol issue. Clean build working fine
I found the issue
The source file path is: src\com\microsoft\office\officemobilefragmentmanagerinfra\FragmentNavigationManager.java
Generated Class file: intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobileFragmentManagerInfra\FragmentNavigationManager.class
There is a case mismatch in directory name at source path and generated class path, which is causing the issue. Source path has fragmentnavigationmanager instead of FragmentNavigationManager
I found that the package name is: com.microsoft.office.officemobile.FragmentManagerInfra.FragmentNavigationManager. Changing directory name to match the package name at the source path resolves the issue
Is this expected, as full build is working fine and incremental Gradle build is only failing?
Working on Windows 10
Spring Initializr is a open source project , which can be downloaded/cloned from github to run our own spring initializr. however the build of the project is maven. I want to convert it to gradle. Can anyone Help ?
I tried it with gradle init and gradle build
Gradle init is creating build.gradle and settings.gradle but gradle build is giving error.
Can someone try and post the solution
Thanks in advance
Error Details :
Task :initializr-actuator:compileTestJava FAILED
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\ActuatorIntegrationTests.java:19: error: package io.spring.initializr.web does not exist
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\ActuatorIntegrationTests.java:35: error: cannot find symbol
extends AbstractFullStackInitializrIntegrationTests {
^
symbol: class AbstractFullStackInitializrIntegrationTests
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\info\BomRangesInfoContributorTests.java:24: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\metric\ProjectGenerationMetricsListenerTests.java:28: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\AbstractInitializrStatTests.java:23: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\MainControllerStatsIntegrationTests.java:24: error: package io.spring.initializr.web does not exist
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\MainControllerStatsIntegrationTests.java:56: error: cannot find symbol
extends AbstractFullStackInitializrIntegrationTests {
^
symbol: class AbstractFullStackInitializrIntegrationTests
7 errors
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':initializr-actuator:compileTestJava'.
Compilation failed; see the compiler error output for details.
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 4s
11 actionable tasks: 1 executed, 10 up-to-date
Instead of converting that you can generate fresh project from following url:
https://start.spring.io/
Select Gradle Project and download the code.
I'm trying Kotlin script for gradle configuring. Line from build.gradle.kts:
val deployTest = System.getProperty("deployTest").toBoolean()
Running:
gradle clean build
It works well on my local workstation but fails on TeamCity:
IllegalStateException: Error type encountered: [ERROR : Type for (System.getProperty("deployTest") as String).toBoolean()] (DeferredType)
Property deployTest is not set on my workstation nor on TC. And on my workstation it returns false. What's wrong with it?