HHH-6937 - Process database profiles just once per build
This commit is contained in:
parent
959e048fd0
commit
2795994b22
|
@ -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<String,String> 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" );
|
||||
|
|
|
@ -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;
|
|
@ -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<String,String> getHibernateProperties();
|
||||
public Configuration getTestingRuntimeConfiguration();
|
||||
public DatabaseAllocation getDatabaseAllocation();
|
||||
}
|
||||
|
|
|
@ -71,7 +71,13 @@ public class DatabaseProfilePlugin implements Plugin<Project> {
|
|||
processStandardProfiles( profileMap );
|
||||
processCustomProfiles( profileMap );
|
||||
this.profiles = new ArrayList<DatabaseProfile>();
|
||||
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<String, DatabaseProfile> profileMap) {
|
||||
|
|
|
@ -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<Project> {
|
|||
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<Project> {
|
|||
}
|
||||
|
||||
private List<MatrixNode> locateMatrixNodes() {
|
||||
return locateMatrixNodes( this.project );
|
||||
}
|
||||
|
||||
private List<MatrixNode> locateMatrixNodes(Project project) {
|
||||
if ( project == null ) {
|
||||
return null; // EARLY EXIT!!!
|
||||
}
|
||||
|
||||
if ( ! project.plugins.hasPlugin(DatabaseProfilePlugin) ) {
|
||||
return locateMatrixNodes( project.parent ); // EARLY EXIT!!!
|
||||
}
|
||||
|
||||
List<MatrixNode> matrixNodes = new ArrayList<MatrixNode>();
|
||||
Iterable<DatabaseProfile> profiles = project.plugins[DatabaseProfilePlugin].databaseProfiles;
|
||||
Iterable<DatabaseProfile> profiles = project.rootProject.plugins[DatabaseProfilePlugin].databaseProfiles;
|
||||
if ( profiles != null ) {
|
||||
for ( DatabaseProfile profile : profiles ) {
|
||||
matrixNodes.add( new MatrixNode( project, profile, theJdk ) );
|
||||
|
|
Loading…
Reference in New Issue