Gradle build clean-ups
- re-organize release task definitions to avoid use of subproject iteration
This commit is contained in:
parent
9335d3efbf
commit
f82d381fe3
|
@ -13,6 +13,8 @@ plugins {
|
||||||
|
|
||||||
|
|
||||||
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||||
|
apply from: rootProject.file( 'gradle/releasable.gradle' )
|
||||||
|
|
||||||
apply plugin: 'org.hibernate.matrix-test'
|
apply plugin: 'org.hibernate.matrix-test'
|
||||||
apply plugin: 'org.hibernate.orm.build.reports'
|
apply plugin: 'org.hibernate.orm.build.reports'
|
||||||
|
|
||||||
|
@ -65,6 +67,7 @@ dependencies {
|
||||||
if ( project.ormVersion.isSnapshot ) {
|
if ( project.ormVersion.isSnapshot ) {
|
||||||
// only run the ci build tasks for SNAPSHOT versions
|
// only run the ci build tasks for SNAPSHOT versions
|
||||||
task ciBuild( dependsOn: [clean, test] )
|
task ciBuild( dependsOn: [clean, test] )
|
||||||
|
tasks.release.enabled false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
task release( dependsOn: [clean, test] )
|
task release( dependsOn: [clean, test] )
|
||||||
|
|
|
@ -14,7 +14,7 @@ buildscript {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'de.thetaphi:forbiddenapis:3.1'
|
classpath 'de.thetaphi:forbiddenapis:3.2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,25 +58,6 @@ if ( !project.description ) {
|
||||||
|
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy {
|
|
||||||
dependencySubstitution {
|
|
||||||
// will handle dependencies pulled in transitively
|
|
||||||
substitute module( 'javax.persistence:javax.persistence-api' ) with module( libraries.jakarta_jpa )
|
|
||||||
substitute module( 'javax.transaction:jta' ) with module( libraries.jakarta_jta )
|
|
||||||
substitute module( 'org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec' ) with module( libraries.jakarta_jta )
|
|
||||||
substitute module( 'javax.validation:validation-api' ) with module( libraries.jakarta_validation )
|
|
||||||
substitute module( 'javax.interceptor:javax.interceptor-api' ) with module( libraries.jakarta_interceptor )
|
|
||||||
substitute module( 'javax.activation:javax.activation-api' ) with module( libraries.jakarta_activation )
|
|
||||||
substitute module( 'javax.enterprise:cdi-api' ) with module( libraries.jakarta_cdi )
|
|
||||||
substitute module( 'org.jboss.weld.se:weld-se-shaded' ) with module( libraries.jakarta_weld )
|
|
||||||
substitute module( 'javax.xml.bind:jaxb-api' ) with module( libraries.jakarta_jaxb_api )
|
|
||||||
substitute module( 'org.glassfish.jaxb:jaxb-runtime' ) with module( libraries.jakarta_jaxb_runtime )
|
|
||||||
substitute module( 'org.jboss.narayana.jta:narayana-jta' ) with module( libraries.jboss_jta_jakarta )
|
|
||||||
substitute module( 'org.jboss:jboss-transaction-spi' ) with module( libraries.jboss_tx_spi_jakarta )
|
|
||||||
substitute module( 'org.hibernate.validator:hibernate-validator' ) with module( libraries.jakarta_validator )
|
|
||||||
substitute module( 'org.glassfish:javax.el' ) with module( libraries.jakarta_el )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exclude group: 'xml-apis', module: 'xml-apis'
|
exclude group: 'xml-apis', module: 'xml-apis'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +128,11 @@ dependencies {
|
||||||
|
|
||||||
tasks.withType( JavaCompile ) {
|
tasks.withType( JavaCompile ) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
|
options.warnings false
|
||||||
|
// javaCompileTask.options.compilerArgs += [
|
||||||
|
// "-nowarn",
|
||||||
|
// "-encoding", "UTF-8"
|
||||||
|
// ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !gradle.ext.javaToolchainEnabled ) {
|
if ( !gradle.ext.javaToolchainEnabled ) {
|
||||||
|
@ -186,20 +172,15 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure JVM Options
|
// Configure JVM Options
|
||||||
tasks.withType( JavaCompile ).configureEach {
|
|
||||||
options.forkOptions.jvmArgs.addAll( getProperty( 'toolchain.compiler.jvmargs' ).toString().split( ' ' ) )
|
|
||||||
}
|
|
||||||
tasks.withType( Javadoc ).configureEach {
|
|
||||||
options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().split( ' ' ).toList().findAll( { !it.isEmpty() } ) )
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display version of Java tools
|
// Display version of Java tools
|
||||||
tasks.withType( JavaCompile ).configureEach {
|
tasks.withType( JavaCompile ).configureEach {
|
||||||
|
options.forkOptions.jvmArgs.addAll( getProperty( 'toolchain.compiler.jvmargs' ).toString().split( ' ' ) )
|
||||||
doFirst {
|
doFirst {
|
||||||
logger.lifecycle "Compiling with '${javaCompiler.get().metadata.installationPath}'"
|
logger.lifecycle "Compiling with '${javaCompiler.get().metadata.installationPath}'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.withType( Javadoc ).configureEach {
|
tasks.withType( Javadoc ).configureEach {
|
||||||
|
options.setJFlags( getProperty( 'toolchain.javadoc.jvmargs' ).toString().split( ' ' ).toList().findAll( { !it.isEmpty() } ) )
|
||||||
doFirst {
|
doFirst {
|
||||||
logger.lifecycle "Generating javadoc with '${javadocTool.get().metadata.installationPath}'"
|
logger.lifecycle "Generating javadoc with '${javadocTool.get().metadata.installationPath}'"
|
||||||
}
|
}
|
||||||
|
@ -209,18 +190,6 @@ else {
|
||||||
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
|
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
|
||||||
|
|
||||||
|
|
||||||
convention.findPlugin( JavaPluginConvention.class ).sourceSets.each { sourceSet ->
|
|
||||||
JavaCompile javaCompileTask = project.tasks.findByName( sourceSet.compileJavaTaskName ) as JavaCompile
|
|
||||||
|
|
||||||
// NOTE : this aptDir stuff is needed until we can have IntelliJ run annotation processors for us
|
|
||||||
// which cannot happen until we can fold hibernate-testing back into hibernate-core/src/test
|
|
||||||
// which cannot happen until... ugh
|
|
||||||
|
|
||||||
javaCompileTask.options.compilerArgs += [
|
|
||||||
"-nowarn",
|
|
||||||
"-encoding", "UTF-8"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Attach tools JAR to the classpath for byteman tests
|
// Attach tools JAR to the classpath for byteman tests
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Applied to all projects
|
// Applied to all modules (sub-projects)
|
||||||
|
|
||||||
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,14 @@
|
||||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'signing'
|
apply from: rootProject.file( 'gradle/releasable.gradle' )
|
||||||
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||||
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
||||||
|
|
||||||
|
apply plugin: 'signing'
|
||||||
|
|
||||||
|
tasks.getByPath( ':release:publishReleaseArtifacts' ).dependsOn tasks.release
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
javadocSources {
|
javadocSources {
|
||||||
description 'Used to aggregate javadocs for the whole project'
|
description 'Used to aggregate javadocs for the whole project'
|
||||||
|
@ -107,10 +111,12 @@ signing {
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Release / publishing tasks
|
// Release / publishing tasks
|
||||||
|
|
||||||
task ciBuild( dependsOn: [test, publish] )
|
task ciBuild {
|
||||||
|
dependsOn test, publish
|
||||||
|
}
|
||||||
|
|
||||||
task release(dependsOn: [test, publishToSonatype])
|
tasks.release.dependsOn tasks.test, tasks.publishToSonatype
|
||||||
publishToSonatype.mustRunAfter test
|
tasks.publishToSonatype.mustRunAfter test
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
||||||
|
|
||||||
|
task release {
|
||||||
|
dependsOn ':release:releaseChecks'
|
||||||
|
mustRunAfter ':release:releaseChecks'
|
||||||
|
enabled !project.ormVersion.isSnapshot
|
||||||
|
}
|
|
@ -554,16 +554,6 @@ task release {
|
||||||
finalizedBy gitTasksAfterRelease
|
finalizedBy gitTasksAfterRelease
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.subprojects.each { Project subProject ->
|
|
||||||
if ( project.name != subProject.name ) {
|
|
||||||
if ( subProject.tasks.findByName( 'release' ) ) {
|
|
||||||
project.tasks.publishReleaseArtifacts.dependsOn( subProject.tasks.release )
|
|
||||||
subProject.tasks.release.dependsOn( releaseChecks )
|
|
||||||
subProject.tasks.release.mustRunAfter( releaseChecks )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task ciReleaseChecks {
|
task ciReleaseChecks {
|
||||||
dependsOn releaseChecks
|
dependsOn releaseChecks
|
||||||
}
|
}
|
||||||
|
@ -716,7 +706,8 @@ class ReleaseNote {
|
||||||
|
|
||||||
gradle.getTaskGraph().whenReady {tg->
|
gradle.getTaskGraph().whenReady {tg->
|
||||||
|
|
||||||
if ( tg.hasTask( project.tasks.releaseChecks ) ) {
|
if ( tg.hasTask( project.tasks.releaseChecks )
|
||||||
|
&& ! project.getGradle().getStartParameter().isDryRun() ) {
|
||||||
String releaseVersionLocal
|
String releaseVersionLocal
|
||||||
String developmentVersionLocal
|
String developmentVersionLocal
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||||
|
apply from: rootProject.file( 'gradle/releasable.gradle' )
|
||||||
|
|
||||||
description = "Gradle plugin for integrating Hibernate aspects into your build"
|
description = "Gradle plugin for integrating Hibernate aspects into your build"
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ tasks.test {
|
||||||
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
|
||||||
}
|
}
|
||||||
|
|
||||||
task release {
|
tasks.release {
|
||||||
dependsOn tasks.publishPlugins
|
dependsOn tasks.publishPlugins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
A template for projects wanting to use Hibernate ORM.
|
|
||||||
|
|
||||||
Useful to either:
|
|
||||||
|
|
||||||
1. Bootstrap a new user project
|
|
||||||
2. Bootstrap a test-case project
|
|
|
@ -1,112 +0,0 @@
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
|
||||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
|
||||||
*/
|
|
||||||
plugins {
|
|
||||||
id 'base'
|
|
||||||
|
|
||||||
// for publishing snapshots
|
|
||||||
id 'maven-publish'
|
|
||||||
id 'org.hibernate.build.maven-repo-auth'
|
|
||||||
|
|
||||||
// publishing to BinTray
|
|
||||||
id "com.jfrog.bintray"
|
|
||||||
id "nu.studer.credentials" version "2.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE : Had trouble using the `distribution` plugin, so manually using Jar/Tar tasks
|
|
||||||
|
|
||||||
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
|
||||||
|
|
||||||
ext {
|
|
||||||
processedTemplateDir = project.layout.buildDirectory.dir('resources/template')
|
|
||||||
archiveDir = project.layout.buildDirectory.dir('distributions')
|
|
||||||
}
|
|
||||||
|
|
||||||
task processTemplateResources(type:Copy) {
|
|
||||||
inputs.files( 'src/template/resources' )
|
|
||||||
outputs.dir( processedTemplateDir )
|
|
||||||
|
|
||||||
description = 'Copies the template sources into the build dir, performing some replacements'
|
|
||||||
|
|
||||||
from( 'src/template/resources' ) {
|
|
||||||
filter( ReplaceTokens, tokens: [ 'ormVersion' : project.version.toString() ] )
|
|
||||||
}
|
|
||||||
into processedTemplateDir.get().asFile
|
|
||||||
}
|
|
||||||
|
|
||||||
task templateTgz(type:Tar) {
|
|
||||||
description = 'Bundles the template project into a TGZ archive'
|
|
||||||
|
|
||||||
inputs.files( processedTemplateDir )
|
|
||||||
outputs.dir( archiveDir )
|
|
||||||
|
|
||||||
dependsOn project.tasks.processTemplateResources
|
|
||||||
|
|
||||||
compression = Compression.GZIP
|
|
||||||
|
|
||||||
from processedTemplateDir.get().asFile
|
|
||||||
|
|
||||||
destinationDirectory = archiveDir
|
|
||||||
}
|
|
||||||
|
|
||||||
task templateZip(type:Zip) {
|
|
||||||
description = 'Bundles the template project into a Zip archive'
|
|
||||||
|
|
||||||
inputs.files( processedTemplateDir )
|
|
||||||
outputs.dir( archiveDir )
|
|
||||||
|
|
||||||
dependsOn project.tasks.processTemplateResources
|
|
||||||
|
|
||||||
from processedTemplateDir.get().asFile
|
|
||||||
|
|
||||||
destinationDirectory = archiveDir
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
user = credentials.'personal.bintray.user'
|
|
||||||
key = credentials.'personal.bintray.key'
|
|
||||||
|
|
||||||
filesSpec {
|
|
||||||
from templateTgz
|
|
||||||
from templateZip
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg {
|
|
||||||
userOrg = 'hibernate'
|
|
||||||
repo = 'generic'
|
|
||||||
name = 'orm-project-template'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task assembleDist( dependsOn: [tasks.templateTgz, tasks.templateZip] )
|
|
||||||
task release( dependsOn: tasks.assembleDist )
|
|
||||||
|
|
||||||
tasks.publish {
|
|
||||||
dependsOn tasks.assembleDist
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.bintrayUpload {
|
|
||||||
dependsOn tasks.assembleDist
|
|
||||||
doFirst {
|
|
||||||
if ( credentials.'personal.bintray.user' == null ) {
|
|
||||||
throw new GradleException( "BinTray user not known, cannot perform upload" );
|
|
||||||
}
|
|
||||||
if ( credentials.'personal.bintray.key' == null ) {
|
|
||||||
throw new GradleException( "BinTray API key not known, cannot perform upload" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( version.toString().endsWith( "-SNAPSHOT" ) ) {
|
|
||||||
tasks.bintrayUpload.enabled = false
|
|
||||||
tasks.release.dependsOn tasks.publish
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tasks.publish.enabled = false
|
|
||||||
tasks.release.dependsOn tasks.bintrayUpload
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
A template project to help bootstrap a Gradle project with support for Hibernate
|
|
||||||
specific extensions.
|
|
||||||
|
|
||||||
This might be useful for new users wanting to get started as well as a quick way to
|
|
||||||
bootstrap project for test cases (bug reports, etc)
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
|
||||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ###################################################################################
|
|
||||||
// again, needed to be able to consume `org.hibernate.orm` plugin SNAPSHOTS
|
|
||||||
buildscript {
|
|
||||||
configurations {
|
|
||||||
classpath {
|
|
||||||
resolutionStrategy {
|
|
||||||
cacheChangingModulesFor(0, java.util.concurrent.TimeUnit.SECONDS )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ###################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
java
|
|
||||||
|
|
||||||
// todo : find a way to inject this version
|
|
||||||
// - this is yet another example of where lazybones
|
|
||||||
// (or proper Gradle build-init feature) would be
|
|
||||||
// incredibly useful. Same with groupId, package-name,
|
|
||||||
// etc.
|
|
||||||
id( "org.hibernate.orm" ) version "@ormVersion@"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "your.org"
|
|
||||||
version = "the-version"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
val ormVersion = "@ormVersion@"
|
|
||||||
val junit5Version = "5.3.1"
|
|
||||||
val h2Version = "1.4.199"
|
|
||||||
|
|
||||||
implementation( "org.hibernate.orm", "hibernate-core", ormVersion )
|
|
||||||
|
|
||||||
testImplementation( "org.hibernate.orm", "hibernate-testing", ormVersion )
|
|
||||||
testImplementation( "org.junit.jupiter", "junit-jupiter-api", junit5Version )
|
|
||||||
testImplementation( "org.junit.jupiter", "junit-jupiter-params", junit5Version )
|
|
||||||
|
|
||||||
testRuntimeOnly( "org.junit.jupiter", "junit-jupiter-engine", junit5Version )
|
|
||||||
testRuntimeOnly( "com.h2database", "h2", h2Version )
|
|
||||||
testRuntimeOnly( "org.jboss.logging", "jboss-logging", "3.3.2.Final" )
|
|
||||||
testRuntimeOnly( "log4j", "log4j", "1.2.17" )
|
|
||||||
}
|
|
||||||
|
|
||||||
hibernate {
|
|
||||||
enhancement {
|
|
||||||
// all false by default
|
|
||||||
lazyInitialization = true
|
|
||||||
dirtyTracking = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task( "compile" ) {
|
|
||||||
dependsOn( tasks.compileJava )
|
|
||||||
dependsOn( tasks.compileTestJava )
|
|
||||||
dependsOn( tasks.processResources )
|
|
||||||
dependsOn( tasks.processTestResources )
|
|
||||||
}
|
|
||||||
|
|
||||||
configure<JavaPluginConvention> {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
|
||||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
|
||||||
*/
|
|
||||||
rootProject.name = "my-hibernate-project"
|
|
||||||
|
|
||||||
// ###################################################################################
|
|
||||||
// A lot of magic to be able to consumer SNAPSHOT versions of the Hibernate ORM plugin...
|
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven {
|
|
||||||
name = "jboss-snapshots-repository"
|
|
||||||
url = uri( "https://repository.jboss.org/nexus/content/repositories/snapshots" )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resolutionStrategy {
|
|
||||||
eachPlugin {
|
|
||||||
if ( requested.id.namespace == "org.hibernate"
|
|
||||||
&& requested.id.name == "orm"
|
|
||||||
&& requested.version.orEmpty().endsWith("-SNAPSHOT" ) ) {
|
|
||||||
val notation = "org.hibernate.orm:hibernate-gradle-plugin:${requested.version}"
|
|
||||||
logger.lifecycle( "Swapping SNAPSHOT version of plugin : {}", notation )
|
|
||||||
useModule( notation )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ###################################################################################
|
|
|
@ -1,38 +0,0 @@
|
||||||
package org.your.domain;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple example entity
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
public class SimpleEntity {
|
|
||||||
@Id
|
|
||||||
private Integer id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private SimpleEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleEntity(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleEntity(Integer id, String name) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package org.your.domain;
|
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
||||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static com.arjuna.ats.internal.jdbc.recovery.JDBCXARecovery.PASSWORD;
|
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hibernate.cfg.AvailableSettings.URL;
|
|
||||||
import static org.hibernate.cfg.AvailableSettings.USER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for SimpleEntity
|
|
||||||
*/
|
|
||||||
@ServiceRegistry(
|
|
||||||
settings = {
|
|
||||||
// can define settings here, or in `hibernate.properties` file
|
|
||||||
@Setting( name = URL, value = "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000" ),
|
|
||||||
@Setting( name = USER, value = "sa" ),
|
|
||||||
@Setting( name = PASSWORD, value = "" )
|
|
||||||
}
|
|
||||||
)
|
|
||||||
@DomainModel( annotatedClasses = SimpleEntity.class )
|
|
||||||
@SessionFactory()
|
|
||||||
public class EntityTests {
|
|
||||||
@Test
|
|
||||||
public void basicTest(SessionFactoryScope scope) {
|
|
||||||
scope.inTransaction(
|
|
||||||
session -> {
|
|
||||||
final SimpleEntity entity = session.createQuery( "from SimpleEntity", SimpleEntity.class ).uniqueResult();
|
|
||||||
assertThat( entity, notNullValue() );
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void createTestData(SessionFactoryScope scope) {
|
|
||||||
scope.inTransaction(
|
|
||||||
session -> session.persist( new SimpleEntity( 1, "the first" ) )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void dropTestData(SessionFactoryScope scope) {
|
|
||||||
scope.inTransaction(
|
|
||||||
session -> session.createQuery( "delete SimpleEntity" ).executeUpdate()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
|
||||||
log4j.appender.stdout.Target=System.out
|
|
||||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
|
||||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
|
||||||
|
|
||||||
log4j.rootLogger=warn, stdout
|
|
||||||
log4j.logger.org.hibernate=info
|
|
Loading…
Reference in New Issue