Skip to content

Commit 88bfd66

Browse files
committed
Do not copy quarkus configuration to Gradle plugin forced properties
1 parent 1dadceb commit 88bfd66

File tree

5 files changed

+13
-104
lines changed

5 files changed

+13
-104
lines changed

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/actions/BeforeTestAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ private EffectiveConfigProvider effectiveProvider() {
105105
extensionView.getForcedProperties(),
106106
extensionView.getProjectProperties(),
107107
extensionView.getQuarkusBuildProperties(),
108-
extensionView.getQuarkusRelevantProjectProperties(),
109108
manifestAttributes,
110109
manifestSections,
111110
extensionView.getNativeBuild(),

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package io.quarkus.gradle.tasks;
22

33
import static io.quarkus.gradle.tasks.QuarkusGradleUtils.getSourceSet;
4-
import static io.smallrye.common.expression.Expression.Flag.DOUBLE_COLON;
5-
import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX;
6-
import static io.smallrye.common.expression.Expression.Flag.NO_SMART_BRACES;
7-
import static io.smallrye.common.expression.Expression.Flag.NO_TRIM;
84
import static java.util.Collections.emptyList;
95

106
import java.io.File;
117
import java.util.ArrayList;
128
import java.util.Collections;
139
import java.util.HashMap;
14-
import java.util.HashSet;
1510
import java.util.List;
1611
import java.util.Map;
1712
import java.util.Set;
@@ -32,7 +27,6 @@
3227
import io.quarkus.deployment.pkg.PackageConfig;
3328
import io.quarkus.gradle.dsl.Manifest;
3429
import io.quarkus.maven.dependency.ResolvedDependency;
35-
import io.smallrye.common.expression.Expression;
3630

3731
/**
3832
* This base class exists to hide internal properties, make those only available in the {@link io.quarkus.gradle.tasks}
@@ -81,15 +75,7 @@ private BaseConfig buildBaseConfig() {
8175
Set<File> resourcesDirs = getSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME).getResources().getSourceDirectories()
8276
.getFiles();
8377

84-
// Used to handle the (deprecated) buildNative and testNative tasks.
85-
project.getExtensions().getExtraProperties().getProperties().forEach((k, v) -> {
86-
if (k.startsWith("quarkus.") || k.startsWith("platform.quarkus.")) {
87-
forcedPropertiesProperty.put(k, v.toString());
88-
}
89-
});
90-
9178
EffectiveConfig effectiveConfig = EffectiveConfig.builder()
92-
.withForcedProperties(forcedPropertiesProperty.get())
9379
.withTaskProperties(Collections.emptyMap())
9480
.withBuildProperties(quarkusBuildProperties.get())
9581
.withProjectProperties(project.getProperties())
@@ -145,13 +131,6 @@ protected EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel)
145131
Set<File> resourcesDirs = getSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME).getResources().getSourceDirectories()
146132
.getFiles();
147133

148-
// Used to handle the (deprecated) buildNative and testNative tasks.
149-
project.getExtensions().getExtraProperties().getProperties().forEach((k, v) -> {
150-
if (k.startsWith("quarkus.") || k.startsWith("platform.quarkus.")) {
151-
forcedPropertiesProperty.put(k, v.toString());
152-
}
153-
});
154-
155134
Map<String, String> defaultProperties = new HashMap<>();
156135
String userIgnoredEntries = String.join(",", ignoredEntries.get());
157136
if (!userIgnoredEntries.isEmpty()) {
@@ -162,7 +141,6 @@ protected EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel)
162141

163142
return EffectiveConfig.builder()
164143
.withPlatformProperties(appModel.getPlatformProperties())
165-
.withForcedProperties(forcedPropertiesProperty.get())
166144
.withTaskProperties(properties)
167145
.withBuildProperties(quarkusBuildProperties.get())
168146
.withProjectProperties(project.getProperties())
@@ -172,65 +150,6 @@ protected EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel)
172150
.build();
173151
}
174152

175-
/**
176-
* Filters resolved Gradle configuration for properties in the Quarkus namespace
177-
* (as in start with <code>quarkus.</code>). This avoids exposing configuration that may contain secrets or
178-
* passwords not related to Quarkus (for instance environment variables storing sensitive data for other systems).
179-
*
180-
* @param appArtifact the application dependency to retrive the quarkus application name and version.
181-
* @return a filtered view of the configuration only with <code>quarkus.</code> names.
182-
*/
183-
protected Map<String, String> buildSystemProperties(ResolvedDependency appArtifact, Map<String, String> quarkusProperties) {
184-
Map<String, String> buildSystemProperties = new HashMap<>();
185-
buildSystemProperties.putIfAbsent("quarkus.application.name", appArtifact.getArtifactId());
186-
buildSystemProperties.putIfAbsent("quarkus.application.version", appArtifact.getVersion());
187-
188-
for (Map.Entry<String, String> entry : forcedPropertiesProperty.get().entrySet()) {
189-
if (entry.getKey().startsWith("quarkus.") || entry.getKey().startsWith("platform.quarkus.")) {
190-
buildSystemProperties.put(entry.getKey(), entry.getValue());
191-
}
192-
}
193-
for (Map.Entry<String, String> entry : quarkusBuildProperties.get().entrySet()) {
194-
if (entry.getKey().startsWith("quarkus.") || entry.getKey().startsWith("platform.quarkus.")) {
195-
buildSystemProperties.put(entry.getKey(), entry.getValue());
196-
}
197-
}
198-
for (Map.Entry<String, ?> entry : project.getProperties().entrySet()) {
199-
if ((entry.getKey().startsWith("quarkus.") || entry.getKey().startsWith("platform.quarkus."))
200-
&& entry.getValue() != null) {
201-
buildSystemProperties.put(entry.getKey(), entry.getValue().toString());
202-
}
203-
}
204-
205-
Set<String> quarkusValues = new HashSet<>();
206-
quarkusValues.addAll(quarkusProperties.values());
207-
quarkusValues.addAll(buildSystemProperties.values());
208-
209-
for (String value : quarkusValues) {
210-
Expression expression = Expression.compile(value, LENIENT_SYNTAX, NO_TRIM, NO_SMART_BRACES, DOUBLE_COLON);
211-
for (String reference : expression.getReferencedStrings()) {
212-
String expanded = forcedPropertiesProperty.get().get(reference);
213-
if (expanded != null) {
214-
buildSystemProperties.put(reference, expanded);
215-
continue;
216-
}
217-
218-
expanded = quarkusBuildProperties.get().get(reference);
219-
if (expanded != null) {
220-
buildSystemProperties.put(reference, expanded);
221-
continue;
222-
}
223-
224-
expanded = (String) project.getProperties().get(reference);
225-
if (expanded != null) {
226-
buildSystemProperties.put(reference, expanded);
227-
}
228-
}
229-
}
230-
231-
return buildSystemProperties;
232-
}
233-
234153
private String quarkusProfile() {
235154
String profile = System.getProperty(QUARKUS_PROFILE);
236155
if (profile == null) {

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfigProvider.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class EffectiveConfigProvider {
2424
final MapProperty<String, String> forcedProperties;
2525
final MapProperty<String, Object> projectProperties;
2626
final MapProperty<String, String> quarkusBuildProperties;
27-
final MapProperty<String, String> quarkusRelevantProjectProperties;
2827
final MapProperty<String, Object> manifestAttributes;
2928
final MapProperty<String, Attributes> manifestSections;
3029
final Property<Boolean> nativeBuild;
@@ -36,7 +35,6 @@ public EffectiveConfigProvider(ListProperty<String> ignoredEntries,
3635
MapProperty<String, String> forcedProperties,
3736
MapProperty<String, Object> projectProperties,
3837
MapProperty<String, String> quarkusBuildProperties,
39-
MapProperty<String, String> quarkusRelevantProjectProperties,
4038
MapProperty<String, Object> manifestAttributes,
4139
MapProperty<String, Attributes> manifestSections,
4240
Property<Boolean> nativeBuild,
@@ -47,7 +45,6 @@ public EffectiveConfigProvider(ListProperty<String> ignoredEntries,
4745
this.forcedProperties = forcedProperties;
4846
this.projectProperties = projectProperties;
4947
this.quarkusBuildProperties = quarkusBuildProperties;
50-
this.quarkusRelevantProjectProperties = quarkusRelevantProjectProperties;
5148
this.manifestAttributes = manifestAttributes;
5249
this.manifestSections = manifestSections;
5350
this.nativeBuild = nativeBuild;
@@ -72,10 +69,6 @@ public EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel,
7269
defaultProperties.putIfAbsent("quarkus.application.version", appArtifact.getVersion());
7370

7471
Map<String, String> forced = new HashMap<>(forcedProperties.get());
75-
projectProperties.get().forEach((k, v) -> {
76-
forced.put(k, v.toString());
77-
78-
});
7972
additionalForcedProperties.forEach((k, v) -> {
8073
forced.put(k, v.toString());
8174
});
@@ -87,7 +80,7 @@ public EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel,
8780
.withForcedProperties(forced)
8881
.withTaskProperties(properties)
8982
.withBuildProperties(quarkusBuildProperties.get())
90-
.withProjectProperties(quarkusRelevantProjectProperties.get())
83+
.withProjectProperties(projectProperties.get())
9184
.withDefaultProperties(defaultProperties)
9285
.withSourceDirectories(resourcesDirs)
9386
.withProfile(getQuarkusProfile())
@@ -117,7 +110,7 @@ private String getQuarkusProfile() {
117110
profile = quarkusBuildProperties.get().get(QUARKUS_PROFILE);
118111
}
119112
if (profile == null) {
120-
Object p = quarkusRelevantProjectProperties.get().get(QUARKUS_PROFILE);
113+
Object p = projectProperties.get().get(QUARKUS_PROFILE);
121114
if (p != null) {
122115
profile = p.toString();
123116
}

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,15 @@ protected static void deleteFileIfExists(Path file) {
380380
}
381381
}
382382

383-
private Map<String, String> buildSystemProperties(ResolvedDependency appArtifact, Map<String, String> quarkusProperties) {
383+
/**
384+
* Filters resolved Gradle configuration for properties in the Quarkus namespace
385+
* (as in start with <code>quarkus.</code>). This avoids exposing configuration that may contain secrets or
386+
* passwords not related to Quarkus (for instance environment variables storing sensitive data for other systems).
387+
*
388+
* @param appArtifact the application dependency to retrive the quarkus application name and version.
389+
* @return a filtered view of the configuration only with <code>quarkus.</code> names.
390+
*/
391+
protected Map<String, String> buildSystemProperties(ResolvedDependency appArtifact, Map<String, String> quarkusProperties) {
384392
Map<String, String> buildSystemProperties = new HashMap<>();
385393
buildSystemProperties.putIfAbsent("quarkus.application.name", appArtifact.getArtifactId());
386394
buildSystemProperties.putIfAbsent("quarkus.application.version", appArtifact.getVersion());
@@ -390,11 +398,6 @@ private Map<String, String> buildSystemProperties(ResolvedDependency appArtifact
390398
buildSystemProperties.putIfAbsent("quarkus.package.output-timestamp", "1970-01-02T00:00:00Z");
391399
}
392400

393-
for (Map.Entry<String, String> entry : getExtensionView().getForcedProperties().get().entrySet()) {
394-
if (entry.getKey().startsWith("quarkus.") || entry.getKey().startsWith("platform.quarkus.")) {
395-
buildSystemProperties.put(entry.getKey(), entry.getValue());
396-
}
397-
}
398401
for (Map.Entry<String, String> entry : getExtensionView().getQuarkusBuildProperties().get().entrySet()) {
399402
if (entry.getKey().startsWith("quarkus.") || entry.getKey().startsWith("platform.quarkus.")) {
400403
buildSystemProperties.put(entry.getKey(), entry.getValue());
@@ -414,23 +417,19 @@ private Map<String, String> buildSystemProperties(ResolvedDependency appArtifact
414417
for (String value : quarkusValues) {
415418
Expression expression = Expression.compile(value, LENIENT_SYNTAX, NO_TRIM, NO_SMART_BRACES, DOUBLE_COLON);
416419
for (String reference : expression.getReferencedStrings()) {
417-
String expanded = getExtensionView().getForcedProperties().get().get(reference);
420+
String expanded = getExtensionView().getQuarkusBuildProperties().get().get(reference);
418421
if (expanded != null) {
419422
buildSystemProperties.put(reference, expanded);
420423
continue;
421424
}
422425

423-
expanded = getExtensionView().getQuarkusBuildProperties().get().get(reference);
424-
if (expanded != null) {
425-
buildSystemProperties.put(reference, expanded);
426-
continue;
427-
}
428426
expanded = (String) getExtensionView().getProjectProperties().get().get(reference);
429427
if (expanded != null) {
430428
buildSystemProperties.put(reference, expanded);
431429
}
432430
}
433431
}
432+
434433
return buildSystemProperties;
435434
}
436435
}

devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusTaskWithExtensionView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public EffectiveConfigProvider effectiveProvider() {
4545
getExtensionView().getForcedProperties(),
4646
getExtensionView().getProjectProperties(),
4747
getExtensionView().getQuarkusBuildProperties(),
48-
getExtensionView().getQuarkusRelevantProjectProperties(),
4948
getManifestAttributes(),
5049
getManifestSections(),
5150
getExtensionView().getNativeBuild(),

0 commit comments

Comments
 (0)