Skip to content

Update jgit from 5.7.0 to 6.7.0. - #6500

Closed
mbien wants to merge 2 commits into
apache:masterfrom
mbien:jgit-670
Closed

mbien wants to merge 2 commits into
apache:masterfrom
mbien:jgit-670

Conversation

@mbien

@mbien mbien commented Sep 29, 2023 •

Copy link
Copy Markdown
Member
  • JGit 6.x requires JDK 11+
  • JGit split the main jar into multiple artifacts, this PR adds
    • org.eclipse.jgit
    • org.eclipse.jgit.lfs
    • org.eclipse.jgit.gpg.bc
    • org.eclipse.jgit.ssh.jsch
  • only minor API adjustments were needed even though JGit had 14 releases in the meantime (changes)

fixes #4197
unblocks #6528

@mbien mbien added work-in-progress Upgrade Library Library (Dependency) Upgrade git [ci] enable versioning job ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Sep 29, 2023
@mbien mbien added this to the NB20 milestone Sep 29, 2023
@neilcsmith-net

Copy link
Copy Markdown
Member

It looks like this is changing the OSGi module into a standard NetBeans library wrapper? Compare the dev build with the last release - modules/org-eclipse-jgit.jar no longer contains the library, but points to the library files in modules/ext. I assume this is why you had to add things like public packages.

I assume we might have to have a subproject for each JGit fragment? This is assuming that the OSGi support in the IDE supports fragment-host already. eg. see #1048 for platform.

Do we also need to include org.eclipse.jgit.gpg.bc? The project.xml includes dependencies on bcpg and bcprov.

@mbien

mbien commented Sep 29, 2023 •

Copy link
Copy Markdown
Member Author

It looks like this is changing the OSGi module into a standard NetBeans library wrapper?

yes. I didn't have time for the osgi extra steps, I only wanted to quickly check how much work the migration would be - turned out almost none since the API didn't change much. OSGI would require one module per jar (as far as I understand the ant build) - i wasn't even sure how many extra jars would be needed, turns out only one.

I essentially had to figure out which classes are in which artifacts (I feared there would be more artifacts) first. NetBeans' SMO search feature was quite useful for this.

@matthiasblaesing

Copy link
Copy Markdown
Contributor

I had a quick look at this and looks sane to me. The "one module" approach might be a good option.

For org.eclipse.jgit.gpg.bc: Yes I think this should also be included. That module provides signing support and from a quick glance this is hooked into CommitCommand and TagCommand, which makes sense for the usecases. If I remember correctly we also have an issue requesting support for signing.

Looking through the modules, org.eclipse.jgit.lfs seems also to be sensible for the NB usecase

@ramiswailem

Copy link
Copy Markdown
Contributor

#4439

Fixes issues when modules with JDK 11 requirement are loaded.
@mbien

mbien commented Oct 2, 2023 •

Copy link
Copy Markdown
Member Author
  • the individual jars have some extra notes appended to their license. What I did is to strip html and concat all of them into a single EDL-1.0-jgit license - hope thats ok
  • the API sig checks are disabled for this lib wrapper module (sigtest.gen.fail.on.error=false)
  • micronaut tests seem to work again when some dependencies are bumped, this took a while since the tests log so many exceptions that it is difficult to know what is expected and what not

probably going to keep this split into two commits

how should we handle secondary dependencies? This is what the 4 jars would need:

Details
    <dependency>
      <groupId>com.googlecode.javaewah</groupId>
      <artifactId>JavaEWAH</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.16.0</version>
    </dependency>

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>

    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcpg-jdk18on</artifactId>
    </dependency>

    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcprov-jdk18on</artifactId>
    </dependency>

    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcutil-jdk18on</artifactId>
    </dependency>

    <dependency>
      <groupId>org.bouncycastle</groupId>
      <artifactId>bcpkix-jdk18on</artifactId>
    </dependency>

    <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
    </dependency>

    <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jzlib</artifactId>
    </dependency>

NB's bouncy castle wrappers are at jdk15on
edit: resolved via #6517

basic tests green, going to restart with all tests active just to be sure (edit: also green)

@mbien
mbien marked this pull request as ready for review October 2, 2023 01:14
@mbien mbien added the ci:all-tests [ci] enable all tests label Oct 2, 2023
 - JGit 6.x requires JDK 11+
 - JGit split the main jar into multiple artifacts, this adds
   - org.eclipse.jgit
   - org.eclipse.jgit.lfs
   - org.eclipse.jgit.gpg.bc
   - org.eclipse.jgit.ssh.jsch
 - only minor code adjustments needed
@mbien

mbien commented Oct 5, 2023

