Skip to content

Commit 66dbebe

Browse files
committed
Merge branch 'kscript4'
# Conflicts: # build.gradle.kts
2 parents 8909371 + 44a046a commit 66dbebe

Some content is hidden

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

68 files changed

+2944
-1965
lines changed

CHANGES.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
* Improved test_suite.sh
2+
* Automatic setting up of test environment (assert.sh, test directories)
3+
* Automatic compilation
4+
* idea - script to help to test idea use cases
5+
* Script setup_environment.sh can be used for local testing
6+
* Some script tests moved to Unit Tests
7+
8+
* Improved Unit Tests
9+
* Several new Unit tests
10+
* New Unit Tests can be created much easier (Major point why modularization makes sense)
11+
12+
* Improved Logging
13+
* Silent mode / Development mode logging
14+
15+
* Modularisation of source code
16+
* Removed duplication
17+
* Code divided in logical pieces and moved to packages
18+
* Script resolution creates immutable objects
19+
20+
* Build script
21+
* Updated Gradle to version 7.3 and shadowJar to 6.1.0
22+
* Fixes in build file
23+
24+
* Performance
25+
* Much less IO operations - that should contribute to better performance
26+
27+
* Updated Kotlin to 1.5.31, but only for compiler, not kotlin-scripting. It's far from optimal, but it is not possible to move fully to Kotlin 1.5 or even 1.6, because of the issues with resolution of artifacts in latest kotlin-scripting. I have put report here: https://youtrack.jetbrains.com/issue/KT-49511
28+
29+
* Fixed a lot of IDE warnings in code
30+
31+
* Packaging - gradle file converted to Kotlin; still does not work, but it was like that before anyway
32+
33+
* Changes for kscript dir allow simple implementation of config file if needed. (.kscript/kscript.config); Not implemented by me, but might be useful e.g. for storing preambles
34+
35+
INCOMPATIBLE CHANGES:
36+
* In annotations the only allowed delimiter is coma "," (to allow options with arguments, separated by space)
37+
* Resolution of env variables is more restrictive - only vars expected by kscript can be resolved (for security - it's not good to include arbitrary strings from user env into the script)
38+
* Reworked caching mechanism
39+
* Dropped cache for resolution of artifacts - I can not observe change in resolution time. In fact .m2 repository is already kind of cache, so it should not be needed to add another one.
40+
41+
SUGGESTIONS:
42+
* I would drop old annotations based on comments or at least depreciate them
43+
* It's worthy to consider dropping ability to reference script by $HOME and by '/'. It will break other scripts if used in web scripts.
44+
* There might be duplicate names when loading even different files from URI. Then when the idea project creates source dir it will fail: e.g. idea project from include_variations.kts. Requires some other way of setting up IDEA project.
45+
46+
SUGGESTIONS - MERGE:
47+
* Please do "Squash Merge" - there is a lot of changes and experiments in code - no reason to keep them in log
48+
* One test in ScriptResolverTest is @Disabled. It should be enabled and committed again after merge, so that references to URLs are correct
49+
* I would suggest to do release of kscript 4.0-beta for better tests of new implementation.
50+
*

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,4 @@ Other changes
237237

238238
## v1.0
239239

240-
Initial Release
240+
Initial Release

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ On the other hand this doesn't embed dependencies within the script("fat jar"),
483483
FAQ
484484
---
485485

486+
### How to edit kscript in VS Code?
487+
488+
See https://magnusgunnarsson.se/offentlig/kscript-in-visual-studio-code-vsc/ for a walkthrough and the required editor configuration.
489+
486490
### Why is `kscript` not calling the main method in my `.kts` script?
487491

488492
There is [no need](https://kotlinlang.org/docs/tutorials/command-line.html#using-the-command-line-to-run-scripts) for a `main` method in a Kotlin script. Kotlin `*.kts` scripts can be more simplistic compared to more common kotlin `*.kt` source files. The former work without a `main` method by directly running the provided code from top to bottom. E.g.

build.gradle.kts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
3+
import org.gradle.api.tasks.testing.logging.TestLogEvent
4+
5+
val kotlinVersion: String = "1.6.20"
26

37
plugins {
4-
kotlin("jvm") version "1.4.32"
8+
kotlin("jvm") version "1.6.20"
59
application
6-
id("com.github.johnrengelman.shadow") version "5.2.0"
10+
id("com.github.johnrengelman.shadow") version "6.1.0"
711
}
812

913
repositories {
@@ -12,23 +16,49 @@ repositories {
1216

1317
group = "com.github.holgerbrandl.kscript.launcher"
1418

15-
//val kotlinVersion: String by rootProject.extra
16-
val kotlinVersion: String ="1.4.32"
19+
tasks.test {
20+
useJUnitPlatform()
21+
22+
testLogging {
23+
events(TestLogEvent.FAILED); exceptionFormat = TestExceptionFormat.FULL
24+
}
25+
}
26+
27+
tasks.withType<Test> {
28+
addTestListener(object : TestListener {
29+
override fun beforeSuite(suite: TestDescriptor) { logger.quiet("\nTest class: ${suite.displayName}") }
30+
override fun beforeTest(testDescriptor: TestDescriptor) {}
31+
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {
32+
logger.quiet("${String.format( "%-60s - %-10s", testDescriptor.name, result.resultType )} ")
33+
}
34+
35+
override fun afterSuite(suite: TestDescriptor, result: TestResult) {}
36+
})
37+
}
38+
1739
val launcherClassName: String ="kscript.app.KscriptKt"
1840

1941
dependencies {
20-
compile("com.offbytwo:docopt:0.6.0.20150202")
42+
implementation("com.offbytwo:docopt:0.6.0.20150202")
2143

2244
implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
2345
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
46+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-RC3")
47+
2448
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
2549
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:$kotlinVersion")
2650
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven:$kotlinVersion")
2751

28-
compile("org.slf4j:slf4j-nop:1.7.30")
52+
implementation("commons-io:commons-io:2.11.0")
53+
implementation("commons-codec:commons-codec:1.15")
54+
55+
implementation("org.slf4j:slf4j-nop:1.7.32")
56+
57+
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
58+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")
59+
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
60+
testImplementation("io.mockk:mockk:1.12.1")
2961

30-
testImplementation("junit:junit:4.12")
31-
testImplementation( "io.kotlintest:kotlintest:2.0.7")
3262
testImplementation(kotlin("script-runtime"))
3363
}
3464

gradle/wrapper/gradle-wrapper.jar

3.83 KB
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-6.7-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)