Skip to content

Commit ad9342c

Browse files
committed
optimize build script
1 parent aeceb91 commit ad9342c

3 files changed

Lines changed: 53 additions & 77 deletions

File tree

.travis.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ jdk:
66
sudo: true
77

88
before_install:
9-
# 赋予执行权限
109
- chmod a+x gradlew
1110

1211
script:
13-
# 清理、生成、测试、文档
14-
- ./gradlew clean build dokka
12+
- ./gradlew check allJars
1513

1614
before_cache:
1715
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
@@ -31,15 +29,6 @@ deploy:
3129
on:
3230
tags: true
3331
branch: version2
34-
# 发布到 Bintray (布星)
35-
- provider: bintray
36-
skip_cleanup: true
37-
file: "deploy.json"
38-
user: $BintrayUser
39-
key: $BintrayAPIKey
40-
on:
41-
tags: true
42-
branch: version2
4332

4433
notifications:
4534
webhooks: https://oapi.dingtalk.com/robot/send?access_token=4b59c5ece57fc88af8fda28cc07573c4caf525aa69afc0cc888ccf3ce6dbe41b

build.gradle.kts

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import org.jetbrains.dokka.gradle.LinkMapping
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
plugins {
4-
kotlin("jvm") version "1.3.50"
5-
id("org.jetbrains.dokka") version "0.9.17"
5+
kotlin("jvm") version "1.3.50" apply (true)
6+
id("org.jetbrains.dokka") version "0.9.18"
7+
id("com.jfrog.bintray") version "1.8.4"
68
`build-scan`
79
}
810

@@ -12,43 +14,70 @@ buildScan {
1214
publishAlways()
1315
}
1416

17+
group = "org.mechdancer"
1518
version = "0.2.5-dev-3"
1619

17-
allprojects {
18-
apply(plugin = "kotlin")
19-
group = "org.mechdancer"
20-
repositories {
21-
mavenCentral()
22-
jcenter()
23-
}
24-
dependencies {
25-
implementation(kotlin("stdlib-jdk8"))
2620

27-
testImplementation("junit", "junit", "+")
28-
testImplementation(kotlin("test-junit"))
29-
}
30-
tasks.withType<KotlinCompile> {
31-
kotlinOptions {
32-
jvmTarget = "1.8"
33-
}
21+
repositories {
22+
mavenCentral()
23+
jcenter()
24+
}
25+
dependencies {
26+
implementation(kotlin("stdlib-jdk8"))
27+
28+
testImplementation("junit", "junit", "+")
29+
testImplementation(kotlin("test-junit"))
30+
}
31+
tasks.withType<KotlinCompile> {
32+
kotlinOptions {
33+
jvmTarget = "1.8"
3434
}
3535
}
3636

37+
3738
tasks.dokka {
3839
outputFormat = "html"
3940
outputDirectory = "$buildDir/javadoc"
41+
linkMappings.add(LinkMapping().apply {
42+
dir = "src"
43+
url = "https://github.com/MechDancer/linearalgebra/tree/master/src"
44+
suffix = "#L"
45+
})
4046
}
4147

42-
val dokkaJar by tasks.creating(Jar::class) {
48+
val doc = tasks.register<Jar>("javadocJar") {
4349
group = JavaBasePlugin.DOCUMENTATION_GROUP
4450
description = "Assembles Kotlin docs with Dokka"
4551
archiveClassifier.set("javadoc")
4652
from(tasks.dokka)
4753
}
4854

49-
val packJars by tasks.creating(Jar::class) {
55+
val sources = tasks.register<Jar>("sourcesJar") {
5056
group = JavaBasePlugin.BUILD_TASK_NAME
51-
description = "pack all jars"
52-
from(tasks.jar)
53-
from(dokkaJar)
57+
description = "Creates sources jar"
58+
archiveClassifier.set("sources")
59+
from(sourceSets.main.get().allSource)
5460
}
61+
62+
val fat = tasks.register<Jar>("fatJar") {
63+
group = JavaBasePlugin.BUILD_TASK_NAME
64+
description = "Packs binary output with dependencies"
65+
archiveClassifier.set("all")
66+
from(sourceSets.main.get().output)
67+
from({
68+
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
69+
})
70+
}
71+
72+
tasks.register("allJars") {
73+
group = JavaBasePlugin.BUILD_TASK_NAME
74+
description = "Assembles all jars in one task"
75+
dependsOn(doc, sources, fat, tasks.jar)
76+
}
77+
78+
artifacts {
79+
add("archives", tasks.jar)
80+
add("archives", fat)
81+
add("archives", sources)
82+
add("archives", doc)
83+
}

deploy.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)