Skip to content

Commit

Permalink
HHH-6937 - Process database profiles just once per build
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Jan 4, 2012
1 parent 76a3ad2 commit 959e048
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void apply(Project project) {
}

private void processStandardProfiles(Map<String, DatabaseProfile> 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;
Expand All @@ -89,10 +89,6 @@ private void processStandardProfiles(Map<String, DatabaseProfile> profileMap) {
processProfiles( standardDatabasesDirectory, profileMap );
}

private Project getRootProject(Project project) {
return project.getParent() != null ? getRootProject( project.getParent() ) : project;
}

private void processProfiles(File directory, Map<String, DatabaseProfile> profileMap) {
// the directory itself is a "database directory" if it contains either:
// 1) a file named 'matrix.gradle'
Expand Down Expand Up @@ -124,11 +120,15 @@ private void processProfiles(File directory, Map<String, DatabaseProfile> profil
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<String> ignored;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class MatrixTestingPlugin implements Plugin<Project> {
public void apply(Project project) {
this.project = project;

project.plugins.apply( DatabaseProfilePlugin );
project.rootProject.plugins.apply( DatabaseProfilePlugin );
List<MatrixNode> matrixNodes = locateMatrixNodes();
if ( matrixNodes == null || matrixNodes.isEmpty() ) {
// no db profiles defined
Expand Down

0 comments on commit 959e048

Please sign in to comment.