You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by sn...@apache.org on 2025/03/24 15:36:33 UTC
(polaris) branch main updated: Add zip+tar to publishable artifacts and add a `run.sh` script (#1082)
This is an automated email from the ASF dual-hosted git repository.
snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new a0bf7e319 Add zip+tar to publishable artifacts and add a `run.sh` script (#1082)
a0bf7e319 is described below
commit a0bf7e319247a9060508b4d7819762d0d51d163e
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Mon Mar 24 16:36:29 2025 +0100
Add zip+tar to publishable artifacts and add a `run.sh` script (#1082)
Adds the tar+zip distribution archives as publishable artifacts to Maven publication.
Also updates polaris-quarkus-admin to build as a "fast-jar" instead of an "uber-jar".
---
gradle/projects.main.properties | 1 +
quarkus/admin/build.gradle.kts | 64 +++++++++++++++++++++++++++----------
quarkus/run-script/build.gradle.kts | 36 +++++++++++++++++++++
quarkus/run-script/scripts/run.sh | 39 ++++++++++++++++++++++
quarkus/server/build.gradle.kts | 55 ++++++++++++++++++++++++++++---
5 files changed, 174 insertions(+), 21 deletions(-)
diff --git a/gradle/projects.main.properties b/gradle/projects.main.properties
index 91c9ff607..3904dd06e 100644
--- a/gradle/projects.main.properties
+++ b/gradle/projects.main.properties
@@ -30,6 +30,7 @@ polaris-quarkus-service=quarkus/service
polaris-quarkus-server=quarkus/server
polaris-quarkus-spark-tests=quarkus/spark-tests
polaris-quarkus-admin=quarkus/admin
+polaris-quarkus-run-script=quarkus/run-script
polaris-eclipselink=extension/persistence/eclipselink
polaris-jpa-model=extension/persistence/jpa-model
polaris-tests=integration-tests
diff --git a/quarkus/admin/build.gradle.kts b/quarkus/admin/build.gradle.kts
index 0d11b0c70..cbad25e10 100644
--- a/quarkus/admin/build.gradle.kts
+++ b/quarkus/admin/build.gradle.kts
@@ -28,6 +28,14 @@ plugins {
id("distribution")
}
+val runScript by configurations.creating { description = "Used to reference the run.sh script" }
+
+val distributionZip by
+ configurations.creating { description = "Used to reference the distribution zip" }
+
+val distributionTar by
+ configurations.creating { description = "Used to reference the distribution tarball" }
+
dependencies {
implementation(project(":polaris-core"))
implementation(project(":polaris-version"))
@@ -53,10 +61,12 @@ dependencies {
testRuntimeOnly(project(":polaris-eclipselink"))
testRuntimeOnly("org.postgresql:postgresql")
+
+ runScript(project(":polaris-quarkus-run-script", "runScript"))
}
quarkus {
- quarkusBuildProperties.put("quarkus.package.type", "uber-jar")
+ quarkusBuildProperties.put("quarkus.package.type", "fast-jar")
// Pull manifest attributes from the "main" `jar` task to get the
// release-information into the jars generated by Quarkus.
quarkusBuildProperties.putAll(
@@ -72,28 +82,48 @@ quarkus {
)
}
-publishing {
- publications {
- named<MavenPublication>("maven") {
- val quarkusBuild = tasks.getByName<QuarkusBuild>("quarkusBuild")
- artifact(quarkusBuild.runnerJar) {
- classifier = "runner"
- builtBy(quarkusBuild)
- }
+distributions {
+ main {
+ contents {
+ from(runScript)
+ from(project.layout.buildDirectory.dir("quarkus-app"))
+ from("../../NOTICE")
+ from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
}
}
}
-tasks.named("distZip") { dependsOn("quarkusBuild") }
+val quarkusBuild = tasks.named<QuarkusBuild>("quarkusBuild")
-tasks.named("distTar") { dependsOn("quarkusBuild") }
+val distTar =
+ tasks.named<Tar>("distTar") {
+ dependsOn(quarkusBuild)
+ // Trigger resolution (and build) of the run-script artifact
+ inputs.files(runScript)
+ compression = Compression.GZIP
+ }
-distributions {
- main {
- contents {
- from("../../NOTICE")
- from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
- from(project.layout.buildDirectory) { include("polaris-quarkus-admin-*-runner.jar") }
+val distZip =
+ tasks.named<Zip>("distZip") {
+ dependsOn(quarkusBuild)
+ // Trigger resolution (and build) of the run-script artifact
+ inputs.files(runScript)
+ }
+
+// Expose runnable jar via quarkusRunner configuration for integration-tests that require the
+// server.
+artifacts {
+ add(distributionTar.name, provider { distTar.get().archiveFile }) { builtBy(distTar) }
+ add(distributionZip.name, provider { distZip.get().archiveFile }) { builtBy(distZip) }
+}
+
+afterEvaluate {
+ publishing {
+ publications {
+ named<MavenPublication>("maven") {
+ artifact(distTar.get().archiveFile) { builtBy(distTar) }
+ artifact(distZip.get().archiveFile) { builtBy(distZip) }
+ }
}
}
}
diff --git a/quarkus/run-script/build.gradle.kts b/quarkus/run-script/build.gradle.kts
new file mode 100644
index 000000000..315e88edd
--- /dev/null
+++ b/quarkus/run-script/build.gradle.kts
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+val runScript by
+ configurations.creating { description = "Used to provide the run.sh script" }
+
+description = "Provides run.sh script for Quarkus fast-jar for distribution tar/zip"
+
+// This is a separate project that only provides run scripts (run.sh).
+// It is a separate project, because it is not good practice to directly
+// reference files outside any project.
+//
+// Artifacts are NOT published as a Maven artifacts.
+
+artifacts {
+ add(runScript.name, project.layout.projectDirectory.file("scripts/run.sh"))
+}
+
+// Need this task to be present, there are no checks/tests in this project though
+tasks.register("check")
diff --git a/quarkus/run-script/scripts/run.sh b/quarkus/run-script/scripts/run.sh
new file mode 100755
index 000000000..1cea71574
--- /dev/null
+++ b/quarkus/run-script/scripts/run.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Linux Quarkus fast-jar run script for Apache Polaris
+
+set -e
+
+script_dir="$(dirname "$0")"
+
+if [ -z "$JAVA_HOME" ] ; then
+ JAVACMD="`\\unset -f command; \\command -v java`"
+else
+ JAVACMD="$JAVA_HOME/bin/java"
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "The JAVA_HOME environment variable is not defined correctly," >&2
+ echo "this environment variable is needed to run this program." >&2
+ exit 1
+fi
+
+exec "${JAVACMD}" -jar "${script_dir}/quarkus-run.jar"
diff --git a/quarkus/server/build.gradle.kts b/quarkus/server/build.gradle.kts
index ac19236bb..04b7030c9 100644
--- a/quarkus/server/build.gradle.kts
+++ b/quarkus/server/build.gradle.kts
@@ -17,6 +17,7 @@
* under the License.
*/
+import io.quarkus.gradle.tasks.QuarkusBuild
import io.quarkus.gradle.tasks.QuarkusRun
plugins {
@@ -28,6 +29,17 @@ plugins {
id("distribution")
}
+val quarkusRunner by
+ configurations.creating { description = "Used to reference the generated runner-jar" }
+
+val runScript by configurations.creating { description = "Used to reference the run.sh script" }
+
+val distributionZip by
+ configurations.creating { description = "Used to reference the distribution zip" }
+
+val distributionTar by
+ configurations.creating { description = "Used to reference the distribution tarball" }
+
dependencies {
implementation(project(":polaris-core"))
implementation(project(":polaris-api-management-service"))
@@ -42,6 +54,8 @@ dependencies {
// enforce the Quarkus _platform_ here, to get a consistent and validated set of dependencies
implementation(enforcedPlatform(libs.quarkus.bom))
implementation("io.quarkus:quarkus-container-image-docker")
+
+ runScript(project(":polaris-quarkus-run-script", "runScript"))
}
quarkus {
@@ -61,10 +75,6 @@ quarkus {
)
}
-tasks.named("distZip") { dependsOn("quarkusBuild") }
-
-tasks.named("distTar") { dependsOn("quarkusBuild") }
-
tasks.register("run") { dependsOn("quarkusRun") }
tasks.named<QuarkusRun>("quarkusRun") {
@@ -75,6 +85,7 @@ tasks.named<QuarkusRun>("quarkusRun") {
distributions {
main {
contents {
+ from(runScript)
from(project.layout.buildDirectory.dir("quarkus-app"))
from("../../NOTICE")
from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
@@ -82,3 +93,39 @@ distributions {
}
}
}
+
+val quarkusBuild = tasks.named<QuarkusBuild>("quarkusBuild")
+
+val distTar =
+ tasks.named<Tar>("distTar") {
+ dependsOn(quarkusBuild)
+ inputs.files(runScript)
+ compression = Compression.GZIP
+ }
+
+val distZip =
+ tasks.named<Zip>("distZip") {
+ dependsOn(quarkusBuild)
+ inputs.files(runScript)
+ }
+
+// Expose runnable jar via quarkusRunner configuration for integration-tests that require the
+// server.
+artifacts {
+ add(quarkusRunner.name, provider { quarkusBuild.get().fastJar.resolve("quarkus-run.jar") }) {
+ builtBy(quarkusBuild)
+ }
+ add(distributionTar.name, provider { distTar.get().archiveFile }) { builtBy(distTar) }
+ add(distributionZip.name, provider { distZip.get().archiveFile }) { builtBy(distZip) }
+}
+
+afterEvaluate {
+ publishing {
+ publications {
+ named<MavenPublication>("maven") {
+ artifact(distTar.get().archiveFile) { builtBy(distTar) }
+ artifact(distZip.get().archiveFile) { builtBy(distZip) }
+ }
+ }
+ }
+}