-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
193 lines (161 loc) · 4.95 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.3/userguide/building_java_projects.html in the Gradle documentation.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath libs.plugin.license
classpath libs.plugin.noHttp
classpath libs.plugin.javaformat
classpath libs.plugin.pitest
classpath libs.plugin.jib
classpath libs.plugin.shadow
}
}
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'pmd'
}
apply plugin: 'io.spring.javaformat'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.nohttp'
apply plugin: 'info.solidsoft.pitest'
apply plugin: 'com.google.cloud.tools.jib'
apply plugin: 'com.github.johnrengelman.shadow'
apply from: 'dependencies.gradle'
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
group = 'io.micrometer.release'
println "I'm configuring $project.name with version $project.version"
sourceSets {
e2eTest {
java {
destinationDirectory = project.layout.buildDirectory.dir('classes/java/e2eTest')
}
compileClasspath = sourceSets.test.compileClasspath + sourceSets.test.output
runtimeClasspath = sourceSets.test.runtimeClasspath + sourceSets.test.output + files("${buildDir}/classes/java/e2eTest")
}
test {
java {
exclude '**/*E2e*.java'
}
}
}
dependencies {
checkstyle libs.javaFormatForPlugins
implementation libs.slf4j
implementation libs.logback
implementation libs.jacksonDatabind
testImplementation platform(libs.junitBom)
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation libs.assertj
testImplementation libs.archunit
testImplementation libs.mockitoCore
testImplementation libs.jacksonDatatype
testImplementation libs.wiremock
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// PIT JUnit 5 plugin
testImplementation libs.pitestJunit5
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
application {
// Define the main class for the application.
mainClass = 'io.micrometer.release.Main'
}
tasks.named('test') {
useJUnitPlatform()
}
test {
useJUnitPlatform() {
excludeTags("e2e")
}
}
tasks.register('e2e', Test) {
description = 'Runs E2E tests.'
group = 'verification'
dependsOn e2eTestClasses
testClassesDirs = sourceSets.e2eTest.output.classesDirs
classpath = sourceSets.e2eTest.runtimeClasspath
useJUnitPlatform() {
includeTags("e2e")
}
}
formatE2eTest.dependsOn("formatTest")
license {
header rootProject.file('gradle/licenseHeader.txt')
strictCheck true
mapping {
kt = 'SLASHSTAR_STYLE'
}
sourceSets = project.sourceSets
ext.year = Calendar.getInstance().get(Calendar.YEAR)
skipExistingHeaders = true
exclude '**/*.json' // comments not supported
exclude '**/*.txt' // comments not supported
}
// PMD plugin configuration
pmd {
consoleOutput = true
toolVersion = libs.versions.pmdTool.get()
ruleSetFiles = files("${projectDir}/src/test/resources/ruleset.xml")
}
tasks.withType(Pmd) {
reports {
xml.required.set(false) // Disable XML reports
html.required.set(true) // Enable HTML reports
}
}
tasks.check {
dependsOn(tasks.withType(Pmd))
}
pitest {
junit5PluginVersion = libs.versions.pitestJunit5
threads = 4 // Parallel threads for mutation testing
outputFormats = ['HTML'] // Generate an HTML report
timestampedReports = false // Avoid timestamped reports for consistent file paths
testStrengthThreshold.set(85)
mutationThreshold.set(75)
setCoverageThreshold(80)
excludedClasses.set(["io.micrometer.release.Main"])
testSourceSets = [sourceSets.test] // Only use the main test source set
}
build.dependsOn("pitest")
jib {
from {
image = "scratch" // Use an empty base image since we'll use a Dockerfile
}
to {
image = System.getenv("DOCKER_HUB_REPO") ?: ''
tags = [project.version]
auth {
username = System.getenv("DOCKER_HUB_USERNAME") ?: ""
password = System.getenv("DOCKER_HUB_TOKEN") ?: ""
}
}
container {
jvmFlags = ["-Xms512m", "-Xmx1024m"]
mainClass = "io.micrometer.release.Main"
}
extraDirectories {
paths = file(".") // Ensure Dockerfile is included
}
}
shadowJar {
archiveBaseName.set("micrometer-release")
archiveClassifier.set("") // Remove the "all" classifier
archiveVersion.set("") // Remove the version from the JAR name
}