We wrote a little Shell-Script to achieve this:
#!/bin/bash
echo "Undeploy old war"
curl -S -H "content-Type: application/json" -d '{"operation":"undeploy", "address":[{"deployment":"old.war"}]}' --digest http://user:password@hostname:9990/management
echo ""
echo "Remove old war"
curl -S -H "content-Type: application/json" -d '{"operation":"remove", "address":[{"deployment":"old.war"}]}' --digest http://user:password@hostname:9990/management
echo ""
echo "Upload new war"
bytes_value=`curl -F "file=@/path/to/new.war" --digest http://user:password@$hostname:9990/management/add-content | perl -pe 's/^.*"BYTES_VALUE"\s*:\s*"(.*)".*$/$1/'`
echo $bytes_value
json_string_start='{"content":[{"hash": {"BYTES_VALUE" : "'
json_string_end='"}}], "address": [{"deployment":"new.war"}], "operation":"add", "enabled":"true"}'
json_string="$json_string_start$bytes_value$json_string_end"
echo "Deploy new war"
result=`curl -S -H "Content-Type: application/json" -d "$json_string" --digest http://user:password@hostname:9990/management | perl -pe 's/^.*"outcome"\s*:\s*"(.*)".*$/$1/'`
echo $result
if [ "$result" != "success" ]; then
exit -1
fi
First of all the old WAR-File is going to be removed. After that the new archive is beeing uploaded and deployed. For us this works even if no content has been deployed yet. In this case the first two calls will fail but the new content is going to be deployed anyway.
We were able to reduce the deployment time from about 20 to 4 minutes by switching from Wildfly Maven-Plugin to this script!
Hope that helps. Cheers