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 . */ plugins { id "org.wildfly.build.provision" version "0.0.3" } apply from: rootProject.file( 'gradle/base-information.gradle' ) apply plugin: 'java' apply from: rootProject.file( 'gradle/libraries.gradle' ) apply plugin: 'maven-publish' apply plugin: 'maven-publish-auth' apply from: rootProject.file( 'gradle/publishing-repos.gradle' ) apply from: rootProject.file( 'gradle/publishing-pom.gradle' ) apply plugin: 'build-dashboard' apply plugin: 'project-report' apply plugin: 'idea' project.tasks.jar.enabled = false project.tasks.javadoc.enabled = false ext { // NOTE : `wildflyVersion` comes from libraries.gradle... // Exact ORM version, e.g. "5.1.1.Final" slot = rootProject.hibernateVersion // Just the minor ORM version, e.g. "5.1"; Is used as an alias for the exact version minorSlot = rootProject.hibernateMajorMinorVersion // "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}" configurations { jipijapa { transitive = false } wildflyJPA22Patch byteBuddy } provision { configuration = file('wildfly-server-provisioning.xml') destinationDir = file("$project.wildFlyInstallDir") override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) { groupId = 'javax.persistence' artifactId = 'javax.persistence-api' version = '2.2' } } dependencies { jipijapa "org.wildfly:jipijapa-hibernate5:${wildflyVersion}" byteBuddy libraries.byteBuddy testCompile project( ":hibernate-core" ) 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 } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 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 { publications { publishedArtifacts { artifact( createModulesZip ) { classifier artifactClassifier } } } } task ciBuild( dependsOn: [clean, test, publish] ) task release( dependsOn: [clean, test, bintrayUpload] ) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // tasks related to in-container (Arquillian + WF) testing 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' 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 processTestResources { expand([ wildFlyInstallDir: project.wildFlyInstallDir, arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments" ]) }