gradle
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| gradle [2021/02/19 00:08] – skipidar | gradle [2021/04/14 07:13] (current) – skipidar | ||
|---|---|---|---|
| Line 138: | Line 138: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | === Fork a Java process from Gradle === | ||
| + | |||
| + | Here a snippet about forking the process, | ||
| + | e.g. for launching the app under test for load tests, contract tests. | ||
| + | |||
| + | It waits for the Spring boot application to come up. | ||
| + | For that it looks at the port 8080 and checks the STDOUT for the string " | ||
| + | |||
| + | |||
| + | Example: | ||
| + | https:// | ||
| + | |||
| + | <sxh java> | ||
| + | |||
| + | buildscript { | ||
| + | repositories { | ||
| + | mavenCentral() | ||
| + | maven { | ||
| + | url ' | ||
| + | } | ||
| + | } | ||
| + | dependencies { | ||
| + | classpath(" | ||
| + | classpath " | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | plugins { | ||
| + | id " | ||
| + | id ' | ||
| + | } | ||
| + | |||
| + | apply plugin: " | ||
| + | |||
| + | jar { | ||
| + | baseName = ' | ||
| + | version = " | ||
| + | } | ||
| + | |||
| + | dependencies { | ||
| + | compile( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | testCompile( | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | } | ||
| + | |||
| + | task startProvider(type: | ||
| + | classpath = sourceSets.main.runtimeClasspath | ||
| + | main = ' | ||
| + | // args = [ ' | ||
| + | jvmArgs = [' | ||
| + | workingDir = " | ||
| + | standardOutput = " | ||
| + | errorOutput = " | ||
| + | // stopAfter = verify | ||
| + | waitForPort = 8080 | ||
| + | waitForOutput = ' | ||
| + | // environment ' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Assuming that the SPring boot application is under | ||
| + | |||
| + | <sxh java> | ||
| + | package com.dius.account; | ||
| + | |||
| + | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| + | import org.springframework.boot.builder.SpringApplicationBuilder; | ||
| + | |||
| + | @SpringBootApplication | ||
| + | public class Application { | ||
| + | public static void main(String[] args) { | ||
| + | new SpringApplicationBuilder(Application.class).run(args); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
gradle.1613693321.txt.gz · Last modified: by skipidar
