2018-01-10 22:30:45 -05:00
import org.apache.tools.ant.filters.ReplaceTokens
2016-06-27 08:07:08 -04:00
/ *
* 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>.
* /
2018-01-10 16:06:58 -05:00
2018-01-20 18:05:40 -05:00
plugins {
2018-01-21 21:07:59 -05:00
id "org.wildfly.build.provision" version "0.0.3"
2018-01-20 18:05:40 -05:00
}
2018-01-10 22:30:45 -05:00
apply from: rootProject . file ( 'gradle/base-information.gradle' )
2016-06-29 16:48:20 -04:00
apply plugin: 'java'
2018-01-10 22:30:45 -05:00
apply from: rootProject . file ( 'gradle/libraries.gradle' )
2016-06-29 16:48:20 -04:00
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
2018-01-10 22:30:45 -05:00
apply from: rootProject . file ( 'gradle/publishing-repos.gradle' )
2018-01-17 23:47:31 -05:00
apply from: rootProject . file ( 'gradle/publishing-pom.gradle' )
2018-01-10 22:30:45 -05:00
2016-06-29 16:48:20 -04:00
apply plugin: 'build-dashboard'
apply plugin: 'project-report'
apply plugin: 'idea'
2018-01-10 17:52:28 -05:00
project . tasks . jar . enabled = false
project . tasks . javadoc . enabled = false
2018-01-10 16:06:58 -05:00
2016-06-27 08:07:08 -04:00
ext {
2018-01-02 14:47:29 -05:00
// NOTE : `wildflyVersion` comes from libraries.gradle...
2016-06-27 08:07:08 -04:00
// Exact ORM version, e.g. "5.1.1.Final"
2018-01-10 16:06:58 -05:00
slot = rootProject . hibernateVersion
2016-06-27 08:07:08 -04:00
// Just the minor ORM version, e.g. "5.1"; Is used as an alias for the exact version
2016-08-05 11:08:35 -04:00
minorSlot = rootProject . hibernateMajorMinorVersion
2018-01-02 14:47:29 -05:00
// "10" for WildFly 10.x, "11" for 11.x, etc
2018-01-10 16:06:58 -05:00
wildFlyMajorVersion = project . wildflyVersion . split ( '\\.' ) [ 0 ]
2016-08-05 11:08:35 -04:00
artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
2016-06-29 16:48:20 -04:00
2016-08-05 11:08:35 -04:00
moduleXmlStagingDir = file ( "$buildDir/tmp/modules" )
2016-06-27 08:07:08 -04:00
2018-01-02 14:47:29 -05:00
wildFlyInstallDirBase = "$rootProject.buildDir.absolutePath/wildfly"
// this is just a "guess" as to the root directory inside the dist zip
// todo : Would be better to actually ask the zip
wildFlyInstallDir = "$wildFlyInstallDirBase/wildfly-${wildflyVersion}"
2016-08-06 15:05:03 -04:00
expandedModuleProperties = [
slot: slot ,
minorSlot: minorSlot ,
2018-01-10 16:06:58 -05:00
version: project . hibernateVersion ,
2016-08-06 15:05:03 -04:00
wildflyVersion: wildflyVersion ,
2016-10-04 16:43:27 -04:00
byteBuddyVersion: byteBuddyVersion
2018-01-02 14:47:29 -05:00
]
2016-08-05 11:08:35 -04:00
}
2018-01-10 22:30:45 -05:00
description = "Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}"
2016-06-27 08:07:08 -04:00
configurations {
2016-06-29 16:48:20 -04:00
jipijapa {
transitive = false
}
2017-12-15 08:06:32 -05:00
wildflyJPA22Patch
2016-10-04 16:43:27 -04:00
byteBuddy
2016-06-27 08:07:08 -04:00
}
2018-01-20 18:05:40 -05:00
provision {
2018-01-24 09:58:14 -05:00
configuration = file ( 'wildfly-server-provisioning.xml' )
2018-01-20 18:05:40 -05:00
destinationDir = file ( "$project.wildFlyInstallDir" )
2018-01-21 21:07:59 -05:00
override ( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
groupId = 'javax.persistence'
artifactId = 'javax.persistence-api'
version = '2.2'
}
2018-01-20 18:05:40 -05:00
}
2016-06-27 08:07:08 -04:00
dependencies {
jipijapa "org.wildfly:jipijapa-hibernate5:${wildflyVersion}"
2016-10-04 16:43:27 -04:00
byteBuddy libraries . byteBuddy
2016-06-27 08:07:08 -04:00
testCompile project ( ":hibernate-core" )
2016-09-13 15:57:21 -04:00
testCompile project ( ":hibernate-envers" )
2016-06-27 08:07:08 -04:00
testCompile libraries . junit
testCompile libraries . arquillian_junit_container
testCompile libraries . arquillian_protocol_servlet
testCompile libraries . shrinkwrap_descriptors_api_javaee
testCompile libraries . shrinkwrap_descriptors_impl_javaee
testCompile libraries . wildfly_arquillian_container_managed
}
2016-08-05 11:08:35 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// tasks related to creating and publishing the module zip
task copyAndExpandModuleXml ( type: Copy ) {
description 'Performs a copy of the XML files defining the module into a staging directory for the purpose of performing token-replacement'
2016-08-06 15:05:03 -04:00
inputs . properties ( expandedModuleProperties as Map )
2016-08-05 11:08:35 -04:00
into moduleXmlStagingDir
2016-08-06 15:05:03 -04:00
expand ( expandedModuleProperties as Map )
2016-06-27 08:07:08 -04:00
into ( 'org/hibernate/' + slot ) {
from 'src/main/modules/org/hibernate/core'
}
into ( 'org/hibernate/infinispan/' + slot ) {
from 'src/main/modules/org/hibernate/infinispan'
}
into ( 'org/hibernate/jipijapa-hibernate5/' + slot ) {
from 'src/main/modules/org/hibernate/jipijapa-hibernate5'
}
2016-06-29 16:48:20 -04:00
// create alias for the short name
2016-06-27 08:07:08 -04:00
into ( 'org/hibernate/' + minorSlot ) {
from 'src/main/aliases/org/hibernate/core'
}
into ( 'org/hibernate/infinispan/' + minorSlot ) {
from 'src/main/aliases/org/hibernate/infinispan'
}
into ( 'org/hibernate/jipijapa-hibernate5/' + minorSlot ) {
from 'src/main/aliases/org/hibernate/jipijapa-hibernate5'
}
}
2016-08-05 11:08:35 -04:00
task createModulesZip ( type: Zip , dependsOn: [ copyAndExpandModuleXml ] ) {
baseName 'hibernate-orm-modules'
classifier artifactClassifier
2016-06-29 16:48:20 -04:00
2016-08-05 11:08:35 -04:00
from moduleXmlStagingDir
2016-06-27 08:07:08 -04:00
into ( 'org/hibernate/' + slot ) {
from parent . project ( 'hibernate-core' ) . configurations . archives . allArtifacts . files
from parent . project ( 'hibernate-envers' ) . configurations . archives . allArtifacts . files
2016-10-04 16:43:27 -04:00
// also need Byte Buddy's jar
from configurations . byteBuddy
2016-06-27 08:07:08 -04:00
}
into ( 'org/hibernate/infinispan/' + slot ) {
from parent . project ( 'hibernate-infinispan' ) . configurations . archives . allArtifacts . files . filter { file - > ! file . name . endsWith ( '-sources.jar' ) & & ! file . name . endsWith ( '-tests.jar' ) }
}
into ( 'org/hibernate/jipijapa-hibernate5/' + slot ) {
2016-06-29 16:48:20 -04:00
from configurations . jipijapa
2016-06-27 08:07:08 -04:00
}
}
2016-06-29 16:48:20 -04:00
publishing {
publications {
mavenZip ( MavenPublication ) {
artifact ( createModulesZip ) {
classifier artifactClassifier
}
}
}
}
2018-01-10 16:06:58 -05:00
task release ( dependsOn: createModulesZip )
2016-06-29 16:48:20 -04:00
2016-08-05 11:08:35 -04:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// tasks related to in-container (Arquillian + WF) testing
2016-06-27 08:07:08 -04:00
2018-01-20 18:05:40 -05:00
task installWildFly ( dependsOn: [ createModulesZip , provision ] ) {
description = 'Downloads the WildFly distribution, installs it into a local directory, includes present version of Hibernate ORM, JPA 2.2 : ready for integration tests'
2016-06-27 08:07:08 -04:00
2017-12-15 08:06:32 -05:00
doLast {
2018-01-21 21:07:59 -05:00
// install the Hibernate ORM modules from the current build
2018-01-02 14:47:29 -05:00
copy {
duplicatesStrategy DuplicatesStrategy . EXCLUDE
from zipTree ( createModulesZip . archivePath )
2018-01-10 22:30:45 -05:00
into "${project.wildFlyInstallDir}/modules"
2017-12-15 08:06:32 -05:00
}
}
}
2018-01-02 14:47:29 -05:00
task installHibernateModule ( dependsOn: [ createModulesZip , installWildFly ] )
2016-06-27 08:07:08 -04:00
2018-01-20 18:05:40 -05:00
task prepareWildFlyForTests ( dependsOn: [ installHibernateModule ] )
2016-08-05 11:08:35 -04:00
test . dependsOn prepareWildFlyForTests
2016-06-27 08:07:08 -04:00
2016-06-29 16:48:20 -04:00
processTestResources {
2018-01-10 22:30:45 -05:00
expand ( [
wildFlyInstallDir: project . wildFlyInstallDir ,
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
] )
2016-06-27 08:07:08 -04:00
}
2016-08-05 11:08:35 -04:00
2018-01-22 12:28:24 -05:00
if ( project . isSnapshot ) {
// only run the ci build tasks for SNAPSHOT versions
task ciBuild ( dependsOn: [ clean , test ] )
}
else {
task release ( dependsOn: [ clean , test ] )
}