Skip to content

Commit 977ff7a

Browse files
committed
Add build for artifact with bridge methods
1 parent 8968198 commit 977ff7a

File tree

5 files changed

+102
-19
lines changed

5 files changed

+102
-19
lines changed

.github/workflows/maven-build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ jobs:
6060
# running install site seems to more closely imitate real site deployment,
6161
# more likely to prevent failed deployment
6262
run: mvn -B clean install site -DskipTests --file pom.xml
63+
test-bridged:
64+
name: build-and-test Bridged (Java 17)
65+
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails
66+
needs: build
67+
runs-on: ubuntu-latest
68+
strategy:
69+
fail-fast: true
70+
steps:
71+
- uses: actions/checkout@v4
72+
- name: Set up JDK
73+
uses: actions/setup-java@v4
74+
with:
75+
java-version: 17
76+
distribution: 'temurin'
77+
cache: 'maven'
78+
- name: Maven Install (skipTests)
79+
env:
80+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
81+
#skipping japicmp check for bridged artifact until after next release
82+
run: mvn -B clean install -Djapicmp.skip=true -Pbridged -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
6383
test:
6484
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
6585
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails

pom.xml

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.kohsuke</groupId>
5-
<artifactId>github-api</artifactId>
5+
<artifactId>${github-api.artifactId}</artifactId>
66
<version>2.0-rc.2-SNAPSHOT</version>
77
<name>GitHub API for Java</name>
88
<description>GitHub API for Java</description>
@@ -62,6 +62,7 @@
6262
</distributionManagement>
6363

6464
<properties>
65+
<github-api.artifactId>github-api</github-api.artifactId>
6566
<hamcrest.version>3.0</hamcrest.version>
6667
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
6768
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
@@ -306,6 +307,18 @@
306307
</testResources>
307308
<pluginManagement>
308309
<plugins>
310+
<plugin>
311+
<groupId>com.infradna.tool</groupId>
312+
<artifactId>bridge-method-injector</artifactId>
313+
<version>1.30</version>
314+
<executions>
315+
<execution>
316+
<goals>
317+
<goal>process</goal>
318+
</goals>
319+
</execution>
320+
</executions>
321+
</plugin>
309322
<plugin>
310323
<groupId>org.apache.maven.plugins</groupId>
311324
<artifactId>maven-gpg-plugin</artifactId>
@@ -328,7 +341,10 @@
328341
</configuration>
329342
</plugin>
330343
<plugin>
331-
<groupId>org.apache.maven.plugins</groupId>
344+
<artifactId>maven-resources-plugin</artifactId>
345+
<version>3.3.1</version>
346+
</plugin>
347+
<plugin>
332348
<artifactId>maven-source-plugin</artifactId>
333349
<version>3.3.1</version>
334350
</plugin>
@@ -563,18 +579,6 @@
563579
</execution>
564580
</executions>
565581
</plugin>
566-
<plugin>
567-
<groupId>com.infradna.tool</groupId>
568-
<artifactId>bridge-method-injector</artifactId>
569-
<version>1.30</version>
570-
<executions>
571-
<execution>
572-
<goals>
573-
<goal>process</goal>
574-
</goals>
575-
</execution>
576-
</executions>
577-
</plugin>
578582
<plugin>
579583
<artifactId>maven-compiler-plugin</artifactId>
580584
<version>3.13.0</version>
@@ -635,6 +639,9 @@
635639
<artifactId>maven-surefire-plugin</artifactId>
636640
<configuration>
637641
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
642+
<systemPropertyVariables>
643+
<test.projectArtifactId>${project.artifactId}</test.projectArtifactId>
644+
</systemPropertyVariables>
638645
</configuration>
639646
<executions>
640647
<execution>
@@ -815,6 +822,42 @@
815822
</plugins>
816823
</build>
817824
</profile>
825+
<profile>
826+
<id>bridged</id>
827+
<properties>
828+
<!-- Only fail code coverage on non-windows machines -->
829+
<github-api.artifactId>github-api-bridged</github-api.artifactId>
830+
</properties>
831+
<build>
832+
<plugins>
833+
<plugin>
834+
<groupId>com.infradna.tool</groupId>
835+
<artifactId>bridge-method-injector</artifactId>
836+
</plugin>
837+
<plugin>
838+
<artifactId>maven-resources-plugin</artifactId>
839+
<executions>
840+
<execution>
841+
<id>copy-bridged-resources</id>
842+
<goals>
843+
<goal>copy-resources</goal>
844+
</goals>
845+
<!-- here the phase you need -->
846+
<phase>validate</phase>
847+
<configuration>
848+
<outputDirectory>${basedir}/target/classes/META-INF/native-image/org.kohsuke/${github-api.artifactId}</outputDirectory>
849+
<resources>
850+
<resource>
851+
<directory>src/main/resources/META-INF/native-image/org.kohsuke/github-api</directory>
852+
</resource>
853+
</resources>
854+
</configuration>
855+
</execution>
856+
</executions>
857+
</plugin>
858+
</plugins>
859+
</build>
860+
</profile>
818861
<profile>
819862
<id>ci-non-windows</id>
820863
<activation>

