Commit ebe1989
committed
Fix: Resolve ClassNotFoundException for KTS scripts
This commit fixes a ClassNotFoundException that occurred when running KTS scripts. The issue was caused by your script class not being packaged into the scriplet.jar during compilation.
The fix involves combining your script code and the wrapper code into a single string before compilation. This ensures that kotlinc treats them as a single compilation unit and packages all necessary classes into the resulting JAR.
Specifically, the changes are:
- In `JarArtifactCreator.kt`:
- For KTS scripts, your script content and the generated wrapper content are now concatenated into a single string.
- This combined string is written to a single temporary .kt file, which is then passed to the Kotlin compiler.
- In `Templates.kt`:
- `createWrapperForScript` now ensures the wrapper code has the correct package declaration, consistent with your script.
This approach should resolve the ClassNotFoundException and allow KTS scripts to be compiled and executed correctly.1 parent 1507273 commit ebe1989
File tree
2 files changed
+18
-9
lines changed- src/main/kotlin/io/github/kscripting/kscript
- code
- creator
2 files changed
+18
-9
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | 46 | | |
49 | | - | |
50 | 47 | | |
51 | | - | |
52 | 48 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
0 commit comments