-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbuild.gradle
More file actions
138 lines (118 loc) · 4.33 KB
/
build.gradle
File metadata and controls
138 lines (118 loc) · 4.33 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
plugins {
id 'com.github.kt3k.coveralls' version '2.12.2'
id 'jacoco'
id 'me.champeau.gradle.jmh' version '0.5.3'
id 'nebula.optional-base' version '3.1.0'
id 'com.github.hierynomus.license' version '0.16.1'
id 'com.github.spotbugs' version "6.0.14"
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}
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/"))
username = System.getenv('MAVEN_CENTRAL_USERNAME')
password = System.getenv('MAVEN_CENTRAL_PASSWORD')
}
}
}
// Single block: set version & release flag once (env override optional)
def envVersion = System.getenv('GITHUB_TAG')
if (envVersion && envVersion.trim()) {
version = envVersion.trim()
}
ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
allprojects {
group = 'com.optimizely.ab'
apply plugin: 'idea'
apply plugin: 'jacoco'
repositories { mavenCentral() }
jacoco { toolVersion = '0.8.7' }
}
def publishedProjects = subprojects.findAll { it.name != 'java-quickstart' }
configure(publishedProjects) {
apply plugin: 'com.github.spotbugs'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'nebula.optional-base'
apply plugin: 'com.github.hierynomus.license'
sourceCompatibility = 1.8
targetCompatibility = 1.8
// Needed only for plugin portal deps
repositories { maven { url 'https://plugins.gradle.org/m2/' } }
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
spotbugsMain {
reports { xml.enabled = false; html.enabled = true }
}
spotbugs {
spotbugsJmh.enabled = false
reportLevel = com.github.spotbugs.snom.Confidence.valueOf('HIGH')
}
jmh { duplicateClassesStrategy = 'warn' }
sourceSets { jmh.java.srcDirs += sourceSets.test.java.srcDirs }
dependencies {
jmh 'org.openjdk.jmh:jmh-core:1.12'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
}
configurations.all {
resolutionStrategy {
force "junit:junit:${junitVersion}"
force 'com.netflix.nebula:nebula-gradle-interop:2.2.2'
}
}
def docTitle = (name == 'core-httpclient-impl') ?
"Optimizely Java SDK: Httpclient" :
"Optimizely Java SDK"
afterEvaluate {
publishing {
publications {
create('release', MavenPublication) {
customizePom(pom, docTitle)
from components.java
artifact sourcesJar
artifact javadocJar
}
}
// Repositories omitted – nexus-publish plugin manages them
}
signing {
// Sign only release (non-SNAPSHOT) and only if key present
if (!rootProject.isReleaseVersion) return
def keyB64 = System.getenv('MAVEN_SIGNING_KEY_BASE64')
if (!keyB64?.trim()) return
def pass = System.getenv('MAVEN_SIGNING_PASSPHRASE')
useInMemoryPgpKeys(new String(keyB64.decodeBase64()), pass)
sign publishing.publications.release
}
}
license {
header = rootProject.file("resources/HEADER")
skipExistingHeaders = true
include "**/*.java"
ext.author = "Optimizely"
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
}
// Root ship task (nexus publish plugin)
// For snapshots: publishToSonatype only (appears in snapshot repo)
// For releases: publish then close+release to promote
tasks.register('ship') {
dependsOn 'publishToSonatype'
if (isReleaseVersion) {
finalizedBy 'closeAndReleaseSonatypeStagingRepository'
}
}
// Remove per‑module ship tasks & cross-project mustRunAfter (they caused config errors)
// Jacoco + Coveralls tasks unchanged below ...
// (keep your existing jacocoMerge, jacocoRootReport, coveralls, customizePom definitions)