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

Update JRuby and all JRuby/Maven plugins #263

Merged
merged 4 commits into from Aug 25, 2023

Conversation

headius
Copy link
Contributor

@headius headius commented Aug 3, 2023

This is part of work to update the entire JRuby/Maven stack, in order to update the version of JRuby used and to address API deprecations at rubygems.org.

This PR updates JRuby to latest (9.4.3.0) and moves all plugins to their new org.jruby.maven group ID with latest versions.

Part of the fix for jruby/maven-tools#37. (incorrectly tagged as #37 here before)

We will need to coordinate getting this released along with the maven plugins in the very near term. Because of the rubygems.org API being shut down next week (the 8th), we are under the gun.

See jruby/mavengem#9, jruby/jruby-maven-plugins#126, jruby/maven-tools#38 and jruby/jruby#7872.

@headius
Copy link
Contributor Author

headius commented Aug 3, 2023

cc @jvanzyl @mkristian

@mosabua
Copy link
Member

mosabua commented Aug 3, 2023

Oh .. thats awesome @headius . I kicked off the build. We can probably work with @cstamas to get another release out whenever you think this is ready from your end. We might have to exclude or fix some other issues.

@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

@mosabua I pushed an update to add the Sonatype snapshots repo to pluginRepositories, which should get this build farther.

This is part of work to update the entire JRuby/Maven stack, in
order to update the version of JRuby used and to address API
deprecations at rubygems.org.

This PR updates JRuby to latest (9.4.3.0) and moves all plugins
to their new org.jruby.maven group ID with latest versions.

The maven-tools gem is updated to 1.2.

Part of the fix for jruby/maven-tools#37.

We will need to coordinate getting this released along with the
maven plugins in the very near term. Because of the rubygems.org
API being shut down next week (the 8th), we are under the gun.

See jruby/mavengem#9, jruby/jruby-maven-plugins#126,
jruby/maven-tools#38 and jruby/jruby#7872.
@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

@cstamas @mosabua More updates looking for a CI build pretty please! 😀

@cstamas
Copy link
Member

cstamas commented Aug 4, 2023

@mkristian ping

@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

I was just able to do a local rebuild of JRuby with all of the following artifacts updated:

  • polyglot-maven to 0.4.11-SNAPSHOT (installed locally)
  • jruby-maven-plugins to 3.0.0-SNAPSHOT (in sonatype snapshots)
  • mavengem to 2.0.0-SNAPSHOT (in sonatype snapshots)
  • maven-tools gem 1.2.0.pre1 (in rubygems)

I believe this is close to having everything in the right places. I need to untangle what order to do releases in to make this all work right.

If it were possible to get a snapshot drop of polyglot-maven it would definitely aid testing!

@cstamas
Copy link
Member

cstamas commented Aug 4, 2023

you want this PR deployed as snapshot or master of it?

@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

@cstamas Whatever works better for your process! I just can't do the full JRuby CI against all the snapshots until this one is available remotely.

@cstamas
Copy link
Member

cstamas commented Aug 4, 2023

Deployed 0.4.11-SNAPSHOT (this PR): ./mvnw clean deploy -P takari-release

[cstamas@blondie polyglot-maven (headius-update_jruby_and_plugins)]$ ./mvnw -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/cstamas/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 1.8.0_382, vendor: Temurin, runtime: /home/cstamas/.sdkman/candidates/java/8.0.382-tem/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.4.7-200.fc38.x86_64", arch: "amd64", family: "unix"
[cstamas@blondie polyglot-maven (headius-update_jruby_and_plugins)]$ 

https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-ruby/0.4.11-SNAPSHOT/

@cstamas
Copy link
Member

cstamas commented Aug 4, 2023

Word of warning: with maven 3.9.4 the build failed 😞

[ERROR] Failed to execute goal io.takari.polyglot:polyglot-maven-plugin:0.4.11-SNAPSHOT:execute (4) on project execute-ruby: Execution 4 of goal io.takari.polyglot:polyglot-maven
-plugin:0.4.11-SNAPSHOT:execute failed: A required class was missing while executing io.takari.polyglot:polyglot-maven-plugin:0.4.11-SNAPSHOT:execute: org/codehaus/plexus/util/IOUtil

Is plexus-util added to plugin classpath? (as 3.9 cuts the ties with Maven2 where p-u was "auto injected/added to classpath of a plugin").

@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

Is plexus-util added to plugin classpath

You are asking if it is in the classpath of the JRuby/Maven plugins, yes? I'll investigate that. I did not change anything related to this.

