-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
202 lines (179 loc) · 6.09 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
194
195
196
197
198
199
200
201
202
// old-style plugins that are not registered at plugins.gradle.org:
buildscript {
repositories {
mavenCentral()
//Needed only for SNAPSHOT versions
//maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
// new-style plugins that ARE registered at plugins.gradle.org:
plugins {
id 'java-library'
id 'signing'
id 'com.palantir.git-version' version '0.12.2'
id 'io.codearte.nexus-staging' version '0.30.0'
id 'maven-publish'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.github.dtreskunov'
def setVersion() {
def fromGit = gitVersion() // https://github.com/palantir/gradle-git-version
def matcher = (fromGit =~ /^(\d+\.\d+\.\d+)(.*)$/)
if (matcher.find()) {
def tag = matcher.group(1)
def isSnapshot = !matcher.group(2).isEmpty()
if (isSnapshot) {
version "${tag}-SNAPSHOT"
} else {
version tag
}
} else {
version fromGit
}
}
setVersion()
println "Project version: ${version}"
ext {
isSnapshotVersion = version.endsWith('SNAPSHOT')
nexusUsername = project.findProperty('nexusUsername') ?: 'secured'
nexusPassword = project.findProperty('nexusPassword') ?: 'secured'
}
// override dependency versions specified in
// https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.7.18/spring-boot-dependencies-2.7.18.pom
ext['logback.version'] = '1.2.13'
ext['spring-framework.version'] = '5.3.39'
ext['snakeyaml.version'] = '2.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
// https://www.baeldung.com/spring-boot-override-dependency-versions
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.7.18'
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.12.621'
}
}
dependencies {
api('org.springframework.boot:spring-boot')
api('org.springframework.boot:spring-boot-autoconfigure')
api('org.springframework:spring-web')
api('org.slf4j:slf4j-api')
api('javax.validation:validation-api:2.0.1.Final')
api('javax.servlet:javax.servlet-api')
api(project.getProperties().getOrDefault('fips', 'true').toBoolean() ? 'org.bouncycastle:bcpkix-fips:1.0.5' : 'org.bouncycastle:bcpkix-jdk15on:1.69')
compileOnly('org.eclipse.jetty:jetty-server') // needed for jetty-specific customizations
compileOnly('org.apache.tomcat.embed:tomcat-embed-core') // needed for tomcat-specific customizations
compileOnly('io.undertow:undertow-core') // needed for undertow-specific customizations
compileOnly('com.amazonaws:aws-java-sdk-secretsmanager') // needed for AWS Secrets Manager support
runtimeOnly('org.springframework.boot:spring-boot-starter-validation')
testRuntimeOnly('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
testRuntimeOnly('org.springframework.boot:spring-boot-starter-' + project.getProperties().getOrDefault('servletContainer', 'tomcat'))
testImplementation('org.springframework.boot:spring-boot-starter-security')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.springframework.security:spring-security-test')
testImplementation('org.apache.httpcomponents:httpclient')
testImplementation('org.junit-pioneer:junit-pioneer:1.4.2')
testImplementation('com.amazonaws:aws-java-sdk-secretsmanager') // needed for AWS Secrets Manager support
}
task generateTestCerts(type: Exec) {
def dir = new File(project.rootDir, "src/test/resources/ssl")
doFirst {
dir.mkdirs()
}
workingDir dir
commandLine 'ruby', '../../gen.rb'
}
test {
useJUnitPlatform()
dependsOn generateTestCerts
testLogging {
showStandardStreams = true
}
// https://junit-pioneer.org/docs/environment-variables/#warnings-for-reflective-access
jvmArgs '--add-opens=java.base/java.util=ALL-UNNAMED'
}
//disable javadoc doclint for Java8
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'EasySSL for Spring Boot microservices'
description = 'EasySSL is a small library to help create Spring Boot microservices that talk to each other over HTTPS with mutual authentication'
url = 'https://github.com/dtreskunov/easyssl'
scm {
url = 'scm:git@github.com:dtreskunov/easyssl.git'
connection = 'scm:git@github.com:dtreskunov/easyssl.git'
developerConnection = 'scm:git@github.com:dtreskunov/easyssl.git'
}
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'dtreskunov'
name = 'Denis Treskunov'
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = isSnapshotVersion ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username nexusUsername
password nexusPassword
}
}
}
}
signing {
if (project.hasProperty('signing.keyId') || !isSnapshotVersion) {
sign publishing.publications
}
}
nexusStaging {
packageGroup = group
numberOfRetries = 20
delayBetweenRetriesInMillis = 10000
username = nexusUsername
password = nexusPassword
}
task closeAndReleaseRepositoryIfNeeded(dependsOn: closeAndReleaseRepository) {
if (isSnapshotVersion) {
enabled = false
dependsOn = []
}
}
task myPublish {
dependsOn publish, closeAndReleaseRepositoryIfNeeded
closeAndReleaseRepositoryIfNeeded.mustRunAfter publish
}