Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current Gradle insists on having all 4 JDKs being installed/present #1874

Open
mouse07410 opened this issue Oct 21, 2024 · 10 comments
Open

Current Gradle insists on having all 4 JDKs being installed/present #1874

mouse07410 opened this issue Oct 21, 2024 · 10 comments

Comments

@mouse07410
Copy link

It is impossible to build BC with Gradle, because it seems to require that all the four JDKs - JDK8, JDK11, JDK17, JDK21 - are installed.

No sane organization, except for those who's distributing something for all of those JDKs, would allow keeping outdated and vulnerable JDKs around. So, we're frowned upon if we have JDK17 (my systems don't), and are forbidden to install JDK11 and JDK8 (and for a good reason, if you ask me).

So, please fix the Gradle build script/file to build its OSGI (or whatever that thing is called) with those JDKs that it can find, rather than insist on all 4. Thanks.

P.S. And/or maintain the Ant build in good shape, and we don't give a flying look for Gradle.

@dghgit
Copy link
Contributor

dghgit commented Oct 22, 2024

We have never made any guarantees or offered any warranty about our sanity.

The current build will work with just Java 21 though, you might be looking at an old build.

@mouse07410
Copy link
Author

We have never made any guarantees or offered any warranty about our sanity.

This is more about the assumed sanity of the development systems. not the developers themselves. ;-)

The current build will work with just Java 21 though, you might be looking at an old build.

Not sure what you mean by "an old build" - I'm (always) building the current "main" branch from the sources.

First, there's this:

$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-8.8-bin.zip

Exception in thread "main" java.io.IOException: Downloading from https://services.gradle.org/distributions/gradle-8.8-bin.zip failed: timeout (10000ms)
	at org.gradle.wrapper.Install.forceFetch(SourceFile:4)
	at org.gradle.wrapper.Install$1.call(SourceFile:8)
	at org.gradle.wrapper.GradleWrapperMain.main(SourceFile:67)
Caused by: java.net.SocketTimeoutException: Connect timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:757)
	at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
	at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:178)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:636)
	at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
	at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:377)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1240)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1126)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1678)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1602)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
	at org.gradle.wrapper.Install.forceFetch(SourceFile:2)
	... 2 more
$
$ type gradle
gradle is hashed (/opt/local/bin/gradle)
$  gradle -V

------------------------------------------------------------
Gradle 8.10.2
------------------------------------------------------------

Build time:    2024-09-23 21:28:39 UTC
Revision:      415adb9e06a516c44b391edff552fd42139443f7

Kotlin:        1.9.24
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM:  21.0.4 (Azul Systems, Inc. 21.0.4+7-LTS)
Daemon JVM:    /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home (no JDK specified, using current Java home)
OS:            Mac OS X 15.0.1 x86_64

Why a perfectly good already-installed current Gradle isn't good enough for this gradlew script - is a separate issue.

Here's what I'm getting:

$ env | grep BC
BC_JDK21=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home
BC_HOME=/Users/ur20980/src/bc-java
$ env | grep JAVA
JAVA_OPTS=-Xmx4096m
JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home
$ gradle build --info 2>&1 | tee ~/gradle-build.txt
Initialized native services in: /Users/ur20980/.gradle/native
Initialized jansi services in: /Users/ur20980/.gradle/native
Received JVM installation metadata from '/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home': {JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home, JAVA_VERSION=21.0.4, JAVA_VENDOR=Azul Systems, Inc., RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.4+7-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.4+7-LTS, VM_VENDOR=Azul Systems, Inc., OS_ARCH=x86_64}
Removing 0 daemon stop events from registry
Starting a Gradle Daemon (subsequent builds will be faster)
Starting process 'Gradle build daemon'. Working directory: /Users/ur20980/.gradle/daemon/8.10.2 Command: /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2g -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /opt/local/share/java/gradle/lib/gradle-daemon-main-8.10.2.jar -javaagent:/opt/local/share/java/gradle/lib/agents/gradle-instrumentation-agent-8.10.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.10.2
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 1.048 secs.
The client will now receive all logging from the daemon (pid: 73128). The daemon log file: /Users/ur20980/.gradle/daemon/8.10.2/daemon-73128.out.log
Starting build in new daemon [memory: 2 GiB]
Using 20 worker leases.
Received JVM installation metadata from '/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home': {JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home, JAVA_VERSION=21.0.4, JAVA_VENDOR=Azul Systems, Inc., RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.4+7-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.4+7-LTS, VM_VENDOR=Azul Systems, Inc., OS_ARCH=x86_64}
Watching the file system is configured to be enabled if available
Now considering [/Users/ur20980/src/bc-java] as hierarchies to watch
File system watching is active
Starting Build
Settings evaluated using settings file '/Users/ur20980/src/bc-java/settings.gradle'.
Projects loaded. Root project using build file '/Users/ur20980/src/bc-java/build.gradle'.
Included projects: [root project 'bc-java', project ':core', project ':jmail', project ':mail', project ':mls', project ':pg', project ':pkix', project ':prov', project ':test', project ':tls', project ':util']