@headius
Copy link
Contributor Author

headius commented Aug 4, 2023

@mkristian
Copy link
Contributor

@cstamas how to to handle p-u if we want this to work with both old and new maven versions ? explicitly adding it to classpath ?

@mkristian
Copy link
Contributor

got the problem which is in https://github.com/takari/polyglot-maven/blob/master/polyglot-maven-plugin/pom.xml and adding plexus-utils solve the problem. Not sure why this PR broke it - probably it did not - still double checking . .

@cstamas
Copy link
Member

cstamas commented Aug 5, 2023

Yes, explicitly add p-u to classpath, as any other dependency, 3.9 cut ties with Maven 2.x legacy. Every 3.9.x had this in release notes explaining it:
https://maven.apache.org/docs/3.9.4/release-notes.html#potentially-breaking-core-changes-if-migrating-from-3-8-x

@cstamas
Copy link
Member

cstamas commented Aug 5, 2023

No, this pr is unrelated. It was me "just to try out" as on my workstation default mvn is 3.9.4.

With mvnw it all works, but, may have issues at runtime if used with 3.9.x

@cstamas
Copy link
Member

cstamas commented Aug 5, 2023

Use of p-u version 3.5.1 (not newer like 4.x) recommended

@mkristian
Copy link
Contributor

@cstamas this fixed the maven-3.9.4 failure on my side

diff --git a/polyglot-maven-plugin/pom.xml b/polyglot-maven-plugin/pom.xml
index 8fd7ee8..3cfdea4 100644
--- a/polyglot-maven-plugin/pom.xml
+++ b/polyglot-maven-plugin/pom.xml
@@ -18,6 +18,11 @@
   <packaging>takari-maven-plugin</packaging>
 
   <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>2.0.6</version>
+    </dependency>
     <dependency>
       <groupId>io.takari.polyglot</groupId>
       <artifactId>polyglot-common</artifactId>

@mkristian
Copy link
Contributor

mkristian commented Aug 5, 2023

#264 ----^

@headius
Copy link
Contributor Author

headius commented Aug 7, 2023

Is it possible that something in your snapshot build is building with Java 20 bytecode? I've got something in the stack that's causing me to get a NoClassDefFoundError with very little information, but the error goes away if I switch to JDK 20 and try to build again.

I will double-check my other JRuby/Maven projects and make sure they've all been build with Java 8 bytecode.

@jvanzyl
Copy link
Contributor

jvanzyl commented Aug 7, 2023

I'll take a look as maybe there's an external snapshot. This repo should be on 8.

@headius
Copy link
Contributor Author

headius commented Aug 7, 2023

It appears that mavengem and jruby-maven-plugins are being deployed with Java 8 compat bytecode.

The failure seems to happen during dependency fetching at the beginning of the build. If I wipe out, say, all of org/jruby/maven in my repo, they need to be fetched to boot polyglot. That fetch fails on 8, but works on 17 or 20.

Once all dependencies have been fetched then Java 8 works properly.

Seems like it would point at my mavengem mojo being the problem but I'm not sure what could be causing it. The failure happens while evaluating the pom.rb files, I believe, which might implicate polyglot-ruby?

I'm shooting in the dark right now. The exception is just this, with no cause or further information, and the stack trace just shows some Ruby method being called followed by NoClassDefFound:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.jruby.ir.targets.indy.Bootstrap
	at uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.did_you_mean.spell_checker.RUBY$method$initialize$0(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/did_you_mean/spell_checker.rb:8)
	at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:139)

@headius
Copy link
Contributor Author

headius commented Aug 8, 2023

I have not found my root problem, but I have isolated it to when the JRuby used by mavengem is allowed to JIT compile Ruby code to JVM bytecode. The error ends up being a LinkageError because two versions of a core JRuby class are being loaded from two different classloaders. I'm working around it for the moment by having mavengem disable the JRuby JIT.

I ran into this once before and was told it might be a bug in JDK 8ish. We worked around it at the time, but I can't locate that code at the moment. The fact that this works properly on JDK 11+ makes me believe it is again a JDK bug at least in JDK 8.

@headius
Copy link
Contributor Author

headius commented Aug 8, 2023

I have filed an OpenJDK issue for the LinkageError I'm seeing. I'll proceed with no-JIT mavengem for now.

https://bugs.openjdk.org/browse/JDK-8313913

@cstamas
Copy link
Member

cstamas commented Aug 8, 2023

The snapshot i deployed was built with java 17 temurin, so it is possible that something went in (but that means we have some issue lurking somewhere?)

