Skip to content

Commit d671178

Browse files
authored
Distribute Clikt on all Kotlin MPP desktop platforms (#127)
This includes JVM, NodeJS, Linux, Windows, and MacOS. With the exception of some [Kotlin compiler bugs](https://youtrack.jetbrains.com/issue/KT-33294), all functionality is implemented on all platforms. Since JitPack does not currently support MPP projects, snapshots will now be distributed through Maven Central.
1 parent 022d6f6 commit d671178

File tree

105 files changed

+1217
-467
lines changed

Some content is hidden

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

105 files changed

+1217
-467
lines changed

.github/workflows/publish.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: build
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'doc/**'
7+
- '*.md'
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
os: [macOS-latest, windows-latest, ubuntu-latest]
16+
17+
runs-on: ${{matrix.os}}
18+
19+
steps:
20+
- name: Checkout the repo
21+
uses: actions/checkout@v2
22+
23+
- name: Run ubuntu tests
24+
if: matrix.os == 'ubuntu-latest'
25+
run: ./gradlew check
26+
27+
- name: Run windows tests
28+
if: matrix.os == 'windows-latest'
29+
run: ./gradlew mingwX64Test
30+
31+
- name: Run macOS tests
32+
if: matrix.os == 'macOS-latest'
33+
run: ./gradlew macosX64Test
34+
35+
- name: Bundle the build report
36+
if: failure()
37+
run: find . -type d -name 'reports' | zip -@ -r build-reports.zip
38+
39+
- name: Upload the build report
40+
if: failure()
41+
uses: actions/upload-artifact@master
42+
with:
43+
name: error-report
44+
path: build-reports.zip
45+
46+
deploy-mac-and-linux:
47+
needs: build
48+
runs-on: macOS-latest
49+
steps:
50+
- name: Checkout the repo
51+
uses: actions/checkout@v2
52+
- name: Set build tag
53+
run: echo ::set-env name=BUILD_TAG::$(git tag --points-at HEAD)
54+
- name: Set build number
55+
run: echo ::set-env name=BUILD_NUMBER::$(git rev-list --count HEAD)
56+
- name: deploy to sonatype snapshots
57+
run: ./gradlew publish
58+
env:
59+
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
60+
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
61+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_signingKey }}
62+
63+
deploy-windows:
64+
needs: build
65+
runs-on: windows-latest
66+
steps:
67+
- name: Checkout the repo
68+
uses: actions/checkout@v2
69+
- name: Set build tag
70+
run: echo ::set-env name=BUILD_TAG::$(git tag --points-at HEAD)
71+
- name: Set build number
72+
run: echo ::set-env name=BUILD_NUMBER::$(git rev-list --count HEAD)
73+
- name: deploy to sonatype snapshots
74+
run: ./gradlew publishMingwX64PublicationToMavenRepository
75+
env:
76+
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
77+
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
78+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_signingKey }}
79+
80+
env:
81+
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"

.github/workflows/PR.yml renamed to .github/workflows/test.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ on:
66
- 'docs/**'
77
- '*.md'
88

9+
910
jobs:
1011
build:
11-
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
os: [macOS-latest, windows-latest, ubuntu-latest]
15+
16+
runs-on: ${{matrix.os}}
1217

1318
steps:
1419
- name: Checkout the repo
15-
uses: actions/checkout@v1
20+
uses: actions/checkout@v2
21+
1622
- name: Cache gradle
1723
uses: actions/cache@v1
1824
with:
@@ -21,8 +27,15 @@ jobs:
2127
restore-keys: |
2228
${{ runner.os }}-gradle-
2329
24-
- name: Run tests
25-
run: ./gradlew build
30+
- name: Run ubuntu tests
31+
if: matrix.os == 'ubuntu-latest'
32+
run: ./gradlew check
33+
- name: Run windows tests
34+
if: matrix.os == 'windows-latest'
35+
run: ./gradlew mingwX64Test
36+
- name: Run macOS tests
37+
if: matrix.os == 'macOS-latest'
38+
run: ./gradlew macosX64Test
2639

2740
- name: Bundle the build report
2841
if: failure()

LICENSE.txt

100755100644
File mode changed.

README.md

+23-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
<p><img src="docs/img/animation.png"></p>
44
</h1>
55

