-
Notifications
You must be signed in to change notification settings - Fork 92
/
publish.gradle
171 lines (143 loc) · 5.29 KB
/
publish.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
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
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
// Java / publishing
java {
// Configure the Java "software component" to include javadoc and sources jars in addition to the classes jar.
// Ultimately, this component is what makes up the publication for this project.
withJavadocJar()
withSourcesJar()
}
jar {
manifest {
attributes(
// Basic JAR manifest attributes
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': 'Hibernate.org',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'Hibernate.org',
'Implementation-Vendor-Id': 'org.hibernate',
'Implementation-Url': 'http://hibernate.org/reactive',
)
}
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
options.addStringOption('Xdoclint:none', '-quiet')
}
publishing {
publications {
register( "publishedArtifacts", MavenPublication) {
from components.java
pom {
name = project.mavenPomName
description = project.description
url = 'https://github.com/hibernate/hibernate-reactive'
organization {
name = 'Hibernate.org'
url = 'https://hibernate.org'
}
licenses {
license {
name = 'Apache License Version 2.0'
url = 'https://opensource.org/licenses/Apache-2.0'
comments = 'See discussion at http://hibernate.org/community/license/ for more details.'
distribution = 'repo'
}
}
issueManagement {
system = 'github'
url = 'https://github.com/hibernate/hibernate-reactive/issues'
}
scm {
connection = 'scm:git:ssh://[email protected]/hibernate/hibernate-reactive.git'
developerConnection = 'scm:git:ssh://[email protected]/hibernate/hibernate-reactive.git'
url = 'https://github.com/hibernate/hibernate-reactive.git'
}
developers {
developer {
id = 'hibernate-team'
name = 'The Hibernate Development Team'
organization = 'Hibernate.org'
organizationUrl = 'https://hibernate.org'
}
}
}
}
}
}
// Signing
var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension
var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension
signingExtension.sign publishingExtension.publications.publishedArtifacts
var signingKey = resolveSigningKey()
var signingPassphrase = resolveSigningPassphrase()
signingExtension.useInMemoryPgpKeys(signingKey, signingPassphrase)
gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
boolean wasPublishingRequested = false
graph.allTasks.each {task ->
if ( task instanceof PublishToMavenRepository ) {
logger.lifecycle( "Found PublishToMavenRepository task : {}", task.path )
wasPublishingRequested = true
}
}
if ( wasPublishingRequested ) {
def publishUser = resolvePublishUser()
def publishPass = resolvePublishPass()
if ( publishUser == null || publishPass == null ) {
throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." )
}
logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version
// require signing if publishing to OSSRH
signingExtension.required = true
}
else if ( signingKey == null || signingPassphrase == null ) {
tasks.withType( Sign ).each { t-> t.enabled = false }
}
}
static String resolveSigningKey() {
var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" )
if ( key != null ) {
return key
}
var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" )
if ( keyFile != null ) {
return new File( keyFile ).text
}
return null
}
static String resolveSigningPassphrase() {
return System.getenv().get( "SIGNING_GPG_PASSPHRASE" )
}
String resolvePublishUser() {
var envVar = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" )
if ( envVar != null ) {
return envVar
}
def projectProp = projectPropOrNull( "sonatypeUsername" )
if ( projectProp != null ) {
return projectProp
}
return null
}
String resolvePublishPass() {
var envVar = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" )
if ( envVar != null ) {
return envVar
}
def projectProp = projectPropOrNull( "sonatypePassword" )
if ( projectProp != null ) {
return projectProp
}
return null
}
String projectPropOrNull(String name) {
if ( project.hasProperty( name ) ) {
return project.findProperty( name )
}
return null;
}