-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublishing.gradle
More file actions
114 lines (101 loc) · 4.28 KB
/
publishing.gradle
File metadata and controls
114 lines (101 loc) · 4.28 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
afterEvaluate {
if (!project.ext.has('publishingConfig')
|| !project.ext.publishingConfig instanceof Map) {
return
}
def config = project.ext.publishingConfig
sonatypeCentralUpload {
username = System.getenv("SONATYPE_USERNAME") ?: "test-user"
password = System.getenv("SONATYPE_PASSWORD") ?: "test-password"
// Use the actual generated artifact files
archives = provider {
def libsDir = layout.buildDirectory.dir("libs").get()
def artifactId = config.artifactId
def version = config.version
files(
libsDir.file("${artifactId}-${version}.jar"),
libsDir.file("${artifactId}-${version}-sources.jar"),
libsDir.file("${artifactId}-${version}-javadoc.jar")
)
}
pom = layout.buildDirectory.file("pom.xml").get().asFile
// This is your PGP private key. This is required to sign your files
signingKey = System.getenv("SONATYPE_SIGNING_KEY") ?: ""
// This is your PGP private key passphrase to decrypt your private key
signingKeyPassphrase = System.getenv("SIGNING_KEY_PASSPHRASE") ?: ""
}
publishing {
publications {
create("maven", MavenPublication) {
from(components["java"] as SoftwareComponent)
groupId = config.groupId
artifactId = config.artifactId
version = config.version
pom {
properties = [
'maven.compiler.source': '11',
'maven.compiler.target': '11',
]
name = config.name
description = config.description
url = 'https://github.com/gleanwork/api-client-java'
scm {
url = 'github.com/gleanwork/api-client-java'
connection = 'scm:git:ssh://git@github.com/gleanwork/api-client-java.git'
}
licenses {
license {
name = 'The MIT License (MIT)'
url = 'https://mit-license.org/'
}
}
developers {
developer {
name = 'Glean'
organization = 'Glean'
email = 'support@glean.com'
}
}
organization {
name = 'Glean'
url = 'https://www.glean.com'
}
}
}
}
if (!project.hasProperty('skip.signing')) {
signing {
def signingKey = findProperty("signingKey")
def signingPassphrase = findProperty("signingPassphrase")
useInMemoryPgpKeys(signingKey, signingPassphrase)
sign publishing.publications.getByName("maven")
}
}
}
// Configure POM file generation task after publishing is configured
tasks.named("generatePomFileForMavenPublication") {
destination = file(layout.buildDirectory.file("pom.xml"))
jar.dependsOn('generatePomFileForMavenPublication')
}
}
// Debug task to log publishing properties before publish tasks
tasks.register('logPublishingProperties') {
doLast {
if (project.ext.has('publishingConfig')) {
def config = project.ext.publishingConfig
logger.quiet("Publishing properties for project '${project.name}':")
logger.quiet(" groupId: ${config.groupId}")
logger.quiet(" artifactId: ${config.artifactId}")
logger.quiet(" version: ${config.version}")
logger.quiet(" name: ${config.name}")
logger.quiet(" description: ${config.description}")
logger.quiet(" publicationName: maven")
}
}
}
// Make all publish tasks depend on the logging task and POM generation
tasks.matching { it.name.startsWith('publish')
|| it.name.contains('sonatypeCentralUpload') }.configureEach {
dependsOn logPublishingProperties
dependsOn 'generatePomFileForMavenPublication'
}