-
Notifications
You must be signed in to change notification settings - Fork 466
/
Copy pathjava-publish.gradle
143 lines (131 loc) · 4.1 KB
/
java-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
///////////
// MAVEN //
///////////
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
// Where it's possible to name parameters and methods clearly enough
// that javadoc is not necessary, why make the code bigger?
//
// Thus, no javadoc warnings.
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
// use markdown in javadoc
def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\">${text}</a>" }
def javadocInfo = '<h2>' + makeLink("https://github.com/${org}/${name}", "${group}:${project.ext.artifactId}:${ext.version}") +
' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '</h2>'
String version_str = ext.version.endsWith('-SNAPSHOT') ? 'snapshot' : ext.version
apply plugin: 'org.jdrupes.mdoclet'
javadoc {
// Where it's possible to name parameters and methods clearly enough
// that javadoc is not necessary, why make the code bigger?
//
// Thus, no javadoc warnings.
options.addStringOption('Xdoclint:none', '-quiet')
// setup the header
options.header javadocInfo
options.footer javadocInfo
// setup links
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', '../gradle/javadoc/java8')
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', '../gradle/javadoc/gradle')
// links to javadoc from the other versions
options.linksOffline("https://diffplug.github.io/spotless/javadoc/${project.artifactIdLib}/${version_str}/", "../gradle/javadoc/${project.artifactIdLib}")
options.linksOffline("https://diffplug.github.io/spotless/javadoc/${project.artifactIdLibExtra}/${version_str}/", "../gradle/javadoc/${project.artifactIdLibExtra}")
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
////////////////
// PUBLISHING //
////////////////
final MAVEN_PLUGIN_ARTIFACT_NAME = 'spotless-maven-plugin'
model {
publishing {
publications {
pluginMaven(MavenPublication) {
if (project.ext.artifactId != 'spotless-plugin-gradle') {
from components.java
}
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId project.ext.artifactId
version project.ext.version
pom.withXml {
// add MavenCentral requirements to the POM
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.ext.artifactId
description project.description
url "https://github.com/${project.org}/${rootProject.name}"
scm {
url "https://github.com/${project.org}/${rootProject.name}"
connection "scm:git:https://github.com/${project.org}/${rootProject.name}.git"
developerConnection "scm:git:ssh:[email protected]/${project.org}/${rootProject.name}.git"
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
if (project.ext.artifactId == MAVEN_PLUGIN_ARTIFACT_NAME) {
// Maven plugin required Maven 3.1.0+ to run
prerequisites { maven '3.1.0' }
}
developers {
if (project.ext.artifactId == MAVEN_PLUGIN_ARTIFACT_NAME) {
developer {
id 'lutovich'
name 'Konstantin Lutovich'
email '[email protected]'
}
}
developer {
id 'nedtwigg'
name 'Ned Twigg'
email '[email protected]'
}
}
}
}
}
}
}
}
if (!version.endsWith('-SNAPSHOT')) {
// upload releases to bintray and then mavenCentral
bintray {
user = System.env['bintray_user']
key = System.env['bintray_pass']
publications = [
'pluginMaven'
]
publish = true
pkg {
repo = 'opensource'
name = project.ext.artifactId
userOrg = project.org
version {
name = project.ext.version
mavenCentralSync {
user = System.env['nexus_user']
password = System.env['nexus_pass']
}
}
}
}
publish.dependsOn(bintrayUpload)
bintrayUpload.dependsOn([
'generatePomFileForPluginMavenPublication',
jar,
sourcesJar,
javadocJar
])
}