Maven users: invoke the WildFly Provisioning Plugin

Assuming the previous Provisioning Configuration File is saved as server-provisioning.xml, you will just have to refer the plugin to it, pick an output directory name and bing the plugin to the build lifecycle.

Example 3. Example Maven Provisioning

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.wildfly.build</groupId>
  5. <artifactId>wildfly-server-provisioning-maven-plugin</artifactId>
  6. <executions>
  7. <execution>
  8. <id>server-provisioning</id>
  9. <goals>
  10. <goal>build</goal>
  11. </goals>
  12. <phase>compile</phase>
  13. <configuration>
  14. <config-file>server-provisioning.xml</config-file>
  15. <server-name>wildfly-custom</server-name>
  16. </configuration>
  17. </execution>

JPA version override

With WildFly 12 being built with JavaEE7 in mind, it ships the JPA 2.1 API.

Hibernate ORM 5.3 requires JPA 2.2, and it is not possible at this time to replace the JPA API using the Maven provisioning plugin so you’ll have to apply a “WildFly patch” as well.

A WildFly patch can be applied from the WildFly CLI; here we show how to automate it all with Maven plugins.

Example 4. Example Maven script to patch the JPA version in WildFly:

  1. <plugin>
  2. <artifactId>maven-dependency-plugin</artifactId>
  3. <executions>
  4. <execution>
  5. <id>fetch-jpa-patch</id>
  6. <phase>process-test-resources</phase>
  7. <goals>
  8. <goal>copy</goal>
  9. </goals>
  10. <configuration>
  11. <artifactItems>
  12. <artifactItem>
  13. <groupId>org.hibernate.javax.persistence</groupId>
  14. <artifactId>hibernate-jpa-api-2.2-wildflymodules</artifactId>
  15. <classifier>wildfly-12.0.0.Final-patch</classifier>
  16. <version>1.0.0.Beta2</version>
  17. <type>zip</type>
  18. <outputDirectory>${project.build.directory}</outputDirectory>
  19. <overWrite>true</overWrite>
  20. <destFileName>hibernate-jpa-api-2.2-wildflymodules-patch.zip</destFileName>
  21. </artifactItem>
  22. </artifactItems>
  23. </configuration>
  24. </execution>
  25. </executions>
  26. </plugin>
  27. <plugin>
  28. <groupId>org.wildfly.plugins</groupId>
  29. <artifactId>wildfly-maven-plugin</artifactId>
  30. <executions>
  31. <execution>
  32. <id>apply-wildfly-jpa22-patch-file</id>
  33. <phase>pre-integration-test</phase>
  34. <goals>
  35. <goal>execute-commands</goal>
  36. </goals>
  37. <configuration>
  38. <offline>true</offline>
  39. <jbossHome>${jbossHome.provisionedPath}</jbossHome>
  40. <!-- The CLI script below will fail if the patch was already applied in a previous build -->
  41. <fail-on-error>false</fail-on-error>
  42. <commands>
  43. <command>patch apply --override-all ${project.build.directory}/hibernate-jpa-api-2.2-wildflymodules-patch.zip</command>
  44. </commands>
  45. </configuration>
  46. </execution>
  47. </executions>
  48. </plugin>