diff --git a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/AbstractDatabaseProfileImpl.java b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/AbstractDatabaseProfileImpl.java index 46cf9f9791..a365618af9 100644 --- a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/AbstractDatabaseProfileImpl.java +++ b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/AbstractDatabaseProfileImpl.java @@ -36,6 +36,9 @@ import org.gradle.api.logging.Logging; import org.slf4j.Logger; +import org.hibernate.build.qalab.DatabaseAllocation; +import org.hibernate.build.qalab.DatabaseAllocator; + /** * Basic support for {@link DatabaseProfile} implementations * @@ -49,6 +52,7 @@ public abstract class AbstractDatabaseProfileImpl implements DatabaseProfile { private final File profileDirectory; private final Project project; private final Map hibernateProperties; + private final DatabaseAllocation databaseAllocation; @SuppressWarnings( {"unchecked"}) protected AbstractDatabaseProfileImpl(File profileDirectory, Project project) { @@ -83,6 +87,8 @@ public abstract class AbstractDatabaseProfileImpl implements DatabaseProfile { hibernateProperties.put( propName, props.getProperty( propName ) ); } } + + this.databaseAllocation = DatabaseAllocator.locate( project ).getAllocation( this ); } @Override @@ -100,6 +106,11 @@ public abstract class AbstractDatabaseProfileImpl implements DatabaseProfile { return hibernateProperties; } + @Override + public DatabaseAllocation getDatabaseAllocation() { + return databaseAllocation; + } + protected Configuration prepareConfiguration(String name) { Configuration configuration = getOrCreateConfiguration( name ); configuration.setDescription( "The JDBC dependency configuration for the [" + name + "] profile" ); diff --git a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/DatabaseAllocationCleanUp.java b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseAllocationCleanUp.java similarity index 97% rename from buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/DatabaseAllocationCleanUp.java rename to buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseAllocationCleanUp.java index 5ac50d7b0f..98b03e2cb0 100644 --- a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/DatabaseAllocationCleanUp.java +++ b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseAllocationCleanUp.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.build.gradle.testing.matrix; +package org.hibernate.build.gradle.testing.database; import java.util.HashSet; import java.util.Set; diff --git a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfile.java b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfile.java index d606845246..938ef5c6b7 100644 --- a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfile.java +++ b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfile.java @@ -28,6 +28,8 @@ import java.util.Map; import org.gradle.api.artifacts.Configuration; +import org.hibernate.build.qalab.DatabaseAllocation; + /** * Contract for database "profiles". * @@ -39,4 +41,5 @@ public interface DatabaseProfile { public File getDirectory(); public Map getHibernateProperties(); public Configuration getTestingRuntimeConfiguration(); + public DatabaseAllocation getDatabaseAllocation(); } diff --git a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfilePlugin.java b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfilePlugin.java index 3876c2477f..aff27982ff 100644 --- a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfilePlugin.java +++ b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/database/DatabaseProfilePlugin.java @@ -71,7 +71,13 @@ public class DatabaseProfilePlugin implements Plugin { processStandardProfiles( profileMap ); processCustomProfiles( profileMap ); this.profiles = new ArrayList(); - this.profiles.addAll( profileMap.values() ); + + DatabaseAllocationCleanUp listener = new DatabaseAllocationCleanUp(); + project.getGradle().addBuildListener( listener ); + for ( DatabaseProfile profile : profileMap.values() ) { + this.profiles.add( profile ); + listener.addDatabaseAllocation( profile.getDatabaseAllocation() ); + } } private void processStandardProfiles(Map profileMap) { diff --git a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/MatrixTestingPlugin.groovy b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/MatrixTestingPlugin.groovy index 5ae504a338..c4b9b72d61 100644 --- a/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/MatrixTestingPlugin.groovy +++ b/buildSrc/src/main/groovy/org/hibernate/build/gradle/testing/matrix/MatrixTestingPlugin.groovy @@ -40,8 +40,6 @@ import static org.gradle.api.plugins.JavaPlugin.COMPILE_CONFIGURATION_NAME import static org.gradle.api.plugins.JavaPlugin.RUNTIME_CONFIGURATION_NAME import static org.gradle.api.plugins.JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME import static org.gradle.api.plugins.JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME -import org.gradle.BuildAdapter -import org.gradle.BuildResult /** * TODO : 1) add a base configuration of common attribute across all matrix node tasks (convention) @@ -83,12 +81,9 @@ public class MatrixTestingPlugin implements Plugin { matrixSourceSet = prepareSourceSet(); matrixTask = prepareGroupingTask(); - DatabaseAllocationCleanUp listener = new DatabaseAllocationCleanUp(); - project.rootProject.gradle.addBuildListener( listener ); for ( MatrixNode matrixNode: matrixNodes ) { Task matrixNodeTask = prepareNodeTask( matrixNode ); matrixTask.dependsOn( matrixNodeTask ); - listener.addDatabaseAllocation( matrixNode.databaseAllocation ); } if ( !System.properties[SKIP_UNIT_TEST].equals('true') ) { @@ -97,20 +92,8 @@ public class MatrixTestingPlugin implements Plugin { } private List locateMatrixNodes() { - return locateMatrixNodes( this.project ); - } - - private List locateMatrixNodes(Project project) { - if ( project == null ) { - return null; // EARLY EXIT!!! - } - - if ( ! project.plugins.hasPlugin(DatabaseProfilePlugin) ) { - return locateMatrixNodes( project.parent ); // EARLY EXIT!!! - } - List matrixNodes = new ArrayList(); - Iterable profiles = project.plugins[DatabaseProfilePlugin].databaseProfiles; + Iterable profiles = project.rootProject.plugins[DatabaseProfilePlugin].databaseProfiles; if ( profiles != null ) { for ( DatabaseProfile profile : profiles ) { matrixNodes.add( new MatrixNode( project, profile, theJdk ) );