Skip to content

Commit ee545b2

Browse files
committed
docopt port for Kotlin
1 parent b28f30f commit ee545b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3763
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*~
2+
/build/
3+
/.gradle/
4+
/.idea/
5+
/out/

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
- docker
3+
script:
4+
- >
5+
docker run
6+
-e "HOSTUID=`id -u`"
7+
-e "HOSTGID=`id -g`"
8+
-v "`pwd`:/work"
9+
-v "$HOME:/home/hostuser"
10+
-i -t wtanaka/alpine-37-uid-openjdk8-gradle-git
11+
./gradlew check

bintray.gradle

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
6+
dependencies {
7+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
8+
}
9+
}
10+
11+
// https://discuss.gradle.org/t/plugin/7508/2
12+
apply plugin: com.jfrog.bintray.gradle.BintrayPlugin
13+
apply plugin: "maven-publish"
14+
15+
project.ext["signing.keyId"] = '74B2DD02'
16+
project.ext["signing.password"] = System.getenv("GPG_PASSPHRASE") ?: ""
17+
project.ext["signing.secretKeyRingFile"] = file("../sec.gpg").absolutePath
18+
19+
group = 'com.wtanaka'
20+
project.ext["artifactId"] = 'kotlin-sample'
21+
project.ext["websiteUrl"] = 'https://wtanaka.com/'
22+
project.ext["description"] = 'Sample Kotlin Project Layout'
23+
project.ext["githubuser"] = "wtanaka"
24+
project.ext["githubrepo"] = "streaming"
25+
26+
def pomConfig = {
27+
licenses {
28+
license {
29+
name "GNU General Public License, Version 3.0"
30+
url "http://www.gnu.org/licenses/gpl-3.0.html"
31+
distribution "repo"
32+
}
33+
}
34+
developers {
35+
developer {
36+
id "wtanaka"
37+
name "wtanaka.com"
38+
39+
}
40+
}
41+
scm {
42+
connection "scm:git:git://github.com/" + project.ext['githubuser'] +
43+
"/" + project.ext['githubrepo'] + ".git"
44+
developerConnection "scm:git:ssh://github.com:" + project.ext['githubuser'] +
45+
"/" + project.ext['githubrepo'] + ".git"
46+
url "https://github.com/" + project.ext['githubuser'] +
47+
"/" + project.ext['githubrepo'] + "/tree/master"
48+
}
49+
}
50+
51+
// Used for bintray
52+
publishing {
53+
publications {
54+
MyPublication(MavenPublication) {
55+
from components.java
56+
57+
project.configurations.archives.allArtifacts.findAll({
58+
it.classifier in (["sources", "javadoc"] as Set)
59+
}).each({
60+
artifact it
61+
})
62+
63+
groupId project.group
64+
artifactId project.ext['artifactId']
65+
version project.version
66+
pom.withXml {
67+
def root = asNode()
68+
root.appendNode('description', project.ext['description'])
69+
root.appendNode('name', project.group + '.' + project.ext['artifactId'])
70+
root.appendNode('url', project.ext['websiteUrl'])
71+
root.children().last() + pomConfig
72+
}
73+
}
74+
}
75+
}
76+
77+
bintray {
78+
user = System.getenv('BINTRAY_USER')
79+
key = System.getenv('BINTRAY_KEY')
80+
publications = ['MyPublication']
81+
publish = true
82+
override = true
83+
pkg {
84+
repo = 'maven'
85+
name = project.ext['artifactId']
86+
userOrg = System.getenv('BINTRAY_USER')
87+
desc = project.ext['description']
88+
licenses = ["GPL-3.0"]
89+
issueTrackerUrl = 'https://github.com/wtanaka/kotlin-sample/issues'
90+
vcsUrl = 'https://github.com/wtanaka/kotlin-sample.git'
91+
websiteUrl = project.ext['websiteUrl']
92+
publicDownloadNumbers = true
93+
version {
94+
name = project.version
95+
released = new Date()
96+
gpg {
97+
sign = true
98+
// passphrase = ''
99+
}
100+
}
101+
}
102+
}
103+

