-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37021 from aloubyansky/gradle-pass-sys-props-to-w…
…orker Gradle: set all discovered quarkus.* properties as system properties in QuarkusWorker
- Loading branch information
Showing
23 changed files
with
385 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...adle/src/main/resources/system-props-as-build-time-config-source/application/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
plugins{ | ||
id "java" | ||
id "io.quarkus" | ||
} | ||
|
||
|
||
|
||
group 'io.quarkus.test.application' | ||
version '1.0-SNAPSHOT' | ||
|
||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
implementation 'io.quarkus:quarkus-resteasy-reactive' | ||
implementation ('org.acme.extensions:example-extension') | ||
|
||
testImplementation 'io.quarkus:quarkus-junit5' | ||
testImplementation 'io.rest-assured:rest-assured' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
quarkusIntTest { | ||
environment "MY_RT_NAME", "genadiy" | ||
} |
2 changes: 2 additions & 0 deletions
2
...src/main/resources/system-props-as-build-time-config-source/application/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
20 changes: 20 additions & 0 deletions
20
...e/src/main/resources/system-props-as-build-time-config-source/application/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal { | ||
content { | ||
includeGroupByRegex 'io.quarkus.*' | ||
} | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
//noinspection GroovyAssignabilityCheck | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
includeBuild('../extensions/example-extension'){ | ||
|
||
} | ||
rootProject.name='application' |
29 changes: 29 additions & 0 deletions
29
...d-time-config-source/application/src/integrationTest/java/org/acme/ExampleResourceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.acme; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
@QuarkusIntegrationTest | ||
public class ExampleResourceIT { | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
given() | ||
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(is("hello cheburashka")); | ||
} | ||
|
||
@Test | ||
public void testRuntimeName() { | ||
given() | ||
.when().get("/hello/runtime-name") | ||
.then() | ||
.statusCode(200) | ||
.body(is("genadiy")); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...d-time-config-source/application/src/main/java/org/acme/quarkus/sample/HelloResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.acme.quarkus.sample; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.acme.example.extension.runtime.ExampleBuildOptions; | ||
import org.acme.example.extension.runtime.ExampleRuntimeConfig; | ||
|
||
@Path("/hello") | ||
public class HelloResource { | ||
|
||
@Inject | ||
ExampleBuildOptions buildOptions; | ||
|
||
@Inject | ||
ExampleRuntimeConfig rtConfig; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "hello " + buildOptions.name; | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Path("/runtime-name") | ||
public String runtimeName() { | ||
return rtConfig.runtimeName; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...m-props-as-build-time-config-source/application/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.example.runtime-name=${MY_RT_NAME:none} |
34 changes: 34 additions & 0 deletions
34
...ources/system-props-as-build-time-config-source/extensions/example-extension/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
plugins{ | ||
id 'java-library' | ||
id 'maven-publish' | ||
} | ||
subprojects {subProject-> | ||
apply plugin: 'java-library' | ||
apply plugin: 'maven-publish' | ||
|
||
group 'org.acme.extensions' | ||
version '1.0-SNAPSHOT' | ||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
groupId = 'org.acme.extensions' | ||
artifactId = subProject.name | ||
version = '1.0-SNAPSHOT' | ||
from components.java | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
groupId = 'org.acme.extensions' | ||
artifactId = rootProject.name | ||
version = '1.0-SNAPSHOT' | ||
from components.java | ||
} | ||
} | ||
} | ||
group 'org.acme.extensions' | ||
version '1.0-SNAPSHOT' |
18 changes: 18 additions & 0 deletions
18
...em-props-as-build-time-config-source/extensions/example-extension/deployment/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
} | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation platform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
annotationProcessor "io.quarkus:quarkus-extension-processor:${quarkusPlatformVersion}" | ||
|
||
|
||
api project(':example-extension') | ||
implementation 'io.quarkus:quarkus-arc-deployment' | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
...tension/deployment/src/main/java/org/acme/example/extension/deployment/ExampleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.acme.example.extension.deployment; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot | ||
public class ExampleConfig { | ||
|
||
/** | ||
* name | ||
*/ | ||
@ConfigItem(defaultValue = "none") | ||
String name; | ||
} |
30 changes: 30 additions & 0 deletions
30
...sion/deployment/src/main/java/org/acme/example/extension/deployment/ExampleProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.acme.example.extension.deployment; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import org.acme.example.extension.runtime.ExampleBuildOptions; | ||
import org.acme.example.extension.runtime.ExampleRecorder; | ||
import io.quarkus.arc.deployment.SyntheticBeanBuildItem; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
|
||
class ExampleProcessor { | ||
|
||
private static final String FEATURE = "example"; | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.STATIC_INIT) | ||
SyntheticBeanBuildItem syntheticBean(ExampleRecorder recorder, ExampleConfig config) { | ||
return SyntheticBeanBuildItem.configure(ExampleBuildOptions.class) | ||
.scope(Singleton.class) | ||
.runtimeValue(recorder.buildOptions(config.name)) | ||
.done(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...s/system-props-as-build-time-config-source/extensions/example-extension/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
20 changes: 20 additions & 0 deletions
20
...ystem-props-as-build-time-config-source/extensions/example-extension/runtime/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
plugins { | ||
id 'io.quarkus.extension' | ||
} | ||
|
||
quarkusExtension { | ||
deploymentModule = 'example-extension-deployment' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation platform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
annotationProcessor "io.quarkus:quarkus-extension-processor:${quarkusPlatformVersion}" | ||
implementation 'io.quarkus:quarkus-arc' | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...tension/runtime/src/main/java/org/acme/example/extension/runtime/ExampleBuildOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.acme.example.extension.runtime; | ||
|
||
public class ExampleBuildOptions { | ||
|
||
public final String name; | ||
|
||
public ExampleBuildOptions(String name) { | ||
this.name = name; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...e-extension/runtime/src/main/java/org/acme/example/extension/runtime/ExampleRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.acme.example.extension.runtime; | ||
|
||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class ExampleRecorder { | ||
|
||
public RuntimeValue<ExampleBuildOptions> buildOptions(String name) { | ||
System.out.println("ExampleRecorder.buildOptions " + name); | ||
return new RuntimeValue<>(new ExampleBuildOptions(name)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ension/runtime/src/main/java/org/acme/example/extension/runtime/ExampleRuntimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.acme.example.extension.runtime; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(phase = ConfigPhase.RUN_TIME) | ||
public class ExampleRuntimeConfig { | ||
|
||
/** | ||
* Whether the banner will be displayed | ||
*/ | ||
@ConfigItem(defaultValue = "none") | ||
public String runtimeName; | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...nsions/example-extension/runtime/src/main/resources/META-INF/quarkus-extension.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deployment-artifact=org.acme.extensions\:example-extension-deployment\:1.0 |
12 changes: 12 additions & 0 deletions
12
...e/extensions/example-extension/runtime/src/main/resources/META-INF/quarkus-extension.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
name: Quarkus Example Extension | ||
artifact: ${project.groupId}:${project.artifactId}:${project.version} | ||
metadata: | ||
config: | ||
- "quarkus.example.extension." | ||
keywords: | ||
- "logzio" | ||
- "logging" | ||
categories: | ||
- "logging" | ||
description: "Quarkus example extension" |
21 changes: 21 additions & 0 deletions
21
...ces/system-props-as-build-time-config-source/extensions/example-extension/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenLocal() | ||
} | ||
plugins { | ||
id 'io.quarkus.extension' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
dependencyResolutionManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
} | ||
rootProject.name = 'example-extension-parent' | ||
include(':deployment') | ||
include(':runtime') | ||
project(':deployment').name='example-extension-deployment' | ||
project(':runtime').name='example-extension' |
2 changes: 2 additions & 0 deletions
2
...ests/gradle/src/main/resources/system-props-as-build-time-config-source/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
18 changes: 18 additions & 0 deletions
18
...-tests/gradle/src/main/resources/system-props-as-build-time-config-source/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal { | ||
content { | ||
includeGroupByRegex 'io.quarkus.*' | ||
} | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
//noinspection GroovyAssignabilityCheck | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
includeBuild('extensions/example-extension') | ||
includeBuild('application') |
Oops, something went wrong.