Skip to content

Commit

Permalink
Merge pull request #14764 from aloubyansky/reverse-platform-props-merge
Browse files Browse the repository at this point in the history
Reverse the platform properties overriding policy
  • Loading branch information
aloubyansky authored Feb 2, 2021
2 parents b8f4acd + a001ffe commit 5ef0975
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
42 changes: 42 additions & 0 deletions docs/src/main/asciidoc/platform.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,45 @@ There is also a Maven plugin goal that validates the platform properties content
</executions>
</plugin>
----

==== Merging Quarkus Platform Properties

In case an application is importing more than one Quarkus platform and those platforms include their own platform properties artifacts, the content of those platform properties artifacts will be merged to form a single set of properties that will be used for the application build.
The order in which the properties artifacts are merged will correspond to the order in which they appear in the list of dependency version constraints of the application (in the Maven terms that will correspond to the effective list of application's managed dependencies, i.e. the flattened `managedDependencies` POM section).

IMPORTANT: The content of the properties artifacts found earlier will dominate over those found later among the application's dependency constraints!

That means if a platform needs to override a certain property value defined in the platform it is based on, it will need to include its platform properties artifact into the `managedDependencies` section of its BOM before importing the base platform.

For example, the `quarkus-universe-bom` platform is based on the `quarkus-bom` platform. In case, the `quarkus-universe-bom` platform were to override certain properties defined in `quarkus-bom-quarkus-platform-properties` included into the `quarkus-bom` platform, the `quarkus-universe-bom` would have to be composed as
[source,xml]
----
<!-- skipped content -->
<artifactId>quarkus-universe-bom</artifactId>
<name>Quarkus universe - BOM</name>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<!-- universe platform properties -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom-quarkus-platform-properties</artifactId>
<type>properties</type>
<version>${project.version}</version>
</dependency>
<!-- Quarkus Core BOM -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- skipped content -->
----

That way, the `quarkus-universe-bom` platform properties will appear before the `quarkus-bom` platform properties and so will be dominating during merging.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ private void collectPlatformProperties(AppModel.Builder appBuilder, List<Depende
throws AppModelResolverException {
final Set<AppArtifactKey> descriptorKeys = new HashSet<>(4);
final Set<AppArtifactKey> propertyKeys = new HashSet<>(2);
final Map<String, String> collectedProps = new HashMap<String, String>();
for (Dependency d : managedDeps) {
final Artifact artifact = d.getArtifact();
final String extension = artifact.getExtension();
Expand All @@ -314,14 +315,12 @@ private void collectPlatformProperties(AppModel.Builder appBuilder, List<Depende
} catch (IOException e) {
throw new AppModelResolverException("Failed to read properties from " + propsPath, e);
}
final Map<String, String> map = new HashMap<String, String>(props.size());
for (Map.Entry<?, ?> prop : props.entrySet()) {
final String name = String.valueOf(prop.getKey());
if (name.startsWith(BootstrapConstants.PLATFORM_PROPERTY_PREFIX)) {
map.put(prop.getKey().toString(), prop.getValue().toString());
collectedProps.putIfAbsent(prop.getKey().toString(), prop.getValue().toString());
}
}
appBuilder.addPlatformProperties(map);
propertyKeys.add(new AppArtifactKey(artifact.getGroupId(),
artifactId.substring(0,
artifactId.length() - BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX.length()),
Expand All @@ -343,6 +342,7 @@ private void collectPlatformProperties(AppModel.Builder appBuilder, List<Depende
}
throw new AppModelResolverException(buf.toString());
}
appBuilder.addPlatformProperties(collectedProps);
}

@Override
Expand Down

0 comments on commit 5ef0975

Please sign in to comment.