Bug 581767 - Consume BouncyCastle from maven instead of from Orbit?
Summary: Consume BouncyCastle from maven instead of from Orbit?
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 6.6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-03 15:04 EDT by Thomas Wolf CLA
Modified: 2023-04-24 07:05 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2023-04-03 15:04:40 EDT
Eclipse Platform has switched to using the Bouncy Castle (1.72) artifacts from maven instead of the repackaging provided by Eclipse Orbit.

Should JGit to follow suit? Using tycho >= 2.7.5 (which we do), it's possible to do so by including the maven coordinates in the target platform. Using the latest CBI TPD, it's also possible to use TPD files containing maven coordinates to create the target platforms.

I have two uncertainties:

1. Will the dash license tool be happy about this? Probably.
2. What happens when one installs EGit (which would have to change its target platform and thus its p2 repository, too) in an older Eclipse that has the Orbit versions of Bouncy Castle? The maven bundles have different bundle names; instead of "org.bouncycastle.bcpg" they use only "bcpg". Would this cause trouble?

Note that both JGit and EGit have only Import-Package for BC, no Require-Bundle. The package names in the maven artifacts are identical, but Automatic-Module-Name may be different, too.
Comment 1 Matthias Sohn CLA 2023-04-13 17:42:31 EDT
If this works with tpd files I am all in for this proposal since it allows us to continue maintaining target platforms for older Eclipse versions as we do today.

If this works for bouncycastle we should do this also for all other dependencies which already have OSGi manifests.

I don't expect a lot of issues with different bundle names since we mostly use package imports.

Do you have pointers to documentation and examples how to do this ?
Comment 2 Thomas Wolf CLA 2023-04-13 18:10:57 EDT
I have already done this locally. Hadn't found any documentation, I just looked at the TPD grammar at [1] :-). (Not too happy with that grammar, it's way too verbose for maven -- not much better than POM dependencies. Could have used a much more concise syntax using short-hand coordinates like "groupId:artifactId:version". But it does the job.)

Basically, use the latest TPD, then define for instance (this is what I did locally) a new file

  maven/bouncycastle.tpd

with contents

target "bouncycastle" with source configurePhase

maven bouncycastle
	scope = compile
	dependencyDepth = none
	missingManifest = error
	includeSources
{
	dependency {
		groupId = "org.bouncycastle"
		artifactId = "bcpg-jdk18on"
		version = "1.72.2"
	}
	dependency {
		groupId = "org.bouncycastle"
		artifactId = "bcprov-jdk18on"
		version = "1.72"
	}
	dependency {
		groupId = "org.bouncycastle"
		artifactId = "bcpkix-jdk18on"
		version = "1.72"
	}
	dependency {
		groupId = "org.bouncycastle"
		artifactId = "bcutil-jdk18on"
		version = "1.72"
	}
}

Then remove the Orbit BC bundles from orbit/R20230302014618-2023-03.tpd, and iclude maven/bouncycastle.tpd in the top-level TPD files. Change the bundle ids in category.xml (in the p2 repo bundle) from "org.bouncycastle.bc*" to just "bc*". Regenerate target platform files. Rebuild. Done.

The thing with the different bundle names does worry me, but in the end I fear I'll just have to try installing from a locally built p2 repo into an older Eclipse to see what happens. (Probably one can't use key classes from the new maven BC with keys returned from a "BC" security provider installed by the old Orbit bundle. If both old and new bcprov are present, I do expect trouble depending on which one installs the security provider.)

[1] https://github.com/eclipse-cbi/targetplatform-dsl/blob/master/org.eclipse.cbi.targetplatform/src/main/java/org/eclipse/cbi/targetplatform/TargetPlatform.xtext
Comment 3 Matthias Sohn CLA 2023-04-13 19:45:35 EDT
(In reply to Thomas Wolf from comment #2)
> I have already done this locally. Hadn't found any documentation, I just
> looked at the TPD grammar at [1] :-). (Not too happy with that grammar, it's
> way too verbose for maven -- not much better than POM dependencies. Could
> have used a much more concise syntax using short-hand coordinates like
> "groupId:artifactId:version". But it does the job.)
> 
> Basically, use the latest TPD, then define for instance (this is what I did
> locally) a new file
> 
>   maven/bouncycastle.tpd

I'd name this something like maven/dependencies.tpd and later add all the other dependencies we can directly consume from maven

> 
> with contents
> 
> target "bouncycastle" with source configurePhase
> 
> maven bouncycastle
> 	scope = compile
> 	dependencyDepth = none
> 	missingManifest = error
> 	includeSources
> {
> 	dependency {
> 		groupId = "org.bouncycastle"
> 		artifactId = "bcpg-jdk18on"
> 		version = "1.72.2"
> 	}
> 	dependency {
> 		groupId = "org.bouncycastle"
> 		artifactId = "bcprov-jdk18on"
> 		version = "1.72"
> 	}
> 	dependency {
> 		groupId = "org.bouncycastle"
> 		artifactId = "bcpkix-jdk18on"
> 		version = "1.72"
> 	}
> 	dependency {
> 		groupId = "org.bouncycastle"
> 		artifactId = "bcutil-jdk18on"
> 		version = "1.72"
> 	}
> }
> 
> Then remove the Orbit BC bundles from orbit/R20230302014618-2023-03.tpd, and
> iclude maven/bouncycastle.tpd in the top-level TPD files. Change the bundle
> ids in category.xml (in the p2 repo bundle) from "org.bouncycastle.bc*" to
> just "bc*". Regenerate target platform files. Rebuild. Done.
> 
> The thing with the different bundle names does worry me, but in the end I
> fear I'll just have to try installing from a locally built p2 repo into an
> older Eclipse to see what happens. (Probably one can't use key classes from
> the new maven BC with keys returned from a "BC" security provider installed
> by the old Orbit bundle. If both old and new bcprov are present, I do expect
> trouble depending on which one installs the security provider.)
> 
> [1]
> https://github.com/eclipse-cbi/targetplatform-dsl/blob/master/org.eclipse.
> cbi.targetplatform/src/main/java/org/eclipse/cbi/targetplatform/
> TargetPlatform.xtext
Comment 4 Eclipse Genie CLA 2023-04-15 15:42:49 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/201348