While working on automatically deploying a maven artifact to a WildFly server using the WildFly Maven Plugin, I could not find a full working example on the corresponding webpage. It took quite some time, even if it is not much code. Below is everything you need to deploy a maven artifact to WildFly.
This is the pom.xml I use for deploying to a local WildFly server. The pom file below can also be used for a remote deploy, however. I am using WidFly 14 for the example provided below.
4.0.0
com.illucit
wildfly-deploy
1.0.0
pom
com.illucit
ArtifactIWantToDeploy
ear
${artifact.version}
org.wildfly.plugins
wildfly-maven-plugin
2.0.0.Final
localhost
8080
deploy_server
com.illucit
ArtifactIWantToDeploy
ArtifactIWantToDeploy.ear
install
deploy-artifact
illucit_artifactory
illucIT Artifatory
https://myartifactory.illucit.com
In order for being able to deploy to WildFly, you first have to create a new Management user by executing add-user.bat or add-user.sh in the bin directory of WildFly.
After that you have to store those credentials and the credentials of your maven repository in the home directory of the current user under .m2/settings.xml. In my example the artifact I am deploying is hosted on a private repository….
deploy_server
wildfly_management_user
xxx
illucit_artifactory
artifactory_user
xxx
The ids in the settings.xml have to match the server you want to deploy to (deploy_server in my example) and the maven repository where the artifact is stored (illucit_artifactory in my example).
The pom.xml also contains a variable for the corresponding artifact version that you want to deploy ( ${artifact.version} ).
Please also replace the mentioned artifact ArtifactIWantToDeploy with your corresponding maven artifact in the example above.
After setting everything up this way, you can simply do a deploy by running the maven command below in the same directory as the pom.xml provided above.
mvn wildfly:deploy-artifact -Dartifact.version="3.2.1"
I hope this full example can help someone save an hour or two…
If you have any question or comments, please leave a message below!