-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
105 lines (83 loc) · 2.92 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
plugins {
id 'java'
id 'application'
id 'org.springframework.boot' version '2.7.10'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
description = 'Gradle learning labs'
group = 'org.squidmin'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
javaMainClass = "org.squidmin.gradlelabs.GradleLabsApplication"
set('springCloudVersion', "2021.0.6")
}
application {
mainClassName = javaMainClass
}
springBoot {
mainClass = 'org.squidmin.gradlelabs.GradleLabsApplication'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
// Test dependencies
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework:spring-test:5.3.4'
testImplementation 'org.springframework.boot:spring-boot-test:2.4.3'
}
if (project.hasProperty("args")) {
ext.cmdargs = project.getProperty("args")
} else {
ext.cmdargs = "ls"
}
tasks.register('cmdLineJavaExec', JavaExec) {
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
mainClass = javaMainClass
args cmdargs.split()
}
/*
* project.getProperty() throws a MissingPropertyException when a property is not defined.
* Unlike project properties, System.getProperty() returns a null value when a property is not defined.
* The below code configures the Gradle project to use a project property.
* Test project properties using this command:
* ./gradlew propertyTypes -Dargs=lorem -Pargs=ipsum
*/
tasks.register('propertyTypes') {
doLast {
if (project.hasProperty("args")) {
println "Project property value [" + project.getProperty("args") + "]"
}
println "System property value [" + System.getProperty("args") + "]"
}
}
tasks.named('test') {
useJUnitPlatform()
systemProperty 'arg_1', System.getProperty('arg_1')
testLogging {
// Make sure output from standard out or error is shown in Gradle output.
showStandardStreams = true
events "passed", "skipped", "failed"
// Or we use events method:
// events 'standard_out', 'standard_error'
// Or set property events:
// events = ['standard_out', 'standard_error']
// Instead of string values we can use enum values:
// events org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_OUT,
// org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR,
}
}