No, I am wrong. Just figured above where I commented about 3.9.4 not working. I ued wrapper (3.6.3 and Java 8)...
#263 (comment)

@headius
Copy link
Contributor Author

headius commented Aug 8, 2023

@cstamas @jvanzyl @mkristian @mosabua I have released jruby-maven-plugins 3.0.0 and mavengem 2.0.0 to central and confirmed a local build of JRuby using those two plus an updated local snapshot of polyglot-maven.

If you can push an updated snapshot I can run it through CI for additional confirmation, but I think we're in good shape.

@cstamas
Copy link
Member

cstamas commented Aug 8, 2023

Am deploying in few...

@cstamas
Copy link
Member

cstamas commented Aug 8, 2023

Deploy done:

[cstamas@blondie polyglot-maven (headius-update_jruby_and_plugins)]$ git show 
commit 408b6ccb11d58d8c5a2013815a23763e9e20af8d (HEAD -> headius-update_jruby_and_plugins)
Author: Charles Oliver Nutter <headius@headius.com>
Date:   Tue Aug 8 16:44:44 2023 -0500

    Update jruby-maven-plugins to 3.0 and mavengem to 2.0

diff --git a/polyglot-ruby/pom.xml b/polyglot-ruby/pom.xml
index cbd19a5..1e485da 100644
--- a/polyglot-ruby/pom.xml
+++ b/polyglot-ruby/pom.xml
@@ -43,7 +43,7 @@
   </dependencies>
 
   <properties>
-    <mavengem-wagon.version>2.0.0-SNAPSHOT</mavengem-wagon.version>
+    <mavengem-wagon.version>2.0.0</mavengem-wagon.version>
   </properties>
 
   <pluginRepositories>
@@ -158,7 +158,7 @@
       </dependencies>
 
       <properties>
-        <jruby.plugins.version>3.0.0-SNAPSHOT</jruby.plugins.version>
+        <jruby.plugins.version>3.0.0</jruby.plugins.version>
       </properties>
 
       <build>
