-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
115 lines (104 loc) · 4.62 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
plugins {
id "java-library"
id "maven-publish"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id 'signing'
}
group = "io.github.gradle-nexus-e2e"
String versionTimestamp = (new Date()).format("yyyyMMdd-HHmmss") //See: https://issues.sonatype.org/browse/OSSRH-86532
String versionSuffix = (System.env.CI == "true") ? "ci${System.env.GITHUB_RUN_NUMBER ?: ''}-${versionTimestamp}" : "local"
version = project.hasProperty("overriddenVersion") ? project.property("overriddenVersion") : "0.0.1-$versionSuffix"
sourceCompatibility = 1.8
//Small hack to override release related properties to prevent accidental production release if called interactively
//Intended to fail if required (non-optional) values are not provided
if (!project.hasProperty("disableE2EOverriding")) {
List<String> propertiesToOverride = ['sonatypeUsername', 'sonatypePassword']
List<String> optionalPropertiesToOverride = ['signingKey', 'signingPassword', 'signing.gnupg.keyName', 'signing.gnupg.homeDir', 'signing.gnupg.passphrase']
logger.lifecycle("Overriding properties ${propertiesToOverride + optionalPropertiesToOverride} to use *E2E (non-production) values. Can be disbled with '-PdisableE2EOverriding'")
overridePropertiesForE2E(propertiesToOverride)
overrideOptionalPropertiesForE2E(optionalPropertiesToOverride)
}
void overridePropertiesForE2E(List<String> propertyToOverrideNames, boolean failIfNotProvided = true) {
propertyToOverrideNames.each { String propertyNameToOverride ->
project.ext[propertyNameToOverride] = project.getProperty("${propertyNameToOverride}E2E")
}
}
void overrideOptionalPropertiesForE2E(List<String> propertyToOverrideNames) {
propertyToOverrideNames.each { String propertyNameToOverride ->
String e2ePropertyNameToOverride = "${propertyNameToOverride}E2E"
if (project.hasProperty("$e2ePropertyNameToOverride")) {
project.ext[propertyNameToOverride] = project.getProperty("$e2ePropertyNameToOverride")
} else if (project.hasProperty(propertyNameToOverride)) {
logger.info("Nullifying $propertyNameToOverride")
project.ext[propertyNameToOverride] = null //to ask for e2e passphrase using gpg-agent if executed interactively, even if production passprease is defined
} else {
logger.info("Ignoring not set twice $propertyNameToOverride")
}
}
}
repositories {
mavenCentral()
}
java {
withJavadocJar()
withSourcesJar()
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId = "248647f1a45ed6" //can reduce execution time by even 10 seconds
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = 'Minimal Nexus Publish E2E project'
description = 'Minimal project publishing artifacts to Nexus for E2E testing in gradle-nexus-publish-plugin'
url = 'https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal'
inceptionYear = '2020'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'szpak'
name = 'Marcin Zajączkowski'
}
developer {
id = 'marcphilipp'
name = 'Marc Philipp'
}
}
scm {
connection = 'scm:https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal.git'
developerConnection = 'scm:[email protected]:gradle-nexus-e2e/nexus-publish-e2e-minimal.git'
url = 'https://github.com/gradle-nexus-e2e/nexus-publish-e2e-minimal'
}
}
}
}
}
signing {
required { !project.version.endsWith("-SNAPSHOT") && !project.hasProperty("skipSigning") }
if (project.findProperty("signingKey")) {
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
} else {
useGpgCmd()
}
sign publishing.publications.mavenJava
}
//do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}