-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
252 lines (211 loc) · 8.62 KB
/
Copy pathbuild.gradle
File metadata and controls
252 lines (211 loc) · 8.62 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.4'
id 'io.spring.dependency-management' version '1.1.7'
id 'java-library'
}
bootJar.enabled = false
jar.enabled = true
repositories {
mavenCentral()
maven { url = 'https://repo.spring.io/milestone' }
maven { url = 'https://repo.spring.io/snapshot' }
}
allprojects {
group = 'ai.ctxa'
version = '0.1.0-SNAPSHOT'
description = 'contexa'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
}
tasks.register('checkJavaStyle', Exec) {
group = 'verification'
description = 'Check Java style requirements'
commandLine 'node', "${rootDir}/check-java-style.js", '--all'
}
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
bootJar {
enabled = false
}
jar {
enabled = true
archiveClassifier = ''
}
jacoco {
toolVersion = "0.8.12"
}
tasks.named('test') {
useJUnitPlatform()
jvmArgs '-XX:+EnableDynamicAgentLoading', '-Dorg.mockito.mock.maker=mock-maker-subclass'
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
csv.required = false
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
withJavadocJar()
}
repositories {
mavenCentral()
maven { url = 'https://repo.spring.io/milestone' }
maven { url = 'https://repo.spring.io/snapshot' }
maven {
name = 'Central Portal Snapshots'
url = 'https://central.sonatype.com/repository/maven-snapshots/'
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
dependsOn ':checkJavaStyle'
}
tasks.withType(org.springframework.boot.gradle.tasks.run.BootRun).configureEach {
jvmArgs = ['-Dfile.encoding=UTF-8', '-Dconsole.encoding=UTF-8', '-Dstdout.encoding=UTF-8', '-Dstderr.encoding=UTF-8']
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('source', '17')
failOnError = false
}
dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.24.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.springframework.boot:spring-boot-starter-data-redis'
testImplementation 'org.springframework.boot:spring-boot-starter-data-redis'
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
implementation 'org.postgresql:postgresql:42.7.6'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation platform("org.springframework.ai:spring-ai-bom:1.1.2")
implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
implementation("com.github.ben-manes.caffeine:caffeine:3.2.2")
implementation 'io.opentelemetry:opentelemetry-api:1.32.0'
implementation 'org.apache.commons:commons-pool2:2.12.1'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
implementation 'org.modelmapper:modelmapper:3.2.3'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2022.0.4"
mavenBom "io.github.resilience4j:resilience4j-bom:2.1.0"
mavenBom "org.springframework.statemachine:spring-statemachine-bom:4.0.0"
}
}
// Maven repository publishing configuration
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.name
description = 'Contexa - AI-Native IAM & Autonomous Security Platform'
url = 'https://github.com/contexa-security/contexa'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'contexa'
name = 'Contexa Team'
}
}
scm {
connection = 'scm:git:git://github.com/contexa-security/contexa.git'
developerConnection = 'scm:git:ssh://github.com/contexa-security/contexa.git'
url = 'https://github.com/contexa-security/contexa'
}
}
}
}
repositories {
mavenLocal()
maven {
name = 'sonatype'
def releasesUrl = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
def snapshotsUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsUrl : releasesUrl
credentials {
username = findProperty('ossrhUsername') ?: System.getenv('OSSRH_USERNAME') ?: ''
password = findProperty('ossrhPassword') ?: System.getenv('OSSRH_PASSWORD') ?: ''
}
}
}
}
signing {
def signingKey = findProperty('signing.key') ?: System.getenv('GPG_SIGNING_KEY')
def signingPassword = findProperty('signing.password') ?: System.getenv('GPG_SIGNING_PASSWORD')
if (signingKey) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.mavenJava
required { signingKey != null && !version.endsWith('SNAPSHOT') }
}
}
//./gradlew clean publishToMavenCentral
tasks.register('publishToMavenCentral') {
group = 'publishing'
description = 'Publish all modules to Maven Central and trigger Portal registration'
dependsOn subprojects.collect { it.tasks.matching { t -> t.name == 'publishAllPublicationsToSonatypeRepository' } }
doLast {
if (version.endsWith('SNAPSHOT')) {
println 'SNAPSHOT published. No manual upload needed.'
return
}
def tokenUser = findProperty('ossrhUsername') ?: System.getenv('OSSRH_USERNAME') ?: ''
def tokenPass = findProperty('ossrhPassword') ?: System.getenv('OSSRH_PASSWORD') ?: ''
def credentials = "${tokenUser}:${tokenPass}".bytes.encodeBase64().toString()
def namespace = project.group.toString().replace('.', '.')
def url = "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/${namespace}?publishing_type=user_managed"
println "Triggering Central Portal registration: ${url}"
def connection = new URL(url).openConnection() as HttpURLConnection
connection.requestMethod = 'POST'
connection.setRequestProperty('Authorization', "Bearer ${credentials}")
def responseCode = connection.responseCode
if (responseCode == 200 || responseCode == 201) {
println "Central Portal registration successful (${responseCode}). Check https://central.sonatype.com/publishing/deployments"
} else {
def error = connection.errorStream?.text ?: 'No error body'
println "Central Portal registration failed (${responseCode}): ${error}"
}
}
}