-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
107 lines (98 loc) · 4.41 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
plugins {
id "java-library"
id "ivy-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-ivy"
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 {
publicationType = io.github.gradlenexus.publishplugin.NexusRepository.PublicationType.IVY
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
stagingProfileId = "248647f1a45ed6" //can reduce execution time by even 10 seconds
}
}
}
publishing {
publications {
ivy(IvyPublication) {
from(components.java)
descriptor {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
author {
url = 'https://github.com/szpak'
name = 'Marcin Zajączkowski'
}
author {
url = 'https://github.com/marcphilipp'
name = 'Marc Philipp'
}
description {
text = 'Minimal project publishing artifacts to Nexus for E2E testing in gradle-nexus-publish-plugin'
homepage = '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)
}
}