Gradle users: invoke the WildFly Provisioning plugin
A Gradle plugin is also available, and in this case it will take just a couple of lines.
Remember when creating a “thin server”: the WildFly classloader will not be able to load jars from the local Gradle cache: this might trigger a second download as it looks into local Maven repositories exclusively. Especially if you are developing additional feature packs using Gradle, make sure to publish them into a Maven repository so that WildFly can load them.
Follows a full Gradle build script; in contrast to the previous Maven example which is incomplete to keep it short, is a fully working build script. Also it won’t require to apply additional patches to replace the JPA version.
Example 5. Example Gradle Provisioning
plugins {
id "org.wildfly.build.provision" version '0.0.6'
}
repositories {
mavenLocal()
mavenCentral()
maven {
name 'jboss-public'
url 'https://repository.jboss.org/nexus/content/groups/public/'
}
}
provision {
//Optional destination directory:
destinationDir = file("wildfly-custom")
//Update the JPA API:
override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
groupId = 'javax.persistence'
artifactId = 'javax.persistence-api'
version = '2.2'
}
configuration = file( 'wildfly-server-provisioning.xml' )
//Define variables which need replacing in the provisioning configuration!
variables['wildfly.version'] = '12.0.0.Final'
variables['hibernate-orm.version'] = '5.3.0.Final'
}
you could paste this into a new file named build.gradle
in an empty directory, then invoke:
gradle provision
and you’ll have a full WildFly 12.0.0.Final server generated in the wildfly-custom
subdirectory, including a copy of Hibernate ORM version 5.3.0.Final (in addition to the any other version that WildFly normally includes).
A note on repositories:
mavenLocal()
strictly not necessary but will make your builds much faster if you run it more than once.
jboss-nexus
This additional repository is required. Most components of WildFly are available in Maven Central but there are some occasional exceptions.
The JPA version override
The JPA API is a fundamental component of the application server as it is used to integrate with various other standards; at this stage while the feature packs offer some degree of composability it is not yet possible to have additional, independent copies of the JPA API: it needs to be replaced.
Hibernate ORM 5.3.0 requires JPA 2.2, yet WildFly 12 ships with JPA version 2.1. Luckily this provisioning tool is also able to override any artifact resolution.
Of course when future versions of WildFly will be based on JPA 2.2, this step might soon no longer be necessary.