11package io .quarkus .gradle .tasks ;
22
33import 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 ;
84import static java .util .Collections .emptyList ;
95
106import java .io .File ;
117import java .util .ArrayList ;
128import java .util .Collections ;
139import java .util .HashMap ;
14- import java .util .HashSet ;
1510import java .util .List ;
1611import java .util .Map ;
1712import java .util .Set ;
3227import io .quarkus .deployment .pkg .PackageConfig ;
3328import io .quarkus .gradle .dsl .Manifest ;
3429import 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 ) {
0 commit comments