[cstamas@blondie polyglot-maven (headius-update_jruby_and_plugins)]$ ./mvnw -V clean deploy -P takari-release
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/cstamas/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 1.8.0_382, vendor: Temurin, runtime: /home/cstamas/.sdkman/candidates/java/8.0.382-tem/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.4.7-200.fc38.x86_64", arch: "amd64", family: "unix"
...
Uploaded to sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/0.4.11-SNAPSHOT/polyglot-translate-plugin-0.4.11-20230808.223524-2-sources.jar.asc (833 B at 2.8 kB/s)
Downloading from sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/maven-metadata.xml
Downloaded from sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/maven-metadata.xml (445 B at 1.5 kB/s)
Uploading to sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/0.4.11-SNAPSHOT/maven-metadata.xml
Uploaded to sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/0.4.11-SNAPSHOT/maven-metadata.xml (1.6 kB at 1.8 kB/s)
Uploading to sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/maven-metadata.xml
Uploaded to sonatype.snapshots: https://oss.sonatype.org/content/repositories/snapshots/io/takari/polyglot/polyglot-translate-plugin/maven-metadata.xml (445 B at 460 B/s)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Polyglot :: Aggregator 0.4.11-SNAPSHOT:
[INFO] 
[INFO] Polyglot :: Aggregator ............................. SUCCESS [  5.584 s]
[INFO] Polyglot :: Common ................................. SUCCESS [  8.105 s]
[INFO] Polyglot :: Atom ................................... SUCCESS [ 14.574 s]
[INFO] Polyglot :: Maven Plugin ........................... SUCCESS [ 11.008 s]
[INFO] Polyglot :: Ruby ................................... SUCCESS [ 33.469 s]
[INFO] Polyglot :: Scala .................................. SUCCESS [ 32.306 s]
[INFO] Polyglot :: Groovy ................................. SUCCESS [ 14.582 s]
[INFO] Polyglot :: YAML ................................... SUCCESS [ 15.238 s]
[INFO] Polyglot :: Clojure ................................ SUCCESS [ 10.708 s]
[INFO] Polyglot :: XML .................................... SUCCESS [ 10.713 s]
[INFO] Polyglot :: Java ................................... SUCCESS [  6.839 s]
[INFO] Polyglot :: Kotlin ................................. SUCCESS [ 28.983 s]
[INFO] Polyglot :: Translate Plugin ....................... SUCCESS [  6.592 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:19 min
[INFO] Finished at: 2023-08-09T00:35:29+02:00
[INFO] ------------------------------------------------------------------------
[cstamas@blondie polyglot-maven (headius-update_jruby_and_plugins)]$ 

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

Everything looks good here: jruby/jruby#7872

The few failures are either because I'm not prefetching the polyglot snapshot on that environment (rather than custom settings.xml) or it's an unrelated failure (a few tests went red recently and weren't noticed).

I think this is good to release. What else can I do to help?

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

Just FYI, I had a chat with the rubygems.org folks and the deprecated API that's going away will be available until we say we're ready for them to shut it off.

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

@cstamas @mosabua @mosabua I think we're ready for a release here. Do let me know if there's anything else I can do to help.

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

I cleaned up some of the failures on JRuby master and the PR is greener now. Remaining builds are just not pre-fetching the polyglot snapshot.

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

Oh hold the presses... I should release a non-pre maven-tools gem and reference that.

@headius
Copy link
Contributor Author

headius commented Aug 9, 2023

Done!

The pre1 gem and the released gem are identical, so this doesn't really change anything, but it's better to not depend on the prerelease version.

@headius
Copy link
Contributor Author

headius commented Aug 14, 2023

Is there anything I can do to help get this merged and released? We can't upgrade to the new JRuby Maven stack until we can pull in updated polyglot.

@headius
Copy link
Contributor Author

headius commented Aug 14, 2023

We can't upgrade to the new JRuby Maven stack until we can pull in updated polyglot.

Incidentally, if there's anything we might do better to isolate polyglot and its dependencies from mavengem/jruby-maven-plugins used by the build, I'd love to help make that happen. As it is now, there are challenges running a polyglot with older JRuby than the Maven plugins actually activated during the build, meaning they all must update JRuby in lockstep.

@cstamas
Copy link
Member

cstamas commented Aug 15, 2023

I can merge, but am currently away from home and have no access to linux box I usually do releases from (home around 24th Aug). If this is not acceptable for you guys, please ask someone else to perform release.

@headius
Copy link
Contributor Author

headius commented Aug 15, 2023

@cstamas Next week is fine!

Some of the .0 artifacts still had references to de.saumya and
org.torquebox versions, so all three projects have been updated
to the latest releases and re-released. No functional changes, for
the most part, since the libraries themselves were already using
the new artifacts. This mostly affects tests and documentation and
gets rid of all the old artifact references.
@headius
Copy link
Contributor Author

headius commented Aug 16, 2023

One more push to update all of the JRuby/Maven dependencies. Some of them still used older artifacts out of necessity (self-referential or circular-referential dependencies) and some of the documentation still referenced those older artifacts. All are now updated to latest.

@cstamas
Copy link
Member

cstamas commented Aug 25, 2023

Am back, so are we fine? Merge and release?

@headius
Copy link
Contributor Author

headius commented Aug 25, 2023

Make it so!

@cstamas cstamas merged commit 7c61a48 into takari:master Aug 25, 2023
3 checks passed
@headius headius deleted the update_jruby_and_plugins branch August 25, 2023 18:42
@cstamas
Copy link
Member

cstamas commented Aug 25, 2023

@cstamas
Copy link
Member

cstamas commented Aug 25, 2023

0.4.11 landed in Maven Central, enjoy!

@headius
Copy link
Contributor Author

headius commented Aug 26, 2023

Excellent! I will merge support into JRuby and we should be good.

@mkristian
Copy link
Contributor

mkristian commented Aug 31, 2023 via email

@cstamas
Copy link
Member

cstamas commented Aug 31, 2023

I have an old, long ongoing PR that I will probably split into multiple smaller ones, that among others sorts out the plexus-utils stuff, migrates from plexus to JSR330 but there are some issues as well (in kotlin), hence will split it to make these baby steps...

Also, there is parent POM update, that in turn means move to takari-lifecycle 2.x line, and it has some issues i want to sort out, among others, takari-lifecycle became Java 11, so would raise buildtime Java requirement to 11, but could still happily produce Java 8 artifacts.... so, please chime in there and possibly comment about these

#257

@headius
Copy link
Contributor Author

headius commented Aug 31, 2023

@mkristian if you are asking in general what could be done to improve this, I would say better isolation of the JRuby used for polyglot from any JRuby used in Maven plugins like mavengem. The only reason I needed to update polyglot at the same time was because its older jruby caused problems when the plugins needed a newer one.

@headius
Copy link
Contributor Author

headius commented Aug 31, 2023

@cstamas continuing to support Java 8 in built artifacts would be great because we will continue to support Java 8 for at least another year.

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

Successfully merging this pull request may close these issues.

None yet

5 participants