Background:
- test classes(such as selenium tests) are in an independent module(maven project, etc.).
- have an external dependency(mave, ivy, etc) to war file(s)
- want to run jetty on dependent war file(s)
Gradle can start up jetty on dependency resolved war file(s).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run Jetty on dependency resolved war file | |
// | |
// you can run multiple wars with different configuration by | |
// adding more task definitions. | |
// | |
import org.gradle.api.plugins.jetty.JettyRunWar | |
apply plugin: 'java' | |
apply plugin: 'jetty' | |
repositories { | |
mavenCentral() | |
} | |
configurations { | |
// define custom dependency configuration for war file | |
myWebApp | |
} | |
dependencies { | |
// add war file dependency to my custom configuration | |
myWebApp "org.some:my-app:1.0@war" | |
} | |
task runMyWebApp(type: JettyRunWar) { | |
// specify the resolved war file | |
webApp = configurations.myWebApp.singleFile | |
// more configuration | |
httpPort = 8001 | |
contextPath = 'myWebApp' | |
} |
When you want to run your tests after jetty started, set "daemon=true" and make the test task depends on your new run-war task.