Skip to content

Commit a0bf7e3

Browse files
authored
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".
1 parent 477cc37 commit a0bf7e3

File tree

5 files changed

+174
-21
lines changed

5 files changed

+174
-21
lines changed

gradle/projects.main.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ polaris-quarkus-service=quarkus/service
3030
polaris-quarkus-server=quarkus/server
3131
polaris-quarkus-spark-tests=quarkus/spark-tests
3232
polaris-quarkus-admin=quarkus/admin
33+
polaris-quarkus-run-script=quarkus/run-script
3334
polaris-eclipselink=extension/persistence/eclipselink
3435
polaris-jpa-model=extension/persistence/jpa-model
3536
polaris-tests=integration-tests

quarkus/admin/build.gradle.kts

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ plugins {
2828
id("distribution")
2929
}
3030

31+
val runScript by configurations.creating { description = "Used to reference the run.sh script" }
32+
33+
val distributionZip by
34+
configurations.creating { description = "Used to reference the distribution zip" }
35+
36+
val distributionTar by
37+
configurations.creating { description = "Used to reference the distribution tarball" }
38+
3139
dependencies {
3240
implementation(project(":polaris-core"))
3341
implementation(project(":polaris-version"))
@@ -53,10 +61,12 @@ dependencies {
5361

5462
testRuntimeOnly(project(":polaris-eclipselink"))
5563
testRuntimeOnly("org.postgresql:postgresql")
64+
65+
runScript(project(":polaris-quarkus-run-script", "runScript"))
5666
}
5767

5868
quarkus {
59-
quarkusBuildProperties.put("quarkus.package.type", "uber-jar")
69+
quarkusBuildProperties.put("quarkus.package.type", "fast-jar")
6070
// Pull manifest attributes from the "main" `jar` task to get the
6171
// release-information into the jars generated by Quarkus.
6272
quarkusBuildProperties.putAll(
@@ -72,28 +82,48 @@ quarkus {
7282
)
7383
}
7484

75-
publishing {
76-
publications {
77-
named<MavenPublication>("maven") {
78-
val quarkusBuild = tasks.getByName<QuarkusBuild>("quarkusBuild")
79-
artifact(quarkusBuild.runnerJar) {
80-
classifier = "runner"
81-
builtBy(quarkusBuild)
82-
}
85+
distributions {
86+
main {
87+
contents {
88+
from(runScript)
89+
from(project.layout.buildDirectory.dir("quarkus-app"))
90+
from("../../NOTICE")
91+
from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
8392
}
8493
}
8594
}
8695

87-
tasks.named("distZip") { dependsOn("quarkusBuild") }
96+
val quarkusBuild = tasks.named<QuarkusBuild>("quarkusBuild")
8897

89-
tasks.named("distTar") { dependsOn("quarkusBuild") }
98+
val distTar =
99+
tasks.named<Tar>("distTar") {
100+
dependsOn(quarkusBuild)
101+
// Trigger resolution (and build) of the run-script artifact
102+
inputs.files(runScript)
103+
compression = Compression.GZIP
104+
}
90105

91-
distributions {
92-
main {
93-
contents {
94-
from("../../NOTICE")
95-
from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
96-
from(project.layout.buildDirectory) { include("polaris-quarkus-admin-*-runner.jar") }
106+
val distZip =
107+
tasks.named<Zip>("distZip") {
108+
dependsOn(quarkusBuild)
109+
// Trigger resolution (and build) of the run-script artifact
110+
inputs.files(runScript)
111+
}
112+
113+
// Expose runnable jar via quarkusRunner configuration for integration-tests that require the
114+
// server.
115+
artifacts {
116+
add(distributionTar.name, provider { distTar.get().archiveFile }) { builtBy(distTar) }
117+
add(distributionZip.name, provider { distZip.get().archiveFile }) { builtBy(distZip) }
118+
}
119+
120+
afterEvaluate {
121+
publishing {
122+
publications {
123+
named<MavenPublication>("maven") {
124+
artifact(distTar.get().archiveFile) { builtBy(distTar) }
125+
artifact(distZip.get().archiveFile) { builtBy(distZip) }
126+
}
97127
}
98128
}
99129
}

quarkus/run-script/build.gradle.kts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
val runScript by
21+
configurations.creating { description = "Used to provide the run.sh script" }
22+
23+
description = "Provides run.sh script for Quarkus fast-jar for distribution tar/zip"
24+
25+
// This is a separate project that only provides run scripts (run.sh).
26+
// It is a separate project, because it is not good practice to directly
27+
// reference files outside any project.
28+
//
29+
// Artifacts are NOT published as a Maven artifacts.
30+
31+
artifacts {
32+
add(runScript.name, project.layout.projectDirectory.file("scripts/run.sh"))
33+
}
34+
35+
// Need this task to be present, there are no checks/tests in this project though
36+
tasks.register("check")

quarkus/run-script/scripts/run.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
# Linux Quarkus fast-jar run script for Apache Polaris
22+
23+
set -e
24+
25+
script_dir="$(dirname "$0")"
26+
27+
if [ -z "$JAVA_HOME" ] ; then
28+
JAVACMD="`\\unset -f command; \\command -v java`"
29+
else
30+
JAVACMD="$JAVA_HOME/bin/java"
31+
fi
32+
33+
if [ ! -x "$JAVACMD" ] ; then
34+
echo "The JAVA_HOME environment variable is not defined correctly," >&2
35+
echo "this environment variable is needed to run this program." >&2
36+
exit 1
37+
fi
38+
39+
exec "${JAVACMD}" -jar "${script_dir}/quarkus-run.jar"

quarkus/server/build.gradle.kts

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919

20+
import io.quarkus.gradle.tasks.QuarkusBuild
2021
import io.quarkus.gradle.tasks.QuarkusRun
2122

2223
plugins {
@@ -28,6 +29,17 @@ plugins {
2829
id("distribution")
2930
}
3031

32+
val quarkusRunner by
33+
configurations.creating { description = "Used to reference the generated runner-jar" }
34+
35+
val runScript by configurations.creating { description = "Used to reference the run.sh script" }
36+
37+
val distributionZip by
38+
configurations.creating { description = "Used to reference the distribution zip" }
39+
40+
val distributionTar by
41+
configurations.creating { description = "Used to reference the distribution tarball" }
42+
3143
dependencies {
3244
implementation(project(":polaris-core"))
3345
implementation(project(":polaris-api-management-service"))
@@ -42,6 +54,8 @@ dependencies {
4254
// enforce the Quarkus _platform_ here, to get a consistent and validated set of dependencies
4355
implementation(enforcedPlatform(libs.quarkus.bom))
4456
implementation("io.quarkus:quarkus-container-image-docker")
57+
58+
runScript(project(":polaris-quarkus-run-script", "runScript"))
4559
}
4660

4761
quarkus {
@@ -61,10 +75,6 @@ quarkus {
6175
)
6276
}
6377

64-
tasks.named("distZip") { dependsOn("quarkusBuild") }
65-
66-
tasks.named("distTar") { dependsOn("quarkusBuild") }
67-
6878
tasks.register("run") { dependsOn("quarkusRun") }
6979

7080
tasks.named<QuarkusRun>("quarkusRun") {
@@ -75,10 +85,47 @@ tasks.named<QuarkusRun>("quarkusRun") {
7585
distributions {
7686
main {
7787
contents {
88+
from(runScript)
7889
from(project.layout.buildDirectory.dir("quarkus-app"))
7990
from("../../NOTICE")
8091
from("../../LICENSE-BINARY-DIST").rename("LICENSE-BINARY-DIST", "LICENSE")
8192
exclude("lib/main/io.quarkus.quarkus-container-image*")
8293
}
8394
}
8495
}
96+
97+
val quarkusBuild = tasks.named<QuarkusBuild>("quarkusBuild")
98+
99+
val distTar =
100+
tasks.named<Tar>("distTar") {
101+
dependsOn(quarkusBuild)
102+
inputs.files(runScript)
103+
compression = Compression.GZIP
104+
}
105+
106+
val distZip =
107+
tasks.named<Zip>("distZip") {
108+
dependsOn(quarkusBuild)
109+
inputs.files(runScript)
110+
}
111+
112+
// Expose runnable jar via quarkusRunner configuration for integration-tests that require the
113+
// server.
114+
artifacts {
115+
add(quarkusRunner.name, provider { quarkusBuild.get().fastJar.resolve("quarkus-run.jar") }) {
116+
builtBy(quarkusBuild)
117+
}
118+
add(distributionTar.name, provider { distTar.get().archiveFile }) { builtBy(distTar) }
119+
add(distributionZip.name, provider { distZip.get().archiveFile }) { builtBy(distZip) }
120+
}
121+
122+
afterEvaluate {
123+
publishing {
124+
publications {
125+
named<MavenPublication>("maven") {
126+
artifact(distTar.get().archiveFile) { builtBy(distTar) }
127+
artifact(distZip.get().archiveFile) { builtBy(distZip) }
128+
}
129+
}
130+
}
131+
}

0 commit comments

Comments
 (0)