Not a java dev touching java for the first time, can't get gradle to work.
I'm trying to install this extension for Ghidra. The readme says I should run:
GHIDRA_INSTALL_DIR=${GHIDRA_HOME} gradle
I've installed java 18 and gradle on a mac. When running the above, I get the following error:
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :copyDependencies NO-SOURCE
> Task :compileJava FAILED
/home/gradle/project/src/main/java/ghidra/app/plugin/core/analysis/eBPFSolanaAnalyzer.java:156: error: text blocks are not supported in -source 11
func.setComment("""
^
(use -source 15 or higher to enable text blocks)
1 error
FAILURE: Build failed with an exception.
Tried running out of docker too (thinking it was a problem with my installation):
docker run --rm -u gradle -e GHIDRA_INSTALL_DIR=/home/gradle/project/installed -v "$PWD":/home/gradle/project -w /home/gradle/project gradle gradle
But alas get the exact same error.
Why does gradle think I have Java 11 when in fact I have java 18? gradle -v
gives me:
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1.1 (Homebrew 18.0.1.1 0)
OS: Mac OS X 12.4 x86_64
This is probably total newb question but like I said I've never touched java:) Any help super appreciated.
CodePudding user response:
The error means that the project has been configured to be compatible with Java 11, which is why you can't use features from newer versions (even if you run with a newer version).
While I don't know the Ghidra project, you can see from the build file in the extension that it applies a script from the base project:
apply from: new File(ghidraInstallDir).getCanonicalPath() "/support/buildExtension.gradle"
Then, if you head over to the Ghidra project and find the extension file, you can see that it indeed configures the source and target version:
compileJava {
sourceCompatibility = ghidraProps.getProperty('application.java.compiler')
targetCompatibility = ghidraProps.getProperty('application.java.compiler')
dependsOn copyDependencies
}
These appear to come from the properties file located in Ghidra/application.properties:
application.name=Ghidra
application.version=10.2
application.release.name=DEV
application.layout.version=1
application.gradle.min=6.8
application.java.min=11
application.java.max=
application.java.compiler=11
So I would imaging that if you find this file in your local installation, you can change the application.java.compiler
property to 18. Just be aware that Ghidra might not not actually support it - or it might work just fine; try it out :)