Skip to content

Commit 018c63a

Browse files
committed
Build config refactoring
- Main build.gradle refactored: - build.gradle converted to gradle/kotlin-dsl (yes, Kotlin scripting for build config of Kscript) - Use plugins dsl instead of buildscript - Shadow JAR file name now consistent for all versions and we avoid copy to root of the project - Fixed project version - Cleaned comments - .gitignore cleanup from useless ignores - Default lifecycle task assemble now builds shadowJar instead of jar - Junit 4.12 (the latest bug fix release of Junit) # Conflicts: # .travis.yml # build.gradle # src/main/kotlin/kscript/app/ResolveIncludes.kt # test/test_suite.sh
1 parent df34204 commit 018c63a

File tree

15 files changed

+65
-76
lines changed

15 files changed

+65
-76
lines changed

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@ build/
33
target/
44
out/
55

6-
# Ignore Gradle GUI config
7-
gradle-app.setting
8-
9-
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
10-
!gradle-wrapper.jar
11-
126
# Cache of project
137
.gradletasknamecache
148

15-
.*jar
169
*.iml
1710
.idea
1811

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,17 @@ install:
4545
- sdk install kotlin
4646
- sdk install gradle
4747

48-
## install assert.h
49-
- wget https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh && chmod +x assert.sh
50-
5148
- export KSCRIPT_HOME="/home/travis/build/holgerbrandl/kscript"
49+
- export KSCRIPT_BUILD_LIBS="$KSCRIPT_HOME/build/libs"
5250
- pwd
53-
- export PATH=$KSCRIPT_HOME::$PATH
51+
- export PATH=$KSCRIPT_BUILD_LIBS::$PATH
5452

5553
# build it
56-
- cd $KSCRIPT_HOME && ./gradlew shadowJar
54+
- cd $KSCRIPT_HOME && ./gradlew assemble
55+
- cd $KSCRIPT_BUILD_LIBS
5756

57+
## install assert.h
58+
- wget https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh && chmod +x assert.sh
5859

5960
- which kscript
6061
- which assert.sh
@@ -67,6 +68,7 @@ install:
6768
- kscript ${KSCRIPT_HOME}/test/resources/multi_line_deps.kts
6869
# - resdeps.kts org.org.docopt:org.docopt:0.6.0-SNAPSHOT log4j:log4j:1.2.14
6970
# - kscript ${KSCRIPT_HOME}/test/resources/multi_line_deps.kts
71+
- cd $KSCRIPT_HOME
7072

7173
script: ./test/test_suite.sh
7274

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ brew install holgerbrandl/tap/kscript
8181

8282
To build `kscript` yourself, simply clone the repo and do
8383
```bash
84-
./gradlew shadowJar
84+
./gradlew assemble
8585

86-
## Don't forget to prefix with `./` when running the freshly compiled version
87-
./kscript
86+
## Run kscript from output dir
87+
./build/libs/kscript
8888
```
8989

9090
## Script Input Modes

build.gradle

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

build.gradle.kts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
3+
plugins {
4+
kotlin("jvm") version "1.2.30"
5+
id("com.github.johnrengelman.plugin-shadow") version "2.0.2"
6+
}
7+
8+
group = "com.github.holgerbrandl.kscript.launcher"
9+
10+
dependencies {
11+
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
12+
13+
compile("com.offbytwo:docopt:0.6.0.20150202")
14+
15+
testCompile("junit:junit:4.12")
16+
testCompile( "io.kotlintest:kotlintest:2.0.7")
17+
}
18+
19+
repositories {
20+
jcenter()
21+
}
22+
23+
val shadowJar by tasks.getting(ShadowJar::class) {
24+
// set empty string to classifier and version to get predictable jar file name: build/libs/kscript.jar
25+
archiveName = "kscript.jar"
26+
doLast {
27+
copy {
28+
from(File(projectDir, "src/kscript"))
29+
into(archivePath.parentFile)
30+
}
31+
}
32+
}
33+
34+
// Disable standard jar task to avoid building non-shadow jars
35+
val jar by tasks.getting {
36+
enabled = false
37+
}
38+
// Build shadowJar when
39+
val assemble by tasks.getting {
40+
dependsOn(shadowJar)
41+
}

gradle/wrapper/gradle-wrapper.jar

-295 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip

misc/benchmarking/benchmarking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ misc/benchmarking/benchmark_kscript.kts scriptlet_runtimes_$(git rev-parse --abb
2020

2121
## roll back to master and redo the benchmarking
2222
git checkout master
23-
./gradlew clean shadowJar
23+
./gradlew clean assemble
2424

2525
misc/benchmarking/benchmark_kscript.kts scriptlet_runtimes_$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD).txt
2626

misc/docker_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ docker attach `docker ps -q -l` # reattach the terminal & stdin
3434
cd kscript
3535
export KSCRIPT_HOME=$(pwd)
3636

37-
./gradlew shadowJar
37+
./gradlew assemble
3838

3939
wget https://raw.githubusercontent.com/lehmannro/assert.sh/master/assert.sh
4040
chmod u+x assert.sh

misc/kscript_release.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# 3. Push and wait for travis CI results
66

77
export KSCRIPT_HOME="/Users/brandl/projects/kotlin/kscript";
8+
export KSCRIPT_BUILD_LIBS="$KSCRIPT_HOME/build/libs";
89
export PATH=${KSCRIPT_HOME}:${PATH}
910
export PATH=~/go/bin/:$PATH
1011

@@ -24,12 +25,12 @@ echo "new version is $kscript_version"
2425

2526
cd $KSCRIPT_HOME
2627

27-
./gradlew clean shadowJar
28+
./gradlew clean assemble
2829

2930
## compile binary distribution (including jar and wrapper-script)
3031
mkdir -p $KSCRIPT_ARCHIVE/kscript-${kscript_version}/bin
31-
cp ${KSCRIPT_HOME}/kscript ${KSCRIPT_ARCHIVE}/kscript-${kscript_version}/bin
32-
cp ${KSCRIPT_HOME}/kscript.jar ${KSCRIPT_ARCHIVE}/kscript-${kscript_version}/bin/kscript.jar
32+
cp ${KSCRIPT_BUILD_LIBS}/kscript ${KSCRIPT_ARCHIVE}/kscript-${kscript_version}/bin
33+
cp ${KSCRIPT_BUILD_LIBS}/kscript.jar ${KSCRIPT_ARCHIVE}/kscript-${kscript_version}/bin/kscript.jar
3334

3435
cd ${KSCRIPT_ARCHIVE}
3536
rm ${KSCRIPT_ARCHIVE}/kscript-${kscript_version}.zip
@@ -42,7 +43,8 @@ open ${KSCRIPT_ARCHIVE}
4243
#Java SE 6.0 = 50 (0x32 hex) (from https://en.wikipedia.org/wiki/Java_class_file)
4344
#Default is 50, see https://kotlinlang.org/docs/reference/using-gradle.html#attributes-common-for-jvm-and-js
4445
## to insepct do
45-
#./gradlew clean shadowJar && cp build/libs/kscript-0.1-SNAPSHOT-all.jar kscript.jar
46+
#./gradlew clean assemble
47+
#cd ${KSCRIPT_BUILD_LIBS}
4648
#rm -rf kscript_target_test
4749
#cp -f kscript.jar kscript_target_test.zip
4850
#unzip kscript_target_test.zip -d kscript_target_test

0 commit comments

Comments
 (0)