-
Notifications
You must be signed in to change notification settings - Fork 962
Expand file tree
/
Copy pathbuild.gradle
More file actions
85 lines (74 loc) · 3.1 KB
/
build.gradle
File metadata and controls
85 lines (74 loc) · 3.1 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
plugins {
id "jacoco"
alias(libs.plugins.spotless)
alias(libs.plugins.publish)
}
repositories {
mavenCentral()
}
subprojects {
apply from: rootProject.file('common.gradle')
}
task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
title = 'All modules'
destinationDir = new File(project.buildDir, 'merged-javadoc')
// Note: The closures below are executed lazily.
source {
subprojects*.sourceSets*.main*.allSource
}
classpath.from {
subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency) })*.resolve()
}
}
spotless {
java {
target 'src/*/java/**/*.java'
// note: you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports
importOrder('java', 'javax', 'org.openjdk.btrace', '', '\\#org.openjdk.btrace', '\\#')
removeUnusedImports()
googleJavaFormat() // has its own section below
formatAnnotations() // fixes formatting of type annotations, see below
licenseHeader '/* (C) $YEAR */' // or licenseHeaderFile
}
}
// Nexus Publishing configuration for Maven Central release automation
// This enables the closeAndReleaseStagingRepositories task for automated releases
// Uses the new Central Portal URLs (OSSRH was sunset on June 30, 2025)
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
// Use Central Portal user token credentials (different from legacy OSSRH credentials)
username = findProperty("sonatype.user")
?: findProperty("sonatype.username")
?: System.getenv("SONATYPE_USER")
?: System.getenv("SONATYPE_USERNAME")
password = findProperty("sonatype.password")
?: System.getenv("SONATYPE_PASSWORD")
}
}
}
def sonatypeUsername = findProperty("sonatype.user")
?: findProperty("sonatype.username")
?: System.getenv("SONATYPE_USER")
?: System.getenv("SONATYPE_USERNAME")
def sonatypePassword = findProperty("sonatype.password")
?: System.getenv("SONATYPE_PASSWORD")
def hasSonatypeCredentials =
sonatypeUsername != null && !sonatypeUsername.toString().trim().isEmpty()
&& sonatypePassword != null
&& !sonatypePassword.toString().trim().isEmpty()
if (!hasSonatypeCredentials || project.version.endsWith("-SNAPSHOT")) {
logger.lifecycle("Sonatype credentials not provided or running with snapshot; skipping Nexus staging initialization and release tasks.")
def skipTheseTasks = [
"initializeSonatypeStagingRepository",
"publishToSonatype",
"closeSonatypeStagingRepository",
"dropSonatypeStagingRepository",
"releaseSonatypeStagingRepository",
]
tasks.matching { skipTheseTasks.contains(it.name) }.configureEach {
enabled = false
}
}