0

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?

isobretatel
  • 3,812
  • 7
  • 34
  • 49
  • As far as I see gretty doesn't work that way. You can run the application from the source code directly. – Opal Aug 25 '16 at 07:24

2 Answers2

0

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.

Community
  • 1
  • 1
Hank Schultz
  • 553
  • 5
  • 11
0

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
LukeB
  • 58
  • 4