Copy link
Copy Markdown
Member Author

with the help of @matthiasblaesing #6517 (comment) I tried in a second attempt to use the jars as osgi modules and can confirm my suspicion that each wrapped osgi jar requires one lib wrapper module:

Cannot include other files with an OSGi bundle: modules/org-eclipse-jgit-gpg-bc.jar

I don't really want to do that tbh. would a normal lib wrapper module be ok, like currently in this PR? I suppose we could make this a friend API and/or keep the sig check disabled.

here the diff to this PR which attempts to use osgi modules:

Details
diff --git a/ide/o.eclipse.jgit/build.xml b/ide/o.eclipse.jgit/build.xml
index ee6dc3c..93944ef 100644
--- a/ide/o.eclipse.jgit/build.xml
+++ b/ide/o.eclipse.jgit/build.xml
@@ -21,4 +21,6 @@
 -->
 <project name="ide/o.eclipse.jgit" default="build" basedir=".">
     <import file="../../nbbuild/templates/projectized.xml"/>
+    <!-- dissable target, wrapped osgi libs are copied into ./modules/ -->
+    <target name="jar"/>
 </project>
diff --git a/ide/o.eclipse.jgit/manifest.mf b/ide/o.eclipse.jgit/manifest.mf
index 15c0419..da52db2 100644
--- a/ide/o.eclipse.jgit/manifest.mf
+++ b/ide/o.eclipse.jgit/manifest.mf
@@ -1,6 +1 @@
-Manifest-Version: 1.0
-AutoUpdate-Show-In-Client: false
 OpenIDE-Module: org.eclipse.jgit
-OpenIDE-Module-Localizing-Bundle: org/eclipse/jgit/Bundle.properties
-OpenIDE-Module-Specification-Version: 6.7
-OpenIDE-Module-Java-Dependencies: Java > 11
diff --git a/ide/o.eclipse.jgit/nbproject/project.properties b/ide/o.eclipse.jgit/nbproject/project.properties
index 74ca827..7e6798e 100644
--- a/ide/o.eclipse.jgit/nbproject/project.properties
+++ b/ide/o.eclipse.jgit/nbproject/project.properties
@@ -21,7 +21,7 @@
 is.autoload=true
 sigtest.gen.fail.on.error=false
 
-release.external/org.eclipse.jgit-6.7.0.202309050840-r.jar=modules/ext/org.eclipse.jgit-6.7.0.202309050840-r.jar
-release.external/org.eclipse.jgit.gpg.bc-6.7.0.202309050840-r.jar=modules/ext/org.eclipse.jgit.gpg.bc-6.7.0.202309050840-r.jar
-release.external/org.eclipse.jgit.lfs-6.7.0.202309050840-r.jar=modules/ext/org.eclipse.jgit.lfs-6.7.0.202309050840-r.jar
-release.external/org.eclipse.jgit.ssh.jsch-6.7.0.202309050840-r.jar=modules/ext/org.eclipse.jgit.ssh.jsch-6.7.0.202309050840-r.jar
+release.external/org.eclipse.jgit-6.7.0.202309050840-r.jar=modules/org-eclipse-jgit.jar
+release.external/org.eclipse.jgit.gpg.bc-6.7.0.202309050840-r.jar=modules/org-eclipse-jgit-gpg-bc.jar
+release.external/org.eclipse.jgit.lfs-6.7.0.202309050840-r.jar=modules/org-eclipse-jgit-lfs.jar
+release.external/org.eclipse.jgit.ssh.jsch-6.7.0.202309050840-r.jar=modules/org-eclipse-jgit-ssh.jsch.jar
diff --git a/ide/o.eclipse.jgit/nbproject/project.xml b/ide/o.eclipse.jgit/nbproject/project.xml
index d888629..4531c9d 100644
--- a/ide/o.eclipse.jgit/nbproject/project.xml
+++ b/ide/o.eclipse.jgit/nbproject/project.xml
@@ -78,86 +78,21 @@
                     </run-dependency>
                 </dependency>
             </module-dependencies>
