Produce an Hibernate ORM feature pack, use Wildfly Provisioning to test it

This commit is contained in:
Sanne Grinovero 2018-02-05 23:10:02 +00:00
parent 4625418464
commit 69ed07217e
6 changed files with 103 additions and 145 deletions

View File

@ -1,5 +1,3 @@
import org.apache.tools.ant.filters.ReplaceTokens
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
@ -8,7 +6,8 @@ import org.apache.tools.ant.filters.ReplaceTokens
*/ */
plugins { plugins {
id "org.wildfly.build.provision" version "0.0.3" id "org.wildfly.build.provision" version '0.0.5'
id "org.wildfly.build.featurepack" version '0.0.5'
} }
apply from: rootProject.file( 'gradle/base-information.gradle' ) apply from: rootProject.file( 'gradle/base-information.gradle' )
@ -28,171 +27,123 @@ project.tasks.jar.enabled = false
project.tasks.javadoc.enabled = false project.tasks.javadoc.enabled = false
ext { ext {
// NOTE : `wildflyVersion` comes from libraries.gradle... // NOTE : `wildflyVersion` comes from libraries.gradle...
// Exact ORM version, e.g. "5.1.1.Final" // "10" for WildFly 10.x, "11" for 11.x, etc
slot = rootProject.hibernateVersion wildFlyMajorVersion = project.wildflyVersion.split( '\\.' )[0]
// Just the minor ORM version, e.g. "5.1"; Is used as an alias for the exact version artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
minorSlot = rootProject.hibernateMajorMinorVersion wildFlyInstallDir = "$rootProject.buildDir/wildfly"
fpackStagingDir = file( "target/featurepack" ) //Target build directory for the Feature Pack
// "10" for WildFly 10.x, "11" for 11.x, etc
wildFlyMajorVersion = project.wildflyVersion.split( '\\.' )[0]
artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
moduleXmlStagingDir = file( "$buildDir/tmp/modules" )
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}"
expandedModuleProperties = [
slot: slot,
minorSlot: minorSlot,
version: project.hibernateVersion,
wildflyVersion: wildflyVersion,
byteBuddyVersion: byteBuddyVersion
]
} }
description = "Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}" description = "Feature Pack of Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}"
configurations { configurations {
jipijapa { featurePack {
transitive = false description = "Dependencies to be included in the published Feature Pack"
} }
provisioning {
description = "Dependencies which should be made available to the provisioning of WildFly"
}
}
wildflyJPA22Patch repositories {
byteBuddy mavenLocal()
mavenCentral()
maven {
name 'jboss-nexus'
url "http://repository.jboss.org/nexus/content/groups/public/"
}
}
//This builds the WildFly Feature Packs which define the Hibernate ORM modules
// # Definitions of the modules are in /module-templates
// # Versions of the included libraries are defined in the "featurePack" configuration (below)
// # See the "variables" option to replace tokens in the module definitions
// # This just creates the exploded feature pack: does NOT create a zip nor a publication, which are handled by other tasks below.
featurepack {
moduleTemplates = file( 'module-templates' ) //where to find the templates for module.xml files to generate
destinationDir = project.fpackStagingDir
configurationName 'featurePack'
// Variables to be replaced in the template. N.B. not all variables need to be replaced!
// Exact ORM version, e.g. "5.3.0.Final"
variables['slot'] = rootProject.hibernateVersion
// Just the minor ORM version, e.g. "5.3"; Is used as an alias for the exact version
variables['minorSlot'] = rootProject.hibernateMajorMinorVersion
//Dependency on another Feature Pack:
dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default
}
task createFeaturePackZip( type: Zip, dependsOn: [featurepack] ) {
baseName 'hibernate-orm-modules'
from project.fpackStagingDir
} }
provision { provision {
configuration = file('wildfly-server-provisioning.xml') dependsOn( createFeaturePackZip )
destinationDir = file("$project.wildFlyInstallDir") dependsOn( ":hibernate-envers:jar")
override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) { dependsOn( ":hibernate-core:jar")
groupId = 'javax.persistence' configuration = file( 'wildfly-server-provisioning.xml' )
artifactId = 'javax.persistence-api' destinationDir = file( "$project.wildFlyInstallDir" )
version = '2.2' //Replace the JPA API with version 2.2 in the provisioned WildFly server:
} override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
groupId = 'javax.persistence'
artifactId = 'javax.persistence-api'
version = '2.2'
}
//TODO: explore overriding any other library we might need?
override( 'org.hibernate.common:hibernate-commons-annotations' ) {
version = '5.0.2.Final'
}
variables['wildfly.version'] = project.wildflyVersion
variables['hibernate-orm.version'] = rootProject.hibernateVersion
} }
dependencies { dependencies {
jipijapa "org.wildfly:jipijapa-hibernate5:${wildflyVersion}" testCompile project( ":hibernate-core" )
byteBuddy libraries.byteBuddy testCompile project( ":hibernate-envers" )
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
testCompile project( ":hibernate-core" ) featurePack libraries.byteBuddy
testCompile project( ":hibernate-envers" ) featurePack project( ":hibernate-core" )
testCompile libraries.junit featurePack project( ":hibernate-envers" )
testCompile libraries.arquillian_junit_container featurePack "org.wildfly:jipijapa-hibernate5:${wildflyVersion}"
testCompile libraries.arquillian_protocol_servlet
testCompile libraries.shrinkwrap_descriptors_api_javaee
testCompile libraries.shrinkwrap_descriptors_impl_javaee
testCompile libraries.wildfly_arquillian_container_managed
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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'
inputs.properties( expandedModuleProperties as Map )
into moduleXmlStagingDir
expand( expandedModuleProperties as Map )
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'
}
// create alias for the short name
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'
}
}
task createModulesZip(type: Zip, dependsOn: [copyAndExpandModuleXml]) {
baseName 'hibernate-orm-modules'
classifier artifactClassifier
from moduleXmlStagingDir
into( 'org/hibernate/' + slot ) {
from parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
from parent.project( 'hibernate-envers' ).configurations.archives.allArtifacts.files
// also need Byte Buddy's jar
from configurations.byteBuddy
}
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
}
} }
publishing { publishing {
publications { publications {
publishedArtifacts { publishedArtifacts {
artifact( createModulesZip ) { artifact( createFeaturePackZip ) {
classifier artifactClassifier }
} }
} }
}
} }
task ciBuild( dependsOn: [clean, test, publish] ) task ciBuild( dependsOn: [clean, test, publish] )
task release( dependsOn: [clean, test, bintrayUpload] ) task release( dependsOn: [clean, test, bintrayUpload] )
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// tasks related to in-container (Arquillian + WF) testing // tasks related to in-container (Arquillian + WF) testing
task installWildFly( dependsOn: [createModulesZip, provision] ) { task prepareWildFlyForTests( dependsOn: [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' description = 'Downloads the WildFly distribution, installs it into a local directory, includes present version of Hibernate ORM, JPA 2.2 : ready for integration tests'
doLast {
// install the Hibernate ORM modules from the current build
copy {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
from zipTree( createModulesZip.archivePath )
into "${project.wildFlyInstallDir}/modules"
}
}
} }
task installHibernateModule( dependsOn: [createModulesZip, installWildFly])
task prepareWildFlyForTests( dependsOn: [installHibernateModule] )
test.dependsOn prepareWildFlyForTests test.dependsOn prepareWildFlyForTests
processTestResources { processTestResources {
expand([ expand(
wildFlyInstallDir: project.wildFlyInstallDir, [
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments" wildFlyInstallDir : project.wildFlyInstallDir,
]) arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
]
)
} }

View File

@ -7,9 +7,9 @@
--> -->
<module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="${slot}"> <module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="${slot}">
<resources> <resources>
<resource-root path="hibernate-core-${version}.jar"/> <artifact name="${org.hibernate:hibernate-core}"/>
<resource-root path="hibernate-envers-${version}.jar"/> <artifact name="${org.hibernate:hibernate-envers}"/>
<resource-root path="byte-buddy-${byteBuddyVersion}.jar"/> <artifact name="${net.bytebuddy:byte-buddy}"/>
</resources> </resources>
<dependencies> <dependencies>

View File

@ -11,7 +11,7 @@
</properties> </properties>
<resources> <resources>
<resource-root path="jipijapa-hibernate5-${wildflyVersion}.jar"/> <artifact name="${org.wildfly:jipijapa-hibernate5}"/>
</resources> </resources>
<dependencies> <dependencies>

View File

@ -1,8 +1,15 @@
<!-- Use of copy-module-artifacts is essential to make sure we use the current
builds rather than whatever stale snapshot one might have in local Maven
repositories: JBoss Modules would otherwise load jars from the local Maven -->
<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true"> <server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
<feature-packs> <feature-packs>
<feature-pack <feature-pack
groupId="org.wildfly" groupId="org.hibernate"
artifactId="wildfly-feature-pack" artifactId="hibernate-orm-modules"
version="11.0.0.Final" /> version="${hibernate-orm.version}" />
<feature-pack
groupId="org.wildfly"
artifactId="wildfly-feature-pack"
version="${wildfly.version}" />
</feature-packs> </feature-packs>
</server-provisioning> </server-provisioning>