> Configure project :
Evaluating root project 'bc-java' using build file '/Users/ur20980/src/bc-java/build.gradle'.
.  .  .
* What went wrong:
Execution failed for task ':core:test'.
> Error while evaluating property 'javaLauncher' of task ':core:test'.
   > Failed to calculate the value of task ':core:test' property 'javaLauncher'.
      > Cannot find a Java installation on your machine matching this tasks requirements: {languageVersion=8, vendor=any vendor, implementation=vendor-specific} for MAC_OS on x86_64.
         > No locally installed toolchains match and toolchain auto-provisioning is not enabled.

Here's the complete log: gradle-build.txt

@dghgit
Copy link
Contributor

dghgit commented Oct 23, 2024

Hmmm... if you do a:

javac --help

it does show:

--release
Compile for the specified Java SE release.
Supported releases:
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21

doesn't it?

@mouse07410
Copy link
Author

$ javac --help
Usage: javac <options> <source files>
where possible options include:
  @<filename>                  Read options and filenames from file
  -Akey[=value]                Options to pass to annotation processors
  --add-modules <module>(,<module>)*
        Root modules to resolve in addition to the initial modules,
        or all modules on the module path if <module> is ALL-MODULE-PATH.
  --boot-class-path <path>, -bootclasspath <path>
        Override location of bootstrap class files
  --class-path <path>, -classpath <path>, -cp <path>
        Specify where to find user class files and annotation processors
  -d <directory>               Specify where to place generated class files
  -deprecation
        Output source locations where deprecated APIs are used
  .  .  .  .  .
  --release <release>
        Compile for the specified Java SE release.
        Supported releases: 
            8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
  -s <directory>               Specify where to place generated source files
  --source <release>, -source <release>
        Provide source compatibility with the specified Java SE release.
        Supported releases: 
            8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
  --source-path <path>, -sourcepath <path>
        Specify where to find input source files
  --system <jdk>|none          Override location of system modules
  --target <release>, -target <release>
        Generate class files suitable for the specified Java SE release.
        Supported releases: 
            8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
  --upgrade-module-path <path>
        Override location of upgradeable modules
  -verbose                     Output messages about what the compiler is doing
  --version, -version          Version information
  -Werror                      Terminate compilation if warnings occur

$ javac -version
javac 21.0.5
$ 

@lal-s
Copy link

lal-s commented Dec 10, 2024

I was facing the exact same issue, I am working off the current fork in github and running ./gradlew clean build

I fixed it by setting BC_JDK8 in my bash file but keeping Java 21 as the default version

@dghgit
Copy link
Contributor

dghgit commented Dec 28, 2024

We think it should now be possible to just use Java 21. Feedback would be appreciated.

@mouse07410
Copy link
Author

Better than before. But in the end - no joy.

$ env | grep JAVA
JAVA_OPTS=-Xmx4096m
JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home
$ gradle build --info 2>&1 | tee ~/gradle-build.txt
.  .  .
[Incubating] Problems report is available at: file:///Users/ur20980/src/bc-java/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':checkstyleNohttp'.
> A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
   > An unexpected error occurred configuring and executing Checkstyle.
      > java.lang.OutOfMemoryError: Java heap space

.  .  .

gradle-build.txt

@dghgit
Copy link
Contributor

dghgit commented Dec 29, 2024

What extra directories are in the distribution? I think to see this the checkstyle plugin would have to be wandering into something it shouldn't.

@mouse07410
Copy link
Author

What extra directories are in the distribution?

None, as far as I know - "bc-java" is cloned directly:

$ git remote -v
origin	https://github.com/bcgit/bc-java.git (fetch)
origin	https://github.com/bcgit/bc-java.git (push)
$ 
$ li
CONTRIBUTING.md           bnd.sh*                   config/                   kmip/                     prov/
CONTRIBUTORS.html         build/                    core/                     libs/                     run_test.sh
LICENSE.html              build.gradle              docs/                     mail/                     scripts/
LICENSE.md                build1-1                  gradle/                   misc/                     settings.gradle
README.md                 build1-2                  gradle.properties         mls/                      spotbugs/
SECURITY.md               build1-3                  gradlew*                  mod_test_ext.sh           spotbugs.gradle
add_module.sh             build1-4                  gradlew.bat               mod_test_prov.sh          spotbugs.settings.gradle
ant/                      build1-5to1-8             index.html                osgi_scan.sh*             spotbugs_settings.gradle
bc-build.properties       build1-8+                 jar_process.sh            osgi_scan.xml             test/
bc-build.user.properties@ buildj2me                 jce/                      pg/                       tls/
bc_maven_public_key.asc   ci/                       jmail/                    pkix/                     util/
$

I think to see this the checkstyle plugin would have to be wandering into something it shouldn't.

Alas, I've no clue. What appears to me is that (a) JAVA_OPTS=-Xmx4096m is getting lost or ignored somewhere where it would've been required, or (b) less likely - 4GB of heap space is not enough when building with Gradle.

@dghgit
Copy link
Contributor

dghgit commented Dec 31, 2024

Back to the drawing board...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants