Fix db/ci.node not being added to build scan tags

This commit is contained in:
Yoann Rodière 2024-03-21 18:50:04 +01:00
parent f81124c511
commit 1cac1d5bc9
2 changed files with 27 additions and 5 deletions

View File

@ -47,11 +47,10 @@ gradleEnterprise {
uploadInBackground = !settings.ext.isCiEnvironment
tag "JDK ${JavaVersion.current().toString()}"
String db = rootProject.hasProperty( 'db' ) ? rootProject.properties.db : 'h2'
tag db
value 'database', db
if ( rootProject.hasProperty( 'ci.node' ) ) {
tag rootProject.property('ci.node')
tag extensions.db
value 'database', extensions.db
if ( extensions.hasProperty( 'ci.node' ) ) {
tag extensions.property( 'ci.node' )
}
}
}

View File

@ -1,5 +1,9 @@
package org.hibernate.orm.env;
import java.util.Map;
import java.util.Objects;
import org.gradle.StartParameter;
import org.gradle.api.Plugin;
import org.gradle.api.initialization.Settings;
@ -11,5 +15,24 @@ public class EnvironmentSettingsPlugin implements Plugin<Settings> {
@Override
public void apply(Settings settings) {
settings.getExtensions().add( JpaVersion.EXT_KEY, JpaVersion.from( settings ) );
settings.getExtensions().add( "db", Objects.requireNonNullElse( getP( settings, "db" ), "h2" ) );
String ciNode = getP( settings, "ci.node" );
if ( ciNode != null ) {
settings.getExtensions().add( "ci.node", ciNode );
}
}
private static String getP(Settings settings, String key) {
StartParameter startParameter = settings.getStartParameter();
// the `-P` settings passed at command-line
final Map<String, String> projectProperties = startParameter.getProjectProperties();
final String projectProperty = projectProperties.get( key );
if ( projectProperty != null && !projectProperty.isEmpty() ) {
return projectProperty;
}
else {
return null;
}
}
}