-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpublish.gradle
152 lines (133 loc) · 4.24 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
ext.publishProjects = subprojects.findAll { it.name.startsWith('infoarchive-') }
// Set nexusUsername/nexusPassword or sonatypeUsername/sonatypePassword
// in ~/.gradle/gradle.properties or specify on command line using -P
nexusPublishing {
repositories {
sonatype {
if (project.hasProperty('nexusUsername')) {
username = nexusUsername
}
if (project.hasProperty('nexusPassword')) {
password = nexusPassword
}
stagingProfileId = 'a74884fea6f3c'
}
}
}
configure(publishProjects) {
apply plugin: 'maven-publish'
apply plugin: 'signing'
// OSSRH requires both javadoc and sources jars
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
assemble.dependsOn sourcesJar, javadocJar
artifacts {
archives jar, javadocJar, sourcesJar
}
task installLocally {
dependsOn jar
doLast {
"""mvn install:install-file \
-Dfile=$jar.archivePath \
-DgroupId=$group \
-DartifactId=$name \
-Dversion=$version \
-Dpackaging=jar""".execute()
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
groupId = project.group
artifactId = project.name
pom {
// OSSRH also requires certain info in the POM
name = project.name
description = project.description
packaging = 'jar'
url = 'https://github.com/Enterprise-Content-Management/infoarchive-sdk'
scm {
connection = 'https://github.com/Enterprise-Content-Management/infoarchive-sdk.git'
developerConnection = 'https://github.com/Enterprise-Content-Management/infoarchive-sdk.git'
url = 'https://github.com/Enterprise-Content-Management/infoarchive-sdk.git'
}
licenses {
license {
name = 'Mozilla Public License Version 2.0'
url = 'https://www.mozilla.org/en-US/MPL/2.0/'
}
}
developers {
developer {
// id = 'ray'
// name = 'Remon Sinnema'
// email = '[email protected]'
// timezone = 'Europe/Amsterdam'
organization = 'OpenText'
}
}
contributors {
contributor {
name = 'Remon Sinnema'
organization = 'OpenText'
}
contributor {
name = 'Chandramouli Addaguduru'
organization = 'OpenText'
}
contributor {
name = 'Roman Kochkar'
organization = 'Saint Petersburg State University'
}
contributor {
name = 'Artem Kovalev'
organization = 'OpenText'
}
contributor {
name = 'Erik Silkensen'
organization = 'Flatirons Solutions'
}
contributor {
name = 'Domanic Smith-Jones'
organization = 'OpenText'
}
contributor {
name = 'Tord Svensson'
organization = 'Dell Technologies'
}
}
// For some reason the dependencies don't come across, so do it manually
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.runtimeClasspath.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
// OSSRH also requires everything to be signed
signing {
required { gradle.taskGraph.hasTask('publish') }
sign configurations.archives
sign publishing.publications.mavenJava
}
signMavenJavaPublication.dependsOn generatePomFileForMavenJavaPublication
}
publish {
dependsOn publishProjects*.tasks*.signMavenJavaPublication
finalizedBy closeSonatypeStagingRepository
}