170 lines
5.4 KiB
Groovy
170 lines
5.4 KiB
Groovy
/*
|
|
* 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>.
|
|
*/
|
|
apply plugin: 'base'
|
|
apply plugin: 'maven'
|
|
|
|
ext {
|
|
// Exact ORM version, e.g. "5.1.1.Final"
|
|
slot = rootProject.hibernateTargetVersion
|
|
|
|
// Just the minor ORM version, e.g. "5.1"; Is used as an alias for the exact version
|
|
minorSlot = slot.substring( 0, slot.indexOf( ".", slot.indexOf( "." ) + 1) )
|
|
|
|
majorWildflyVersion = wildflyVersion.substring( 0, wildflyVersion.indexOf( "." ) )
|
|
|
|
// directory for building the ZIP file from
|
|
modulesDirectory = "$buildDir/hibernate-orm-modules"
|
|
}
|
|
|
|
configurations {
|
|
jipijapa
|
|
wildflyDist
|
|
}
|
|
|
|
dependencies {
|
|
jipijapa "org.wildfly:jipijapa-hibernate5:${wildflyVersion}"
|
|
wildflyDist "org.wildfly:wildfly-dist:${wildflyVersion}@zip"
|
|
|
|
testCompile project( ":hibernate-core" )
|
|
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
|
|
}
|
|
|
|
/*************************/
|
|
/* Main */
|
|
/*************************/
|
|
|
|
// Copies all the module.xml descriptors into the output directory
|
|
task copyModuleXmls(type: Copy) {
|
|
into( modulesDirectory )
|
|
expand( slot: slot, minorSlot: minorSlot, version: rootProject.hibernateTargetVersion, wildflyVersion: wildflyVersion )
|
|
|
|
// Actual module.xml files
|
|
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'
|
|
}
|
|
|
|
// Aliases
|
|
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'
|
|
}
|
|
}
|
|
|
|
// Copies all the ORM JARs and the JipiJapa JAR into the output directory
|
|
task copyJars(dependsOn: copyModuleXmls, type: Copy) {
|
|
into( modulesDirectory )
|
|
|
|
into( 'org/hibernate/' + slot ) {
|
|
from parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
|
|
from parent.project( 'hibernate-envers' ).configurations.archives.allArtifacts.files
|
|
from parent.project( 'hibernate-entitymanager' ).configurations.archives.allArtifacts.files
|
|
from parent.project( 'hibernate-java8' ).configurations.archives.allArtifacts.files
|
|
}
|
|
|
|
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 ) {
|
|
from configurations.jipijapa.copy().setTransitive( false )
|
|
}
|
|
}
|
|
|
|
// Creates a ZIP from the output directory
|
|
task createModulesZip(dependsOn: copyJars, type: Zip) {
|
|
classifier = "wildfly-${majorWildflyVersion}-dist"
|
|
from modulesDirectory
|
|
}
|
|
|
|
/*************************/
|
|
/* Testing */
|
|
/*************************/
|
|
|
|
// Unzip Wildfly Dist
|
|
task extractWildFly(type: Copy) {
|
|
from {
|
|
configurations.wildflyDist.collect { zipTree(it) }
|
|
}
|
|
into "$buildDir/"
|
|
}
|
|
|
|
// Unzip Hibernate ORM Modules ZIP into the server's "modules" dir
|
|
task extractModules(dependsOn: [extractWildFly, createModulesZip], type: Copy) {
|
|
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
|
from zipTree( createModulesZip.archivePath )
|
|
into "$buildDir/wildfly-${wildflyVersion}/modules"
|
|
}
|
|
|
|
// Replace properties in arquillian.xml; Actually this should be done by means of configuring
|
|
// the processTestResourcesTask itself, but while that works for resources in src/main/resources,
|
|
// the same failed for src/test/resources; I reckon it's a bug in Gradle
|
|
task filterArquillianXml(dependsOn: processTestResources, type: Copy) {
|
|
into( buildDir.getName() + '/resources/test' )
|
|
expand( buildDir: buildDir.getName(), wildflyVersion: wildflyVersion )
|
|
from 'src/test/resources'
|
|
}
|
|
|
|
test.dependsOn extractModules
|
|
test.dependsOn filterArquillianXml
|
|
|
|
build.dependsOn createModulesZip
|
|
|
|
// Exclude JAR creation/publication inherited from parent
|
|
afterEvaluate {
|
|
tasks.withType(PublishToMavenLocal) { task ->
|
|
if (task.publication.name.equals( 'mavenJava') ) {
|
|
task.enabled = false
|
|
task.group = null
|
|
}
|
|
}
|
|
|
|
tasks.withType(PublishToMavenRepository) { task ->
|
|
if (task.publication.name.equals( 'mavenJava') ) {
|
|
task.enabled = false
|
|
task.group = null
|
|
}
|
|
}
|
|
|
|
tasks.withType(Jar) { task ->
|
|
task.enabled = false
|
|
task.group = null
|
|
}
|
|
}
|
|
|
|
mavenPom {
|
|
name = "Hibernate ORM modules for WildFly ${majorWildflyVersion}"
|
|
description = "Hibernate ORM modules for WildFly ${majorWildflyVersion}"
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenZip( MavenPublication ) {
|
|
artifact createModulesZip
|
|
}
|
|
}
|
|
}
|