Skip to content

Commit 5e523b6

Browse files
committed
ci: extract project version and use it in the Maven example build
1 parent 96342ba commit 5e523b6

File tree

2 files changed

+23
-15
lines changed
  • .github/workflows
  • jsonschema2pojo-maven-plugin/example

2 files changed

+23
-15
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
java: [8]
1919
max-parallel: 5
20-
name: JDK ${{ matrix.java }} | Project
20+
name: Test JDK ${{ matrix.java }}
2121
steps:
2222
- uses: actions/checkout@v3
2323

@@ -47,20 +47,20 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
build-java: [8]
50+
project-java-target: [8]
5151
run:
5252
- { java: 8, gradle: '7.6.4' } # AGP Java 8 => Gradle 7.6.4 (MavenPlugin legacy)
53-
name: JDK ${{ matrix.build-java }} | Example Gradle (Android) | run on Java ${{ matrix.run.java }}
53+
name: JDK ${{ project-java-target }} | Example Gradle (Android)
5454
steps:
5555
- uses: actions/checkout@v3
5656

5757
- name: Install Android SDK
5858
uses: malinskiy/action-android/install-sdk@release/0.1.1
5959

60-
- name: Download m2 org.jsonschema2pojo (matching build-java)
60+
- name: Download m2 org.jsonschema2pojo
6161
uses: actions/download-artifact@v4
6262
with:
63-
name: m2-jsonschema2pojo-jdk${{ matrix.build-java }}
63+
name: m2-jsonschema2pojo-jdk${{ matrix.project-java-target }}
6464
path: ~/.m2/repository/org/jsonschema2pojo
6565

6666
- uses: actions/setup-java@v3
@@ -84,17 +84,17 @@ jobs:
8484
strategy:
8585
fail-fast: false
8686
matrix:
87-
build-java: [8]
87+
project-java-target: [8]
8888
run:
8989
- { java: 8, gradle: '8.9' }
90-
name: JDK ${{ matrix.build-java }} | Example Gradle (Java) | run on Java ${{ matrix.run.java }}
90+
name: JDK ${{ project-java-target }} | Example Gradle (Java)
9191
steps:
9292
- uses: actions/checkout@v3
9393

94-
- name: Download m2 org.jsonschema2pojo (matching build-java)
94+
- name: Download m2 org.jsonschema2pojo
9595
uses: actions/download-artifact@v4
9696
with:
97-
name: m2-jsonschema2pojo-jdk${{ matrix.build-java }}
97+
name: m2-jsonschema2pojo-jdk${{ matrix.project-java-target }}
9898
path: ~/.m2/repository/org/jsonschema2pojo
9999

100100
- uses: actions/setup-java@v3
@@ -118,17 +118,17 @@ jobs:
118118
strategy:
119119
fail-fast: false
120120
matrix:
121-
build-java: [8]
121+
project-java-target: [8]
122122
run:
123123
- { java: 8, maven: '3.9.9' }
124-
name: JDK ${{ matrix.build-java }} | Example Maven | run on Java ${{ matrix.run.java }}
124+
name: JDK ${{ project-java-target }} | Example Maven (Java)
125125
steps:
126126
- uses: actions/checkout@v3
127127

128-
- name: Download m2 org.jsonschema2pojo (matching build-java)
128+
- name: Download m2 org.jsonschema2pojo
129129
uses: actions/download-artifact@v4
130130
with:
131-
name: m2-jsonschema2pojo-jdk${{ matrix.build-java }}
131+
name: m2-jsonschema2pojo-jdk${{ matrix.project-java-target }}
132132
path: ~/.m2/repository/org/jsonschema2pojo
133133

134134
- uses: actions/setup-java@v3
@@ -141,6 +141,10 @@ jobs:
141141
with:
142142
maven-version: ${{ matrix.run.maven }}
143143

144+
- name: Extract project version
145+
id: get_version
146+
run: echo "project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
147+
144148
- name: Build Maven example
145149
working-directory: jsonschema2pojo-maven-plugin/example
146-
run: mvn package
150+
run: mvn -Djsonschema2pojo.version="${{ steps.get_version.outputs.project_version }}" package

jsonschema2pojo-maven-plugin/example/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<artifactId>maven-jsonschema2pojo-example</artifactId>
66
<version>0.0.1-SNAPSHOT</version>
77

8+
<properties>
9+
<jsonschema2pojo.version>1.2.1</jsonschema2pojo.version>
10+
</properties>
11+
812
<build>
913
<plugins>
1014
<plugin>
@@ -17,7 +21,7 @@
1721
<plugin>
1822
<groupId>org.jsonschema2pojo</groupId>
1923
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
20-
<version>1.2.1</version>
24+
<version>${jsonschema2pojo.version}</version>
2125
<configuration>
2226
<sourceDirectory>${basedir}/schema</sourceDirectory>
2327
<targetPackage>com.example.types</targetPackage>

0 commit comments

Comments
 (0)