6-
Clikt *(pronounced "clicked")* is a Kotlin library that makes writing
7-
command line interfaces simple and intuitive. It's the "Command Line
8-
Interface for Kotlin".
6+
Clikt *(pronounced "clicked")* is a multiplatform Kotlin library that makes writing command line
7+
interfaces simple and intuitive. It's the "Command Line Interface for Kotlin".
98

109
It is designed to make the process of writing command line tools effortless
1110
while supporting a wide variety of use cases and allowing advanced
@@ -16,9 +15,9 @@ Clikt has:
1615
* arbitrary nesting of commands
1716
* composable, type safe parameter values
1817
* support for a wide variety of command line interface styles
18+
* multiplatform packages for JVM, NodeJS, and native Linux, Windows and MacOS
1919

20-
What does it look like? Here's a complete example of a simple Clikt
21-
program:
20+
What does it look like? Here's a complete example of a simple Clikt program:
2221

2322
```kotlin
2423
class Hello : CliktCommand() {
@@ -35,7 +34,7 @@ class Hello : CliktCommand() {
3534
fun main(args: Array<String>) = Hello().main(args)
3635
```
3736

38-
And here's what it looks like when run:
37+
And here's what it looks like when run:
3938

4039
```
4140
$ ./hello --count=3
@@ -75,17 +74,31 @@ them with the included [`runsample` script](runsample).
7574

7675
## Installation
7776

78-
Clikt is distributed through
79-
[Maven Central](https://mvnrepository.com/artifact/com.github.ajalt/clikt),
80-
[Jcenter](https://bintray.com/ajalt/maven/clikt) and
81-
[Jitpack](https://jitpack.io/#ajalt/clikt).
77+
Clikt is distributed through [Maven Central](https://search.maven.org/artifact/com.github.ajalt/clikt).
8278

8379
```groovy
8480
dependencies {
8581
implementation("com.github.ajalt:clikt:2.4.0")
8682
}
8783
```
8884

85+
For Kotlin/Native and Kotlin/JS, use `"com.github.ajalt:clikt-multiplatform:2.4.0"` instead.
86+
87+
<details>
88+
<summary>Snapshot builds are also available</summary>
89+
90+
You'll need to add the Sonatype snapshots repository:
91+
92+
```kotlin
93+
repositories {
94+
maven {
95+
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
96+
}
97+
}
98+
```
99+
100+
</details>
101+
89102
## License
90103

91104
Copyright 2018-2020 AJ Alt

build.gradle

+13-29
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,27 @@ buildscript {
88

99
dependencies {
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.0"
11+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.1"
1212
}
1313
}
1414

15-
apply plugin: 'idea'
16-
apply plugin: 'org.jetbrains.dokka'
17-
18-
repositories {
19-
mavenCentral()
20-
jcenter()
21-
}
22-
23-
subprojects {
24-
apply plugin: 'kotlin'
25-
26-
group = GROUP
27-
version = VERSION_NAME
28-
15+
allprojects {
16+
group = "com.github.ajalt"
17+
version = getPublishVersion()
2918
repositories {
3019
mavenCentral()
3120
jcenter()
3221
}
22+
}
3323

34-
dependencies {
35-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
24+
@SuppressWarnings("GrMethodMayBeStatic") // false-positive; we access VERSION_NAME
25+
private def getPublishVersion() {
26+
final tag = System.getenv("BUILD_TAG")
27+
if (tag != null) return tag
3628

37-
testImplementation 'junit:junit:4.12'
38-
testImplementation 'io.kotlintest:kotlintest-assertions:3.4.2'
39-
testImplementation 'com.github.stefanbirkner:system-rules:1.18.0'
40-
testImplementation 'com.google.jimfs:jimfs:1.1'
41-
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
42-
}
43-
44-
compileKotlin {
45-
kotlinOptions.jvmTarget = "1.8"
46-
}
47-
compileTestKotlin {
48-
kotlinOptions.jvmTarget = "1.8"
29+
final buildNumber = System.getenv("BUILD_NUMBER")
30+
if (buildNumber != null) {
31+
return VERSION_NAME + "." + buildNumber + "-SNAPSHOT"
4932
}
33+
return VERSION_NAME
5034
}

clikt/build.gradle

-73
This file was deleted.

0 commit comments

Comments
 (0)