0

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.

Dan Cornilescu
  • 6,780
  • 2
  • 21
  • 45
Thufir
  • 101
  • 1

1 Answers1

2

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