/
build.gradle
250 lines (234 loc) · 9.05 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
group 'info.picocli'
description 'Annotation-based Java command line parser. Usage help with ANSI styles and colors. Autocomplete. Nested subcommands. Easily included as source to avoid adding a dependency.'
version '2.2.0-SNAPSHOT'
// for bumpVersion task
def oldVersion = '2\\.1\\.0'
def oldRevdate = '2017\\-11\\-30'
def revDate = '2017-11-30'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
}
}
allprojects {
apply plugin: 'groovy'
apply plugin: 'java'
sourceCompatibility = 1.5
targetCompatibility = 1.5
repositories {
jcenter()
}
configurations {
ivy
}
dependencies {
compileOnly 'org.codehaus.groovy:groovy-all:2.4.10'
ivy 'org.apache.ivy:ivy:2.4.0' // for Gradle
testCompile 'junit:junit:4.12',
'org.hamcrest:hamcrest-core:1.3',
'org.fusesource.jansi:jansi:1.15',
'org.codehaus.groovy:groovy-all:2.4.10'
}
tasks.withType(GroovyCompile) {
// this, and the `configurations {ivy}` section, are a workaround for the dreaded
// java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport
// that occurs when trying to compile a groovy script containing a @Grab annotation in gradle.
// see https://stackoverflow.com/questions/18173908/error-compiling-a-groovy-project-using-grab-annotation
groovyClasspath += configurations.ivy
}
}
project(':examples') {
dependencies {
compile rootProject
compile 'org.apache.ivy:ivy:2.4.0' // for Intelli/J
}
}
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'jacoco'
apply plugin: 'distribution'
apply plugin: 'maven-publish'
jar {
manifest {
attributes 'Implementation-Title' : 'picocli',
'Implementation-Vendor' : 'Remko Popma',
'Implementation-Version': version,
'Main-Class' : 'picocli.AutoComplete',
'Automatic-Module-Name' : 'info.picocli'
}
}
javadoc {
options.overview = "src/main/java/overview.html"
destinationDir = file("build/docs/apidocs")
}
javadoc.dependsOn('asciidoctor')
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
task testJar(type: Jar, dependsOn: compileTestJava) {
from sourceSets.test.output
classifier = 'tests'
}
task sourcesJar(type: Jar) {
from sourceSets.main.java.srcDirs
classifier = 'sources'
}
task testSourcesJar(type: Jar) {
from sourceSets.test.java.srcDirs
classifier = 'test-sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
asciidoctor {
sourceDir = file('docs')
outputDir = file('build/docs')
logDocuments = true
}
artifacts {
archives javadocJar
archives sourcesJar
archives testSourcesJar
archives testJar
archives jar
}
task bumpVersion {
doLast {
ant.replaceregexp(match: "\"$oldVersion\"", replace: "\"$version\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'src/main/java/picocli', includes: 'CommandLine.java')
fileset(dir: 'src/test/java/picocli', includes: 'CommandLineTest.java')
}
ant.replaceregexp(match: "version $oldVersion", replace: "version $version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'src/test/java/picocli', includes: 'AutoCompleteTest.java')
}
// Doc header
ant.replaceregexp(match: ":revnumber: $oldVersion", replace: ":revnumber: $version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
fileset(dir: 'docs', includes: 'autocomplete.adoc')
}
// Downloads section, Gradle
ant.replaceregexp(match: ":picocli:$oldVersion", replace: ":picocli:$version", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Maven
ant.replaceregexp(match: "<version>$oldVersion</version>", replace: "<version>$version</version>", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, SBT
ant.replaceregexp(match: "\"picocli\" % \"$oldVersion\"", replace: "\\\"picocli\\\" % \\\"$version\\\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
// Downloads section, Ivy
ant.replaceregexp(match: "rev=\"$oldVersion\"", replace: "rev=\\\"$version\\\"", flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
}
ant.replaceregexp(match: oldRevdate, replace: revDate, flags: 'g', byline: true, encoding: 'UTF8') {
fileset(dir: 'docs', includes: 'index.adoc')
fileset(dir: 'docs', includes: 'autocomplete.adoc')
}
}
}
task copyDocs(type: Copy) {
from 'build/docs/html5/index.html'
from 'build/docs/html5/autocomplete.html'
from('build/docs/') { exclude 'html5'}
into 'docs'
}
distributions {
main {
baseName = "$archivesBaseName-all"
contents {
from jar
from sourcesJar
from testJar
from testSourcesJar
from javadocJar
from ('LICENSE')
from ('RELEASE-NOTES.md')
}
}
}
ext {
bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'picocli'
bintrayPackage = 'picocli'
bintrayUsername = System.getenv('BINTRAY_USER')
bintrayApiKey = System.getenv('BINTRAY_KEY')
}
publishing {
publications {
plugin(MavenPublication) {
from components.java
artifact sourcesJar
artifact testJar
artifact testSourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('packaging', 'jar')
root.appendNode('name', 'picocli - a mighty tiny Command Line Interface')
root.appendNode('description', description)
root.appendNode('url', 'http://picocli.info')
root.appendNode('inceptionYear', '2017')
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'The Apache Software License, version 2.0')
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
license.appendNode('distribution', 'repo')
def developer = root.appendNode('developers').appendNode('developer')
developer.appendNode('id', 'rpopma')
developer.appendNode('name', 'Remko Popma')
developer.appendNode('email', 'rpopma@apache.org')
def scm = root.appendNode('scm')
scm.appendNode('connection', 'scm:git:https://github.com/remkop/picocli.git')
scm.appendNode('developerConnection', 'scm:git:ssh://github.com:remkop/picocli.git')
scm.appendNode('url', 'https://github.com/remkop/picocli/tree/master')
}
}
}
repositories {
maven {
name 'myLocal'
url "file://$projectDir/../repo/$bintrayUsername"
}
maven {
name 'Bintray'
url "$bintrayBaseUrl/$bintrayUsername/$bintrayRepository/$bintrayPackage"
credentials {
username = bintrayUsername
password = bintrayApiKey
}
}
}
}
/*
Release procedure:
1. edit version numbers: remove -SNAPSHOT classifier
2. gradlew bumpVersion
3. check modified files
4. gradlew clean build
5. gradlew copyDocs
6. update RELEASE-NOTES.md
7. commit -m "Release picocli version ..."
8. tag v$version
9. gradlew publishPluginPublicationToBintrayRepository
10. edit version numbers: increase minor version and add -SNAPSHOT classifier
11. gradlew bumpVersion
12. check modified files
13. commit -m "Prepare for next development cycle"
14. push (make sure that Push Tags is checked)
15. Log in to GitHub, go to https://github.com/remkop/picocli/releases
16. Click the new tag, click Edit button, update title and release notes (copy from RELEASE-NOTES.md)
17. Upload picocli-$version.jar and picocli-all$version.zip to GitHub
18. Log in to Bintray
19. Navigate to the page for the new version
20. Edit version: Publication Date, Description, VCS tag, GitHub release notes file (RELEASE-NOTES.md)
21. On the version page, Release Notes tab, select GitHub File
22. Publish artifacts to JCenter
22. On the version page, Maven Central tab, sync to Maven (takes several minutes)
*/