I'm getting a bit deeper into Gradle and want to further automate the process. Generally speaking what are the approaches towards interacting with application servers?

I'd want to automate deploying an EAR. Is there even a need, or case to be made, to step out of Gradle for that purpose?

I imagine it's much the same regardless whether it's EAR or WAR files and regardless of the specific application server -- but I'm using Glassfish.

1 Answer 1


If you want just to deploy faster to server(propably not only Glassfish) you can just write code in gradle to do that. Example taken from here

 *  ~/.gradle/gradle.properties:
 *  glassfishHome=/path/to/glassfish_home
 *  or in Netbeans, right click project, Properties, Manage Build in Tasks, Run
 *  Add line to Arguments: -Dorg.gradle.project.glassfishHome=/path/to/glassfish_home
 *  For more information about Exec tasks see
 *  http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Exec.html
task run(dependsOn: 'war', type:Exec) {
    workingDir "${glassfishHome}${File.separator}bin"

    if (System.properties['os.name'].toLowerCase().contains('windows')) {
        commandLine 'cmd', '/c', 'asadmin.bat'
    } else {
        commandLine "./asadmin"

    args "deploy", "--force=true", "${war.archivePath}"
//from: https://www.schuermann.eu/2013/08/03/gradle-glassfish.html

In other words just use your asadmin

  • I was thinking there might be a plug-in or API to interface with asadmin. this is not such a typical task? most use some other approach?
    – Thufir
    Aug 24, 2017 at 1:53
  • 2
    Usually you will have some kind of CI(like jenkins) which will compile/deploy your code from repository. There are some plugins in gradle, but usually they just deploy to local/integrated glassfish instance. In Maven it is made by normal asadmin too. Aug 24, 2017 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.