refactor: extract sigstore-common module - #1288
aaronlew02 wants to merge 1 commit into
Conversation
c0f9d4c to
1dbe606
Compare
|
Given that we just introduced module information, can we make sure this is module safe? packages should not be repeated across modules, etc. |
1dbe606 to
93b56e7
Compare
|
@loosebazooka I've moved all packages in |
93b56e7 to
b02c8f6
Compare
b02c8f6 to
c7e45bf
Compare
|
So once we arrange things, we need to make sure sigstore-common is built and published locally when needed and also is still part of the public release.
Some minor inconsistencies discovered by gemini:
|
c7e45bf to
8192495
Compare
|
There was a problem hiding this comment.
It looks like GrpcChannels could be package private to the fulcio client now.
There was a problem hiding this comment.
Correct. Made GrpcChannels and its methods package-private.
| forbiddenApis { | ||
| signaturesFiles = files("$rootDir/config/forbiddenApis.txt") | ||
| suppressAnnotations = setOf("dev.sigstore.common.forbidden.SuppressForbidden") | ||
| ignoreSignaturesOfMissingClasses = true |
There was a problem hiding this comment.
Lets remove this actually. Looking at it again, I feel like it leaves us open to making mistakes. We can just have separate signature files for common.
There was a problem hiding this comment.
Removed and added separate signature files for :sigstore-common.
| val sigstoreVersion = "2.4.0-SNAPSHOT" | ||
|
|
||
| dependencies { | ||
| implementation("dev.sigstore:sigstore-common:$sigstoreVersion") |
There was a problem hiding this comment.
can we check that this actually fails? like if we add a conflicting package somewhere and then checking for failure?
There was a problem hiding this comment.
I had Gemini run two tests, both of which I verified:
Test 1:
- Two minimal JARs were compiled and packaged in a temporary directory:
mod1.jarwithAutomatic-Module-Name: mod.onecontaining a class in packagepkg.mod2.jarwithAutomatic-Module-Name: mod.twocontaining a class in packagepkg.
- Created a modular consumer project with a
module-info.javarequiring both:module app { requires mod.one; requires mod.two; }
- Running
javac -p mod1.jar:mod2.jar module-info.java Main.javafailed with:error: the unnamed module reads package pkg from both mod.two and mod.one error: module mod.two reads package pkg from both mod.one and mod.two error: module mod.one reads package pkg from both mod.two and mod.one error: module app reads package pkg from both mod.one and mod.two
Test 2:
- A temporary file was created at
sandbox/module-test/src/main/java/dev/sigstore/Conflict.javacontaining:package dev.sigstore; public class Conflict {}
- Because
sandbox/module-test/src/main/java/module-info.javaspecifiesrequires dev.sigstore;, defining a class in packagedev.sigstorecauses a package collision. - Running
./gradlew :module-test:compileJavainsandbox/failed as expected:error: package exists in another module: dev.sigstore package dev.sigstore; ^
| @@ -50,7 +49,6 @@ public static UnsuccessfulResponseHandler newUnsuccessfulResponseHandler() { | |||
| return new UnsuccessfulResponseHandler(Sleeper.DEFAULT, new ExponentialBackOff()); | |||
| } | |||
|
|
|||
| @VisibleForTesting | |||
There was a problem hiding this comment.
perhaps a comment here if we're removing the annotation
There was a problem hiding this comment.
Added a comment.
| } | ||
|
|
||
| dependencies { | ||
| api(project(":sigstore-common")) |
There was a problem hiding this comment.
I think it shouldn't be api if we can avoid it, depending on what we need to expose to the users of sigstore-java, maybe stuff that needs to be exposed should be in it's own lib (like http). So http is "api" and maybe the rest of common is just "implementation"
There was a problem hiding this comment.
For now, I'd like to keep it api, to keep this PR within scope, but I agree that things like HTTP should be extracted into their own modules.
| var reposBuilder = new StringBuilder(); | ||
| var pluginReposBuilder = new StringBuilder(); | ||
| int idx = 0; | ||
| for (String pathStr : |
There was a problem hiding this comment.
I can't tell why this change is necessary? Any insight?
There was a problem hiding this comment.
Each module publishes its own build/local-maven-repo directory, and these are split by a path separator (see here).
|
|
||
| testImplementation(project(":sigstore-testkit")) | ||
|
|
||
| sigstoreJavaRuntime(project(":sigstore-common")) |
There was a problem hiding this comment.
this seems like it should've been pulled in transitively through sigstore-java?
There was a problem hiding this comment.
sigstoreJavaRuntime only resolves directory-type artifacts (see here), for which Gradle does not traverse transitively.
Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
8192495 to
e1048e2
Compare
Summary
This change extracts common utilities (including HTTP and JSON utilities) from
sigstore-javainto a new:sigstore-commonmodule.