@@ -182,33 +182,44 @@ jobs:
182182 text = re.sub(r"(<project\b[^>]*>\s*)", r"\1 <modelVersion>4.0.0</modelVersion>\n", text, count=1, flags=re.S)
183183 return text
184184
185+ def maven_property(name):
186+ return "${" + name + "}"
187+
185188 junit_version = property_value("junit.version")
186189 log4j2_version = property_value("log4j2.version")
190+ exec_maven_plugin_version = property_value("exec-maven-plugin.version")
191+ spotbugs_maven_plugin_version = property_value("spotbugs-maven-plugin.version")
192+ maven_jar_plugin_version = property_value("maven-jar-plugin.version")
193+ maven_source_plugin_version = property_value("maven-source-plugin.version")
194+ maven_javadoc_plugin_version = property_value("maven-javadoc-plugin.version")
195+ maven_surefire_plugin_version = property_value("maven-surefire-plugin.version")
196+ maven_gpg_plugin_version = property_value("maven-gpg-plugin.version")
197+ maven_assembly_plugin_version = "3.7.1"
187198
188199 root_text = central_compatible_pom(root_text)
189200 root_text = root_text.replace("<version>${revision}</version>", f"<version>{revision}</version>", 1)
190201 root_text = re.sub(r"<revision>[^<]+</revision>", f"<revision>{revision}</revision>", root_text, count=1)
191- root_modules = """ <modules>\n <module>godot-java-code-generator</module>\n <module>godot-java-core</module>\n <module>godot-java-examples</module>\n <module>godot-java- native</module>\n </modules>\n\n"""
202+ root_modules = """ <modules>\n <module>godot-java-code-generator</module>\n <module>godot-java-core</module>\n <module>godot-java-native</module>\n </modules>\n\n"""
192203 if "<modules>" not in root_text:
193204 root_text = root_text.replace(" <licenses>", root_modules + " <licenses>", 1)
194205 root.write_text(root_text)
195206
196207 parent_with_coordinates = f""" <parent>\n <groupId>io.github.youngledo</groupId>\n <artifactId>godot-java</artifactId>\n <version>{revision}</version>\n </parent>"""
197208 for path in [
198209 Path("godot-java-code-generator/pom.xml"),
199- Path("godot-java-core/pom.xml"),
200- Path("godot-java-examples/pom.xml"),
201- Path("godot-java-native/pom.xml"),
202210 ]:
203211 text = central_compatible_pom(path.read_text())
204212 if "<parent/>" not in text:
205213 raise RuntimeError(f"Unexpected parent block in {path}")
206214 path.write_text(re.sub(r"\s*<parent/>\s*", "\n" + parent_with_coordinates + "\n\n", text, count=1))
207215
208216 core = Path("godot-java-core/pom.xml")
209- core_text = core.read_text()
217+ core_text = central_compatible_pom(core.read_text())
218+ if "<parent/>" not in core_text:
219+ raise RuntimeError("Unexpected parent block in godot-java-core/pom.xml")
220+ core_text = re.sub(r"\s*<parent/>\s*", "\n", core_text, count=1)
210221 core_coordinates = f""" <groupId>io.github.youngledo</groupId>\n <version>{revision}</version>\n"""
211- core_text = core_text.replace(" <artifactId>godot-java-core</artifactId>", core_coordinates + " <artifactId>godot-java-core</artifactId>", 1)
222+ core_text = re.sub(r"(\s*) <artifactId>godot-java-core</artifactId>", "\n" + core_coordinates + r"\1 <artifactId>godot-java-core</artifactId>", core_text, count= 1)
212223 core_metadata = """
213224
214225 <url>https://github.com/youngledo/godot-java</url>
@@ -237,19 +248,63 @@ jobs:
237248 core_text = core_text.replace(""" <artifactId>junit-jupiter</artifactId>""", f""" <artifactId>junit-jupiter</artifactId>\n <version>{junit_version}</version>\n <scope>test</scope>""", 1)
238249 core_text = core_text.replace(""" <artifactId>log4j-api</artifactId>""", f""" <artifactId>log4j-api</artifactId>\n <version>{log4j2_version}</version>""", 1)
239250 core_text = core_text.replace(""" <artifactId>log4j-core</artifactId>""", f""" <artifactId>log4j-core</artifactId>\n <version>{log4j2_version}</version>\n <scope>runtime</scope>""", 1)
251+ core_text = core_text.replace("${exec-maven-plugin.version}", exec_maven_plugin_version)
252+ core_text = core_text.replace("${spotbugs-maven-plugin.version}", spotbugs_maven_plugin_version)
253+ for artifact_id, version in [
254+ ("maven-jar-plugin", maven_jar_plugin_version),
255+ ("maven-surefire-plugin", maven_surefire_plugin_version),
256+ ("maven-source-plugin", maven_source_plugin_version),
257+ ("maven-javadoc-plugin", maven_javadoc_plugin_version),
258+ ]:
259+ marker = f" <artifactId>{artifact_id}</artifactId>"
260+ replacement = marker + f"\n <version>{version}</version>"
261+ if marker in core_text and replacement not in core_text:
262+ core_text = core_text.replace(marker, replacement, 1)
263+ core_text = core_text.replace(" </plugins>", f""" <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-gpg-plugin</artifactId>\n <version>{maven_gpg_plugin_version}</version>\n <configuration>\n <skip>{maven_property("gpg.skip")}</skip>\n <passphrase>{maven_property("env.GPG_PASSPHRASE")}</passphrase>\n <gpgArguments>\n <arg>--pinentry-mode</arg>\n <arg>loopback</arg>\n </gpgArguments>\n </configuration>\n <executions>\n <execution>\n <id>sign-artifacts</id>\n <phase>verify</phase>\n <goals>\n <goal>sign</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>""", 1)
240264 core.write_text(core_text)
241265
242- examples = Path("godot-java-examples/pom.xml")
243- examples_text = examples.read_text()
244- examples_text = examples_text.replace(""" <artifactId>godot-java-core</artifactId>""", f""" <artifactId>godot-java-core</artifactId>\n <version>{revision}</version>""", 1)
245- examples.write_text(examples_text)
266+ native = Path("godot-java-native/pom.xml")
267+ native_text = central_compatible_pom(native.read_text())
268+ if "<parent/>" not in native_text:
269+ raise RuntimeError("Unexpected parent block in godot-java-native/pom.xml")
270+ native_text = re.sub(r"\s*<parent/>\s*", "\n", native_text, count=1)
271+ native_coordinates = f""" <groupId>io.github.youngledo</groupId>\n <version>{revision}</version>\n"""
272+ native_text = re.sub(r"(\s*)<artifactId>godot-java-native</artifactId>", "\n" + native_coordinates + r"\1<artifactId>godot-java-native</artifactId>", native_text, count=1)
273+ native_metadata = """
274+
275+ <url>https://github.com/youngledo/godot-java</url>
276+
277+ <licenses>
278+ <license>
279+ <name>Apache-2.0</name>
280+ <url>https://www.apache.org/licenses/LICENSE-2.0</url>
281+ <distribution>repo</distribution>
282+ </license>
283+ </licenses>
284+
285+ <developers>
286+ <developer>
287+ <id>youngledo</id>
288+ </developer>
289+ </developers>
290+
291+ <scm>
292+ <connection>scm:git:git@github.com:youngledo/godot-java.git</connection>
293+ <developerConnection>scm:git:git@github.com:youngledo/godot-java.git</developerConnection>
294+ <url>https://github.com/youngledo/godot-java</url>
295+ </scm>"""
296+ native_text = native_text.replace(" <description>Platform native GDExtension library for godot-java</description>", " <description>Platform native GDExtension library for godot-java</description>" + native_metadata, 1)
297+ native_text = native_text.replace(""" <artifactId>maven-assembly-plugin</artifactId>""", f""" <artifactId>maven-assembly-plugin</artifactId>\n <version>{maven_assembly_plugin_version}</version>""", 1)
298+ native_text = native_text.replace(" </plugins>", f""" <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-gpg-plugin</artifactId>\n <version>{maven_gpg_plugin_version}</version>\n <configuration>\n <skip>{maven_property("gpg.skip")}</skip>\n <passphrase>{maven_property("env.GPG_PASSPHRASE")}</passphrase>\n <gpgArguments>\n <arg>--pinentry-mode</arg>\n <arg>loopback</arg>\n </gpgArguments>\n </configuration>\n <executions>\n <execution>\n <id>sign-artifacts</id>\n <phase>verify</phase>\n <goals>\n <goal>sign</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>""", 1)
299+ native.write_text(native_text)
300+
246301 PY
247302
248303 - name : Build and publish
249304 env :
250305 CENTRAL_USERNAME : ${{ secrets.CENTRAL_USERNAME }}
251306 CENTRAL_TOKEN : ${{ secrets.CENTRAL_TOKEN }}
252- run : ./mvnw deploy -P release -Drevision="$REVISION" -Dgodot.java.native.attach.dir="$PWD/dist/native" -DskipTests -B
307+ run : ./mvnw deploy -pl godot-java-core,godot-java-native -am - P release -Drevision="$REVISION" -Dgodot.java.native.attach.dir="$PWD/dist/native" -DskipTests -B
253308
254309 - name : Attach native fallback artifacts to GitHub Release
255310 uses : softprops/action-gh-release@v2
0 commit comments