build.gradle

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apply plugin: 'kotlin'
2+
apply from: 'gitversion.gradle'
3+
apply from: 'findbugs.gradle'
4+
apply from: 'detekt.gradle'
5+
apply from: 'ktlint.gradle'
6+
apply from: 'bintray.gradle'
7+
8+
buildscript {
9+
ext.kotlin_version = '1.2.41'
10+
ext.detekt_version = '1.0.0.RC7'
11+
12+
repositories {
13+
mavenCentral()
14+
}
15+
dependencies {
16+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17+
}
18+
}
19+
20+
repositories {
21+
mavenCentral()
22+
}
23+
24+
dependencies {
25+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
26+
implementation "com.google.code.findbugs:annotations:2.0.2"
27+
testCompile "junit:junit:4.12"
28+
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
29+
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
30+
}
31+
32+
compileKotlin {
33+
kotlinOptions.allWarningsAsErrors = true
34+
}
35+
36+
task sourceJar(type: Jar) {
37+
from sourceSets.main.allJava
38+
classifier "sources"
39+
}
40+
41+
task javadocJar(type: Jar, dependsOn: javadoc) {
42+
from javadoc.destinationDir
43+
classifier = 'javadoc'
44+
}
45+
46+
// Needed for bintray
47+
project.artifacts {
48+
archives sourceJar
49+
archives javadocJar
50+
}
51+

config/detekt.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
autoCorrect: false
2+
failFast: true
3+
4+
test-pattern: # Configure exclusions for test sources
5+
active: true
6+
patterns: # Test file regexes
7+
- '.*/test/.*'
8+
- '.*Test.kt'
9+
- '.*Spec.kt'
10+
exclude-rule-sets:
11+
- 'comments'
12+
exclude-rules:
13+
- 'NamingRules'
14+
- 'WildcardImport'
15+
- 'MagicNumber'
16+
- 'MaxLineLength'
17+
- 'LateinitUsage'
18+
- 'StringLiteralDuplication'
19+
- 'SpreadOperator'
20+
- 'TooManyFunctions'
21+
22+
processors:
23+
active: true
24+
exclude:
25+
# - 'FunctionCountProcessor'
26+
# - 'PropertyCountProcessor'
27+
# - 'ClassCountProcessor'
28+
# - 'PackageCountProcessor'
29+
# - 'KtFileCountProcessor'
30+
31+
console-reports:
32+
active: true
33+
exclude:
34+
# - 'ProjectStatisticsReport'
35+
# - 'ComplexityReport'
36+
# - 'NotificationReport'
37+
# - 'FindingsReport'
38+
# - 'BuildFailureReport'
39+
40+
output-reports:
41+
active: true
42+
exclude:
43+
# - 'HtmlOutputReport'
44+
# - 'PlainOutputReport'
45+
# - 'XmlOutputReport'
46+
47+
style:
48+
MaxLineLength:
49+
maxLineLength: 80

config/findbugs-filter.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FindBugsFilter>
3+
<Match>
4+
<!-- Already detected in Kotlin -->
5+
<Bug code="NP" />
6+
</Match>
7+
</FindBugsFilter>

detekt.gradle

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repositories {
2+
mavenCentral()
3+
// For detekt
4+
maven { url "https://plugins.gradle.org/m2/" }
5+
}
6+
7+
configurations {
8+
detekt
9+
}
10+
11+
dependencies {
12+
detekt "io.gitlab.arturbosch.detekt:detekt-cli:$detekt_version"
13+
}
14+
15+
// Use the command line version of detekt because
16+
// the plugin does not deal with nested projects well
17+
task detekt(type: JavaExec) {
18+
main = "io.gitlab.arturbosch.detekt.cli.Main"
19+
classpath = configurations.detekt
20+
def input = "$projectDir"
21+
def config = "$projectDir/config/detekt.yml"
22+
def filters = ".*test.*"
23+
def params = ['-i', input, '-c', config, '-f', filters]
24+
args(params)
25+
}
26+
check.dependsOn detekt

findbugs.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apply plugin: 'findbugs'
2+
3+
findbugs {
4+
excludeFilter = project.file('config/findbugs-filter.xml')
5+
}
6+
7+
tasks.withType(FindBugs) {
8+
reports {
9+
xml.enabled = false
10+
html.enabled = true
11+
}
12+
}

gitversion.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
buildscript{
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
8+
dependencies {
9+
classpath "gradle.plugin.com.palantir.gradle.gitversion:gradle-git-version:0.10.1"
10+
}
11+
}
12+
13+
// Pull current git version into gradle variable
14+
// https://discuss.gradle.org/t/plugin/7508/2
15+
apply plugin: com.palantir.gradle.gitversion.GitVersionPlugin
16+
17+
project.setVersion(gitVersion())

gradle/wrapper/gradle-wrapper.jar

53.4 KB
Binary file not shown.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Fri Apr 20 20:03:08 HST 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 commit comments

Comments
 (0)