From 959e048fd0525315d014f7ad592d84358ee91997 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 4 Jan 2012 13:43:10 -0600 Subject: [PATCH] HHH-6937 - Process database profiles just once per build --- .../database/DatabaseProfilePlugin.java | 18 +++++++++--------- .../testing/matrix/MatrixTestingPlugin.groovy | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) 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 fb04db5a6c..3876c2477f 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 @@ -75,7 +75,7 @@ public class DatabaseProfilePlugin implements Plugin { } private void processStandardProfiles(Map profileMap) { - final File standardDatabasesDirectory = getRootProject( project ).file( STANDARD_DATABASES_DIRECTORY ); + final File standardDatabasesDirectory = project.file( STANDARD_DATABASES_DIRECTORY ); if ( standardDatabasesDirectory == null || ! standardDatabasesDirectory.exists() ) { log.debug( "Standard databases directory [{}] did not exist", STANDARD_DATABASES_DIRECTORY ); return; @@ -89,10 +89,6 @@ public class DatabaseProfilePlugin implements Plugin { processProfiles( standardDatabasesDirectory, profileMap ); } - private Project getRootProject(Project project) { - return project.getParent() != null ? getRootProject( project.getParent() ) : project; - } - private void processProfiles(File directory, Map profileMap) { // the directory itself is a "database directory" if it contains either: // 1) a file named 'matrix.gradle' @@ -124,11 +120,15 @@ public class DatabaseProfilePlugin implements Plugin { return; } - if ( profileMap.containsKey( databaseProfile.getName() ) ) { - throw new DuplicateDatabaseProfileException( "There is already a profile named " + profileName ); + DatabaseProfile previousEntry = profileMap.put( profileName, databaseProfile ); + if ( previousEntry != null ) { + log.lifecycle( + "Found duplicate profile definitions [name={}], [{}] taking precedence over [{}]", + profileName, + databaseProfile.getDirectory().getAbsolutePath(), + previousEntry.getDirectory().getAbsolutePath() + ); } - - profileMap.put( profileName, databaseProfile ); } private Set ignored; 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 fa94399ea4..5ae504a338 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 @@ -71,7 +71,7 @@ public class MatrixTestingPlugin implements Plugin { public void apply(Project project) { this.project = project; - project.plugins.apply( DatabaseProfilePlugin ); + project.rootProject.plugins.apply( DatabaseProfilePlugin ); List matrixNodes = locateMatrixNodes(); if ( matrixNodes == null || matrixNodes.isEmpty() ) { // no db profiles defined