diff --git a/README.md b/README.md index d3da3fdd21..fe84e5d16c 100644 --- a/README.md +++ b/README.md @@ -128,3 +128,21 @@ Use the following command: gradle clean compile -Pdb=pgsql _*NOTE : If you are running tests against a JDBC driver that is not available via Maven central (generally due to license nonsense - Oracle, DB2, etc) be sure to add these drivers to your local Maven repo cache (~/.m2/repository) or (better) add it to a personal Maven repo server*_ + +Running database-specific tests from the IDE using "profiles" +------------------------------------------------------------- + +You can run any test on any particular database that is configured in a `databases.gradle` profile. + +All you have to do is run the following command: + + gradlew setDataBase -Pdb=pgsql + +or you can use the shortcut version: + + gradlew sDB -Pdb=pgsql + +You can do this from the module which you are interested in testing or from the `hibernate-orm` root folder. + +Afterward, just pick any test from the IDE and run it as usual. Hibernate will pick the database configuration from the `hibernate.properties` +file that was set up by the `setDataBase` Gradle task. diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index ce4ca056f7..7c7eb25659 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -293,7 +293,22 @@ task copyResourcesToIntelliJOutFolder { //// Gradle plugin). For now, just compile first in order to get the logging classes. //eclipseClasspath.dependsOn compile +/* + Use this task to set the current DB in a given module. + > gradlew sDB -Pdb=mysql + + Afterward, you can run any test from the IDE against that particular DB. + */ +task setDataBase { + inputs.property( "db", db ) + doLast { + processTestResources.execute() + copyResourcesToIntelliJOutFolder.execute() + + println( 'Setting current database to ' + db ) + } +} // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Report configs