-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
193 lines (166 loc) · 6.02 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
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
id 'org.springframework.boot' version '3.3.5'
id 'io.spring.dependency-management' version '1.1.6'
id("checkstyle")
}
java {
sourceCompatibility = '17'
targetCompatibility = '17'
withSourcesJar()
withJavadocJar()
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
tasks.named("bootJar") {
archiveClassifier = 'boot'
}
tasks.named("jar") {
archiveClassifier = ''
}
repositories {
mavenCentral()
}
javadoc {
options.addBooleanOption("Xdoclint:-missing", true)
options.links += [
"https://styrainc.github.io/opa-java/javadoc/",
"https://docs.spring.io/spring-security/site/docs/current/api/",
"https://docs.spring.io/spring-boot/api/java/",
]
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.security:spring-security-web'
implementation 'org.springframework.security:spring-security-core'
implementation 'org.springframework:spring-context'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.security:spring-security-config'
testImplementation 'org.testcontainers:testcontainers-bom:1.19.8'
testImplementation 'org.testcontainers:testcontainers:1.19.8'
testImplementation 'org.testcontainers:junit-jupiter:1.19.8'
api group: 'com.styra', name: 'opa', version: '1.8.0'
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}
apply plugin: 'application'
mainClassName = 'com.styra.opa.springboot'
tasks.named('test') {
useJUnitPlatform()
}
// https://discuss.gradle.org/t/how-to-exclude-checkstyle-task-from-build-task/6692/5
//
// This prevents Checkstyle from running on ./gradlew build, but keeps it
// working for ./gradlew lint.
checkstyle {
sourceSets = []
}
tasks.withType(Checkstyle) {
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
}
task lint {
dependsOn checkstyleTest
dependsOn checkstyleMain
// Note that Gradle linting is disabled because it reports problems that
// simply cannot be fixed. For example, it insists that lombok is unused
// when it is. It claims tomcat duplicates classes from jakarta, which may
// be so but that's getting pulled in by Spring, so we can't control that.
}
test {
useJUnitPlatform()
exclude 'com/styra/opa/springboot/autoconfigure/properties/ModifiedSystemEnvOPAPropertiesTest.class'
testLogging {
// uncomment for more verbose output during development
//events "passed", "skipped", "failed", "standard_out", "standard_error"
}
}
tasks.register("testModifiedSystemEnvProperties", Test) {
useJUnitPlatform()
group = "verification"
include 'com/styra/opa/springboot/autoconfigure/properties/ModifiedSystemEnvOPAPropertiesTest.class'
doFirst {
systemProperty 'opa.url', 'http://localhost:8183'
environment 'OPA_PATH', 'foo/bar2'
}
doLast {
systemProperties.remove('opa.url')
environment.remove('OPA_PATH')
}
}
test.finalizedBy(testModifiedSystemEnvProperties)
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
}
}
sonatypeCentralUpload {
// This is your Sonatype generated username
username = System.getenv("SONATYPE_USERNAME")
// This is your sonatype generated password
password = System.getenv("SONATYPE_PASSWORD")
// This is a list of files to upload. Ideally you would point to your jar file, source and javadoc jar (required by central)
archives = files(
"$buildDir/libs/${artifactId}-${version}.jar",
"$buildDir/libs/${artifactId}-${version}-sources.jar",
"$buildDir/libs/${artifactId}-${version}-javadoc.jar"
)
// This is the pom file to upload. This is required by central
pom = file("$buildDir/pom.xml")
// This is your PGP private key. This is required to sign your files
signingKey = System.getenv("SONATYPE_SIGNING_KEY")
// This is your PGP private key passphrase to decrypt your private key
signingKeyPassphrase = System.getenv("SIGNING_KEY_PASSPHRASE")
}
publishing {
publications {
maven(MavenPublication) {
groupId = "${groupId}"
artifactId = "${artifactId}"
version = "${version}"
from components.java
pom {
name = 'OPA Spring Boot SDK'
description = 'The Styra-supported driver to connect Spring Boot applications to Open Policy Agent (OPA) and Enterprise OPA deployments'
url = 'https://github.com/styrainc/opa-springboot'
scm {
url = 'github.com/styrainc/opa-springboot'
connection = 'scm:git:ssh://git@github.com/styrainc/opa-springboot.git'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'Styra'
organization = 'Styra'
email = 'devrel@styra.com'
}
}
organization {
name = 'Styra'
url = 'www.styra.com'
}
}
}
}
}
if (!project.hasProperty('skip.signing')) {
signing {
def signingKey = findProperty("signingKey")
def signingPassphrase = findProperty("signingPassphrase")
useInMemoryPgpKeys(signingKey, signingPassphrase)
sign publishing.publications.maven
}
}