src/test/java/org/kohsuke/github/AotIntegrationTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ public AotIntegrationTest() {
3939
*/
4040
@Test
4141
public void testIfAllRequiredClassesAreRegisteredForAot() throws IOException {
42+
String artifactId = System.getProperty("test.projectArtifactId", "default");
43+
4244
Stream<String> providedReflectionConfigStreamOfNames = readAotConfigToStreamOfClassNames(
43-
"./target/classes/META-INF/native-image/org.kohsuke/github-api/reflect-config.json");
45+
"./target/classes/META-INF/native-image/org.kohsuke/" + artifactId + "/reflect-config.json");
4446
Stream<String> providedNoReflectStreamOfNames = Files
4547
.lines(Path.of("./target/test-classes/no-reflect-and-serialization-list"));
4648
Stream<String> providedSerializationStreamOfNames = readAotConfigToStreamOfClassNames(
47-
"./target/classes/META-INF/native-image/org.kohsuke/github-api/serialization-config.json");
49+
"./target/classes/META-INF/native-image/org.kohsuke/" + artifactId + "/serialization-config.json");
4850
Stream<String> providedAotConfigClassNamesPart = Stream
4951
.concat(providedSerializationStreamOfNames,
5052
Stream.concat(providedReflectionConfigStreamOfNames, providedNoReflectStreamOfNames))
@@ -53,9 +55,11 @@ public void testIfAllRequiredClassesAreRegisteredForAot() throws IOException {
5355
.collect(Collectors.toList());
5456

5557
Stream<String> generatedReflectConfigStreamOfClassNames = readAotConfigToStreamOfClassNames(
56-
"./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json");
58+
"./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/" + artifactId
59+
+ "/reflect-config.json");
5760
Stream<String> generatedSerializationStreamOfNames = readAotConfigToStreamOfClassNames(
58-
"./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json");
61+
"./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/" + artifactId
62+
+ "/serialization-config.json");
5963
Stream<String> generatedAotConfigClassNames = Stream.concat(generatedReflectConfigStreamOfClassNames,
6064
generatedSerializationStreamOfNames);
6165

src/test/java/org/kohsuke/github/BridgeMethodTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public void testBridgeMethods() {
4040
// verifyBridgeMethods(new GHCommit(), "getAuthor", GHCommit.GHAuthor.class, GitUser.class);
4141
// verifyBridgeMethods(new GHCommit(), "getCommitter", GHCommit.GHAuthor.class, GitUser.class);
4242

43+
String artifactId = System.getProperty("test.projectArtifactId", "default");
44+
// Only run these tests when building the "bridged" artifact
45+
org.junit.Assume.assumeThat(artifactId, equalTo("github-api-bridged"));
46+
4347
verifyBridgeMethods(GHAppInstallation.class, "getSuspendedAt", Date.class, Instant.class);
4448
verifyBridgeMethods(GHAppInstallationToken.class, "getExpiresAt", Date.class, Instant.class);
4549
verifyBridgeMethods(GHArtifact.class, "getExpiresAt", Date.class, Instant.class);

src/test/resources/reflection-and-serialization-test-error-message

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
The class "%1$s" needs to be configured or excluded for reflection / serialization and was not mentioned in one of the following resources:
22

3+
Please do one of the following:
4+
1. add "%1$s" to serialization.json and / or reflect-config.json
5+
2. add "%1$s" to no-reflect-and-serialization-list
6+
7+
DO NOT do both.
8+
9+
Option 1:
10+
The class is serialized or reflected over. Includes "GH*" classes the are populated using Jackson.
11+
Does not include Builders and other classes that are only used locally.
12+
313
src/main/resources/META-INF/reflect-config.json - example:
414

515
{
@@ -24,10 +34,12 @@ src/main/resources/META-INF/serialization.json - example:
2434
"name": "%1$s"
2535
}
2636

37+
Option 2:
38+
The class is not serialized or reflected over. This is less common.
39+
2740
src/test/resources/no-reflect-and-serialization-list - example:
2841

2942
%1$s
3043

31-
Please add it to either no-reflect-and-serialization-list or to serialization.json and / or reflect-config.json
3244

3345

0 commit comments

Comments
 (0)