isobretatel
isobretatel

Reputation: 3930

Gretty: How do I specify path to war file?

I am using Jetty Gradle plugin, and trying to port my script to use Gretty. The following works with Jetty Gradle plugin:

jettyRunWar {
    // do not use "war" task, use myCustomWarTask
    dependsOn myCustomWarTask
    dependsOn.remove("war")

    webApp = myCustomWarTask.archivePath
}

Ho do I achieve the same in Gretty?

Upvotes: 0

Views: 3047

Answers (2)

LukeB
LukeB

Reputation: 58

Not sure if anyone else has run into this recently, but for the sake of posterity, I just use:

gradlew appRunWar

There is also support for farms using:

gradlew farmRunWar

Upvotes: 0

Hannah Schultz
Hannah Schultz

Reputation: 573

First, you may want some pretty basic gretty setup:

buildscript {
    repositories {
        // You can declare any Maven/Ivy/file repository here.
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'org.akhikhl.gretty:gretty:1.4.0'
    }
}

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'org.akhikhl.gretty'

gretty {
    servletContainer = 'jetty9'

    httpEnabled = true
    httpPort = 8081
    contextPath = '/WebServer'
    jvmArgs { '-ea' }

    loggingLevel = 'ALL' // options:   'ALL', 'DEBUG', 'ERROR', 'INFO', 'OFF', 'TRACE', 'WARN'
}

Once you have that, you can setup a webapp in a farm. Specify the path to your war file here (the provided example is where the GWT plugin is putting mine).

farm {
    webapp 'build/libs/web_server.war'
}

To specify the dependency:

project.afterEvaluate {
    tasks.farmRun.dependsOn myCustomWarTask
}

Once you have all this in place, 'gradle farmRun' will build and run your war file in Gretty.

Upvotes: 0

Related Questions