-            <public-packages>
-                <package>org.eclipse.jgit.annotations</package>
-                <package>org.eclipse.jgit.api</package>
-                <package>org.eclipse.jgit.api.errors</package>
-                <package>org.eclipse.jgit.attributes</package>
-                <package>org.eclipse.jgit.blame</package>
-                <package>org.eclipse.jgit.diff</package>
-                <package>org.eclipse.jgit.dircache</package>
-                <package>org.eclipse.jgit.errors</package>
-                <package>org.eclipse.jgit.events</package>
-                <package>org.eclipse.jgit.fnmatch</package>
-                <package>org.eclipse.jgit.gitrepo</package>
-                <package>org.eclipse.jgit.gitrepo.internal</package>
-                <package>org.eclipse.jgit.gpg.bc</package>
-                <package>org.eclipse.jgit.gpg.bc.internal</package>
-                <package>org.eclipse.jgit.gpg.bc.internal.keys</package>
-                <package>org.eclipse.jgit.hooks</package>
-                <package>org.eclipse.jgit.ignore</package>
-                <package>org.eclipse.jgit.ignore.internal</package>
-                <package>org.eclipse.jgit.internal</package>
-                <package>org.eclipse.jgit.internal.diff</package>
-                <package>org.eclipse.jgit.internal.diffmergetool</package>
-                <package>org.eclipse.jgit.internal.fsck</package>
-                <package>org.eclipse.jgit.internal.revwalk</package>
-                <package>org.eclipse.jgit.internal.storage.commitgraph</package>
-                <package>org.eclipse.jgit.internal.storage.dfs</package>
-                <package>org.eclipse.jgit.internal.storage.file</package>
-                <package>org.eclipse.jgit.internal.storage.io</package>
-                <package>org.eclipse.jgit.internal.storage.memory</package>
-                <package>org.eclipse.jgit.internal.storage.pack</package>
-                <package>org.eclipse.jgit.internal.storage.reftable</package>
-                <package>org.eclipse.jgit.internal.submodule</package>
-                <package>org.eclipse.jgit.internal.transport.connectivity</package>
-                <package>org.eclipse.jgit.internal.transport.http</package>
-                <package>org.eclipse.jgit.internal.transport.parser</package>
-                <package>org.eclipse.jgit.internal.transport.ssh</package>
-                <package>org.eclipse.jgit.internal.transport.ssh.jsch</package>
-                <package>org.eclipse.jgit.internal.util</package>
-                <package>org.eclipse.jgit.lfs</package>
-                <package>org.eclipse.jgit.lfs.errors</package>
-                <package>org.eclipse.jgit.lfs.internal</package>
-                <package>org.eclipse.jgit.lfs.lib</package>
-                <package>org.eclipse.jgit.lib</package>
-                <package>org.eclipse.jgit.lib.internal</package>
-                <package>org.eclipse.jgit.logging</package>
-                <package>org.eclipse.jgit.merge</package>
-                <package>org.eclipse.jgit.nls</package>
-                <package>org.eclipse.jgit.notes</package>
-                <package>org.eclipse.jgit.patch</package>
-                <package>org.eclipse.jgit.revplot</package>
-                <package>org.eclipse.jgit.revwalk</package>
-                <package>org.eclipse.jgit.revwalk.filter</package>
-                <package>org.eclipse.jgit.storage.file</package>
-                <package>org.eclipse.jgit.storage.pack</package>
-                <package>org.eclipse.jgit.submodule</package>
-                <package>org.eclipse.jgit.transport</package>
-                <package>org.eclipse.jgit.transport.http</package>
-                <package>org.eclipse.jgit.transport.resolver</package>
-                <package>org.eclipse.jgit.transport.ssh.jsch</package>
-                <package>org.eclipse.jgit.treewalk</package>
-                <package>org.eclipse.jgit.treewalk.filter</package>
-                <package>org.eclipse.jgit.util</package>
-                <package>org.eclipse.jgit.util.io</package>
-                <package>org.eclipse.jgit.util.sha1</package>
-                <package>org.eclipse.jgit.util.time</package>
-            </public-packages>
+            <public-packages/>
             <class-path-extension>
-                <runtime-relative-path>ext/org.eclipse.jgit-6.7.0.202309050840-r.jar</runtime-relative-path>
+                <runtime-relative-path>org-eclipse-jgit.jar</runtime-relative-path>
                 <binary-origin>external/org.eclipse.jgit-6.7.0.202309050840-r.jar</binary-origin>
             </class-path-extension>
             <class-path-extension>
-                <runtime-relative-path>ext/org.eclipse.jgit.gpg.bc-6.7.0.202309050840-r.jar</runtime-relative-path>
+                <runtime-relative-path>org-eclipse-jgit-gpg-bc.jar</runtime-relative-path>
                 <binary-origin>external/org.eclipse.jgit.gpg.bc-6.7.0.202309050840-r.jar</binary-origin>
             </class-path-extension>
             <class-path-extension>
-                <runtime-relative-path>ext/org.eclipse.jgit.ssh.jsch-6.7.0.202309050840-r.jar</runtime-relative-path>
+                <runtime-relative-path>org-eclipse-jgit-ssh-jsch.jar</runtime-relative-path>
                 <binary-origin>external/org.eclipse.jgit.ssh.jsch-6.7.0.202309050840-r.jar</binary-origin>
             </class-path-extension>
             <class-path-extension>
