Skip to content

Commit 8d5fd21

Browse files
committed
Add dokka, bintray, and gradle-release support
This started as trying to get bintray uploading working, and resulted in a yak shaving session.
1 parent 54a501e commit 8d5fd21

File tree

3 files changed

+148
-11
lines changed

3 files changed

+148
-11
lines changed

build.gradle

+142-11
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,42 @@
1616
// You should have received a copy of the GNU Lesser General Public License
1717
// along with this library; if not, see http://www.gnu.org/licenses/
1818

19-
version '1.0-SNAPSHOT'
20-
21-
apply plugin: 'kotlin'
22-
apply plugin: 'java'
23-
24-
repositories {
25-
mavenCentral()
26-
}
27-
2819
buildscript {
29-
ext.kotlin_version = '1.0.5-2'
30-
3120
repositories {
3221
mavenCentral()
22+
jcenter()
3323
}
3424

3525
dependencies {
3626
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
27+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
3728
}
3829
}
3930

31+
plugins {
32+
id "com.jfrog.bintray" version "1.7.3"
33+
id 'net.researchgate.release' version "2.5.0"
34+
}
35+
36+
apply plugin: 'kotlin'
37+
apply plugin: 'java'
38+
apply plugin: 'org.jetbrains.dokka'
39+
apply plugin: 'maven-publish'
40+
41+
assert name == 'kotlin-argparser'
42+
def prettyName = 'Kotlin ArgParser'
43+
def tagline = 'Concise and easy yet powerful and robust command line argument parsing for Kotlin'
44+
45+
group 'com.xenomachina'
46+
def githubRepo = "xenomachina/$name"
47+
def vcsUrl = "https://github.com/$githubRepo"
48+
49+
sourceCompatibility = 1.6
50+
51+
repositories {
52+
mavenCentral()
53+
}
54+
4055
dependencies {
4156
testCompile 'junit:junit:4.12'
4257
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -46,3 +61,119 @@ dependencies {
4661
sourceSets {
4762
main.java.srcDirs += 'src/main/kotlin'
4863
}
64+
65+
//////////////////////////////////////////////////////////////////////////////
66+
// Dokka config
67+
//////////////////////////////////////////////////////////////////////////////
68+
69+
// Based on https://github.com/Kotlin/dokka
70+
dokka {
71+
moduleName = project.name
72+
outputFormat = 'javadoc'
73+
outputDirectory = "$buildDir/javadoc"
74+
processConfigurations = ['compile']
75+
//includes = ['packages.md', 'extra.md']
76+
//samples = ['samples/basic.kt', 'samples/advanced.kt']
77+
linkMapping {
78+
dir = "src/main/kotlin"
79+
url = "$vcsUrl/blob/master/src/main/kotlin"
80+
suffix = "#L"
81+
}
82+
sourceDirs = files('src/main/kotlin')
83+
}
84+
85+
// From @dimsuz at https://github.com/Kotlin/dokka/issues/42
86+
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
87+
outputFormat = 'javadoc'
88+
outputDirectory = javadoc.destinationDir
89+
inputs.dir 'src/main/kotlin'
90+
}
91+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
92+
classifier = 'javadoc'
93+
from javadoc.destinationDir
94+
}
95+
96+
//////////////////////////////////////////////////////////////////////////////
97+
// bintrayUpload config
98+
//////////////////////////////////////////////////////////////////////////////
99+
100+
// Based on https://github.com/bintray/gradle-bintray-plugin
101+
bintray {
102+
user = System.getenv('BINTRAY_USER')
103+
key = System.getenv('BINTRAY_KEY')
104+
105+
pkg {
106+
repo = 'maven'
107+
name = project.name
108+
109+
licenses = ['LGPL-2.1']
110+
vcsUrl = vcsUrl
111+
websiteUrl = vcsUrl
112+
issueTrackerUrl = "$vcsUrl/issues"
113+
githubRepo = githubRepo
114+
// TODO githubReleaseNotesFile = ???
115+
116+
version {
117+
name = project.version
118+
desc = "$prettyName version $project.version"
119+
released = new Date()
120+
vcsTag = "$project.version"
121+
}
122+
}
123+
124+
publications = ['MyPublication']
125+
}
126+
127+
// Create the pom configuration:
128+
def pomConfig = {
129+
licenses {
130+
license {
131+
name "GNU Lesser General Public License, Version 2.1"
132+
url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
133+
distribution "repo"
134+
}
135+
}
136+
developers {
137+
developer {
138+
id "xenomachina"
139+
name "Laurence Gonsalves"
140+
141+
// State-of-the art anti-scraper encryption. ;-)
142+
email "moc.anihcamonex@ecnerual".reverse()
143+
}
144+
}
145+
}
146+
147+
task sourcesJar(type: Jar, dependsOn: classes) {
148+
classifier = 'sources'
149+
from sourceSets.main.allSource
150+
}
151+
152+
// Create the publication with the pom configuration:
153+
publishing {
154+
publications {
155+
MyPublication(MavenPublication) {
156+
from components.java
157+
artifact sourcesJar
158+
artifact javadocJar
159+
// We use default groupId, artifactId, and version
160+
161+
pom.withXml {
162+
def root = asNode()
163+
root.appendNode('description', tagline)
164+
root.appendNode('name', prettyName)
165+
root.appendNode('url', vcsUrl)
166+
root.children().last() + pomConfig
167+
}
168+
}
169+
}
170+
}
171+
172+
//////////////////////////////////////////////////////////////////////////////
173+
// gradle-release plugin config
174+
//////////////////////////////////////////////////////////////////////////////
175+
176+
// Based on https://github.com/researchgate/gradle-release
177+
178+
// This causes './gradlew release' to also upload release package to bintray.
179+
afterReleaseBuild.dependsOn bintrayUpload

gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version=1.0.0-SNAPSHOT
2+
3+
# Dependency versions
4+
kotlin_version = 1.0.5-2
5+
dokka_version = 0.9.11

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "kotlin-argparser"

0 commit comments

Comments
 (0)