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

  1. plugins {
  2. id "org.wildfly.build.provision" version '0.0.6'
  3. }
  4. repositories {
  5. mavenLocal()
  6. mavenCentral()
  7. maven {
  8. name 'jboss-public'
  9. url 'https://repository.jboss.org/nexus/content/groups/public/'
  10. }
  11. }
  12. provision {
  13. //Optional destination directory:
  14. destinationDir = file("wildfly-custom")
  15. //Update the JPA API:
  16. override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
  17. groupId = 'javax.persistence'
  18. artifactId = 'javax.persistence-api'
  19. version = '2.2'
  20. }
  21. configuration = file( 'wildfly-server-provisioning.xml' )
  22. //Define variables which need replacing in the provisioning configuration!
  23. variables['wildfly.version'] = '12.0.0.Final'
  24. variables['hibernate-orm.version'] = '5.3.0.Final'
  25. }

you could paste this into a new file named build.gradle in an empty directory, then invoke:

  1. 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.