gradle
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
gradle [2018/03/05 12:25] – created skipidar | gradle [2021/04/14 07:13] (current) – skipidar | ||
---|---|---|---|
Line 7: | Line 7: | ||
===Tasks=== | ===Tasks=== | ||
- | To list all tasks of the project do | + | To list all tasks of the project do < |
< | < | ||
$ gradlew tasks --all | $ gradlew tasks --all | ||
Line 119: | Line 119: | ||
1 actionable task: 1 executed | 1 actionable task: 1 executed | ||
</ | </ | ||
+ | |||
+ | |||
+ | ==== Using environment variabls ==== | ||
+ | |||
+ | Look out for hte type conversion here. | ||
+ | Integer is expected, so you mast cast explicitely | ||
+ | < | ||
+ | Integer.parseInt(System.getenv(' | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | // Top-level build file where you can add configuration options common to all sub-projects/ | ||
+ | ext.majorVersion=1 | ||
+ | ext.minorVersion=3 | ||
+ | ext.incrementalVersion=1 | ||
+ | if (System.getenv(' | ||
+ | ext.incrementalVersion=Integer.parseInt(System.getenv(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | === 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.1520252707.txt.gz · Last modified: (external edit)