-                <runtime-relative-path>ext/org.eclipse.jgit.lfs-6.7.0.202309050840-r.jar</runtime-relative-path>
+                <runtime-relative-path>org-eclipse-jgit-lfs.jar</runtime-relative-path>
                 <binary-origin>external/org.eclipse.jgit.lfs-6.7.0.202309050840-r.jar</binary-origin>
             </class-path-extension>
         </data>
diff --git a/ide/o.eclipse.jgit/src/org/eclipse/jgit/Bundle.properties b/ide/o.eclipse.jgit/src/org/eclipse/jgit/Bundle.properties
deleted file mode 100644
index 53bacf5..0000000
--- a/ide/o.eclipse.jgit/src/org/eclipse/jgit/Bundle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-OpenIDE-Module-Name=JGit Libraries

@neilcsmith-net

Copy link
Copy Markdown
Member

I don't really want to do that tbh. would a normal lib wrapper module be ok, like currently in this PR? I suppose we could make this a friend API and/or keep the sig check disabled.

Why would they be a friend API? That's not compatible. You'd need to replicate the exporting of packages from the OSGi manifest, surely?

The sig files probably need an update if 6.7 isn't API compatible. It should then be a useful diff of what has actually changed.

I don't know what other compatibility implications switching from OSGi to NB module here would raise? I would be inclined more towards the multiple OSGi approach if that actually works in the NetBeans container?

@mbien

mbien commented Oct 5, 2023

Copy link
Copy Markdown
Member Author

Why would they be a friend API? That's not compatible. You'd need to replicate the exporting of packages from the OSGi manifest, surely?

NB bundling third party libs as public API is only asking for trouble in my opinion. e.g see the lucene situation where the editor is stuck at 3.6. since updating that would be likely time consuming (clone the modules, deprecate the old interface etc), while the maven indexer modules which wrap the lib for internal consumption only, can update any time they want with no extra steps.

I haven't actually checked if the direct or indirect users of jgit are exposing the lib in their API, if they do, it would be already too late to hide the lib wrapper.

I don't know what other compatibility implications switching from OSGi to NB module here would raise

anyone is welcome to take over this PR and do the modularization part. I was only really interested in helping out with the API migration (which turned out easier than expected) and fixing some issues, e.g #6528

@mbien
mbien marked this pull request as draft October 5, 2023 08:46
@neilcsmith-net

neilcsmith-net commented Oct 5, 2023 •

Copy link
Copy Markdown
Member

NB bundling third party libs as public API is only asking for trouble in my opinion.

And NB bundling third party libs as friends APIs can be equally problematic (eg. using JNA in RCP used to be a problem). Not all libs work well with multiple versions in one system.

Better IMO to use major release version for breaking upstream changes, and try to limit how much our own exported APIs are impacted by the choice of upstream library version.

I have no concern with dropping OSGi if it won't cause problems elsewhere. I think the exported packages should be kept in sync, and probably bump the module major version to 6?

This should also fix #4197 - not sure what else we have that is solely library version related.

@matthiasblaesing

Copy link
Copy Markdown
Contributor

Based on this I'm trying to see if I can get the individual OSGI jars to work. It seems though, that I have to fix netigso first, as it does not expose the fact, that I'm running on JavaSE-17 and not JavaSE-1.8. I'll see what I can come up with.

@mbien

mbien commented Oct 5, 2023 •

Copy link
Copy Markdown
Member Author

Based on this I'm trying to see if I can get the individual OSGI jars to work. It seems though, that I have to fix netigso first, as it does not expose the fact, that I'm running on JavaSE-17 and not JavaSE-1.8. I'll see what I can come up with.

some of the jgit dependencies (e.g bouncycastle) are multi release jars. Not sure how the osgi classloading works in the dusty container NB uses, the regular NB module classloader should do fine by now since this was fixed in past.

but since you mentioned netbinox, this is based on patched up kepler (from what I see here) which didn't even have support for JDK 8 yet. (multi release jars are java 9)

edit: since I don't know the details of the module loading impl, the safest approach would be to simply use a lib wrapper module since we know that it works as demonstrated in other modules. But this is just my 2c - no strong opinion here.

@mbien

mbien commented Oct 8, 2023

Copy link
Copy Markdown
Member Author

closing in favor of #6544

@mbien mbien closed this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) git [ci] enable versioning job Upgrade Library Library (Dependency) Upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileAlreadyExistsException (JGit issue - upgrade req.)

4 participants