Skip to content

Commit b78c9a0

Browse files
committed
Make module-info compilation CI-safe
- Separate CI build (JDK 11) from test phases (JDK 8/11/17) - Centralize module-info compilation config in parent POM - Use two-stage compilation: module-info with release=9, base code with Java 8 - Maintain JDK 8 runtime compatibility via multi-release JAR structure
1 parent 2659b4f commit b78c9a0

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ on:
99
- master
1010

1111
jobs:
12-
test:
13-
name: "JDK ${{ matrix.java }}"
14-
strategy:
15-
matrix:
16-
java: [ 8, 11 ]
12+
build:
13+
name: 'Build with JDK 11'
1714
runs-on: ubuntu-latest
1815
steps:
1916
# Cancel any previous runs for the same branch that are still running.
@@ -23,25 +20,54 @@ jobs:
2320
access_token: ${{ github.token }}
2421
- name: 'Check out repository'
2522
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
26-
- name: 'Set up JDK ${{ matrix.java }}'
23+
- name: 'Set up JDK 11 for compilation'
2724
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
2825
with:
29-
java-version: ${{ matrix.java }}
26+
java-version: 11
3027
distribution: 'zulu'
3128
cache: 'maven'
3229
- name: 'Install'
3330
shell: bash
3431
run: mvn -B -P!standard-with-extra-repos install -U -DskipTests=true
35-
- name: 'Test'
36-
shell: bash
37-
run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true
3832
- name: 'Javadoc Test Run'
3933
shell: bash
4034
run: mvn -B -P!standard-with-extra-repos javadoc:aggregate -U
35+
- name: 'Upload build artifacts'
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: truth-jars
39+
path: |
40+
**/target/*.jar
41+
!**/target/*-sources.jar
42+
!**/target/*-javadoc.jar
43+
44+
test:
45+
name: "Test with JDK ${{ matrix.java }}"
46+
needs: build
47+
strategy:
48+
matrix:
49+
java: [ 8, 11, 17 ]
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: 'Check out repository'
53+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
54+
- name: 'Set up JDK ${{ matrix.java }} for testing'
55+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
56+
with:
57+
java-version: ${{ matrix.java }}
58+
distribution: 'zulu'
59+
cache: 'maven'
60+
- name: 'Download build artifacts'
61+
uses: actions/download-artifact@v3
62+
with:
63+
name: truth-jars
64+
- name: 'Test'
65+
shell: bash
66+
run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true
4167

4268
publish_snapshot:
4369
name: 'Publish snapshot'
44-
needs: test
70+
needs: [build, test]
4571
if: github.event_name == 'push' && github.repository == 'google/truth'
4672
runs-on: ubuntu-latest
4773
steps:
@@ -66,7 +92,7 @@ jobs:
6692
permissions:
6793
contents: write
6894
name: 'Generate latest docs'
69-
needs: test
95+
needs: [build, test]
7096
if: github.event_name == 'push' && github.repository == 'google/truth'
7197
runs-on: ubuntu-latest
7298
steps:

extensions/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@
2323
<module>liteproto</module>
2424
<module>proto</module>
2525
</modules>
26-
2726
</project>

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,15 @@
322322
</configuration>
323323
</execution>
324324
<execution>
325-
<id>default-testCompile</id>
325+
<id>base-compile</id>
326+
<goals>
327+
<goal>compile</goal>
328+
</goals>
326329
<configuration>
327-
<release>9</release>
330+
<excludes>
331+
<exclude>module-info.java</exclude>
332+
<exclude>**/super/**/*.java</exclude>
333+
</excludes>
328334
</configuration>
329335
</execution>
330336
</executions>

0 commit comments

Comments
 (0)