-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
186 lines (165 loc) · 6.62 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
plugins {
id 'io.freefair.lombok' version "8.12" apply false
id 'com.adarshr.test-logger' version "4.0.0" apply false
id 'com.github.ben-manes.versions' version "0.52.0"
id 'org.springframework.boot' version "3.4.2" apply false
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'io.freefair.lombok'
apply plugin: 'com.adarshr.test-logger'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.ben-manes.versions'
repositories {
mavenLocal()
mavenCentral()
}
group = 'eu.fraho.spring'
archivesBaseName = "${rootProject.name}-${project.name}"
version = rootProject.file('version.txt').text.trim()
description = "Spring boot security integration for JWT"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
java {
withJavadocJar()
withSourcesJar()
}
jar {
manifest {
attributes(
'Implementation-Title': rootProject.name,
'Implementation-Version': project.version,
'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Compatibility': project.sourceCompatibility,
'Built-By': System.getProperty('user.name')
)
}
}
test {
useJUnitPlatform()
ignoreFailures = rootProject.version.endsWith('-SNAPSHOT')
}
dependencies {
annotationProcessor group: "org.springframework.boot", name: "spring-boot-configuration-processor", version: "3.4.2"
testFixturesApi group: "org.springframework.boot", name: "spring-boot-starter-test", version: "3.0.0"
testFixturesApi group: "org.springframework.boot", name: "spring-boot-starter-web", version: "3.0.0"
testFixturesApi group: "com.fasterxml.jackson.datatype", name: "jackson-datatype-jsr310", version: "2.18.2"
testFixturesApi group: 'org.junit.jupiter', name: 'junit-jupiter', version: "5.11.4"
}
configurations.configureEach {
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// code coverage
apply plugin: 'jacoco'
jacoco.toolVersion = "0.8.11"
jacocoTestReport.reports {
xml.required = true
html.required = true
}
check.dependsOn(jacocoTestReport)
// release to central
apply plugin: 'maven-publish'
apply plugin: 'signing'
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = "${rootProject.name}-${project.name}"
version = project.version
from components.java
suppressPomMetadataWarningsFor('testFixturesApiElements')
suppressPomMetadataWarningsFor('testFixturesRuntimeElements')
pom {
name = "${rootProject.name}-${project.name}"
description = project.description
url = 'https://github.com/bratkartoffel/security-jwt'
scm {
connection = 'scm:git:https://github.com/bratkartoffel/security-jwt.git'
developerConnection = 'scm:git:[email protected]:bratkartoffel/security-jwt.git'
url = 'https://github.com/bratkartoffel/security-jwt.git'
}
licenses {
license {
name = 'The MIT License (MIT)'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
developers {
developer {
id = 'bratkartoffel'
name = 'Simon Frankenberger'
email = '[email protected]'
}
}
// workaround
// https://stackoverflow.com/questions/69877418/why-does-every-pom-file-published-by-gradle-has-a-self-referential-dependency
// https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/365
withXml {
asNode().dependencies.dependency.each { dep ->
if(dep["artifactId"].last().value().last() == artifactId) {
assert dep.parent().remove(dep)
}
}
}
}
}
}
repositories {
maven {
credentials {
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : null
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : null
}
url = project.version.endsWith('-SNAPSHOT') ?
'https://oss.sonatype.org/content/repositories/snapshots' :
'https://oss.sonatype.org/service/local/staging/deploy/maven2'
}
}
}
// Signature of artifacts
if (project.hasProperty('signing.gnupg.keyName')) {
signing {
useGpgCmd()
required = !rootProject.version.endsWith('-SNAPSHOT')
sign publishing.publications.mavenJava
}
} else {
logger.info("Disable signing of artifacts as no key is configured")
}
// do not try to print colors on stdout when running on jenkins
if (System.getenv("JENKINS_HOME") != null) {
testlogger.theme 'plain'
}
}
tasks.register('jacocoRootReport', JacocoReport) {
dependsOn = subprojects.test
additionalSourceDirs.from(
subprojects.sourceSets.main.allSource.srcDirs,
subprojects.sourceSets.main.output,
subprojects.jacocoTestReport.executionData
)
reports {
html.required = true
xml.required = true
}
onlyIf = {
true
}
}
// dependencyUpdates should only suggest released versions
static boolean isStable(String version) {
boolean result = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'snapshot'].any {
version ==~ /(?i).*[.-]$it[.\-\d]*/
}
return !result
}
tasks.named("dependencyUpdates").configure {
gradleReleaseChannel = 'current'
revision = 'integration'
rejectVersionIf {
!isStable(it.candidate.version) && isStable(it.currentVersion)
}
}