Reputation: 1225
Previously when using Apache packages, they have included jar files and all I had to do was import them into by build path.
With Apache POI (5.2.4-20230921), it now uses Gradle to build the jars.
I have tried to build POI in Eclipse (2022-03) by going to import-->Existing Gradle Project and selecting the root directory. When I do, I get the following:
The supplied phased action failed with an exception. A problem occurred configuring project ':poi'. A problem occurred evaluating project ':poi'. Failed to calculate the value of task ':poi:compileTestJava' property 'javaCompiler'. No matching toolchains found for requested specification: {languageVersion=8, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64. No locally installed toolchains match and toolchain download repositories have not been configured. poi-src-5.2.4-20230921-5.2.4 line 0 Gradle Error Marker
When I try on the command line, I get the same thing. I have looked up the toolchain information here "https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection", but it didn't help any. Running with --debug and --stacktrace gave me a bunch of additional information that didn't mean much to me.
I have not changed build.gradle from Apache, but here are the toolchain lines:
java {
toolchain {
languageVersion = JavaLanguageVersion.of(jdkVersion)
if (jdkVendor != '') vendor = JvmVendorSpec.matching(jdkVendor)
}
withJavadocJar()
withSourcesJar()
}
I have never used Gradle before so this might be something simple. I am using java 21.0.1 2023-10-17 LTS, which was downloaded and installed today. It also did not work with my previous version.
Any thoughts on what is going on? It seems that downloading the most recent version of Gradle and using with the most recent java and Apache package should be a pretty seamless process.
To address the first comment, I put gradle into the poi folder and ran gradle.bat. Here is the command and output:
poi-src-5.2.4-20230921-5.2.4>gradle.bat
Configuration on demand is an incubating feature.
> Configure project :
Trying to override old definition of datatype junit
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\x\eclipse-workspace\poi-src-5.2.4-20230921-5.2.4\poi\build.gradle' line: 82
* What went wrong:
A problem occurred evaluating project ':poi'.
> Failed to calculate the value of task ':poi:compileTestJava' property 'javaCompiler'.
> No matching toolchains found for requested specification: {languageVersion=8, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64.
> No locally installed toolchains match and toolchain download repositories have not been configured.
* Try:
> Learn more about toolchain auto-detection at https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection.
> Learn more about toolchain repositories at https://docs.gradle.org/8.4/userguide/toolchains.html#sub:download_repositories.
> 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 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1s
Upvotes: 0
Views: 851
Reputation: 1225
I got it to work by editing the build.gradle file. It was defaulting to 8 if the detection didn't work.
I change this line:
jdkVersion = (project.properties['jdkVersion'] ?: '8') as int
To this:
jdkVersion = (21) as int
in build.gradle and it ran. Of course, you would have to change it to whatever version you were running if you had the same error or could address the auto-detection.
Upvotes: 1