Skip to content

Commit 514a1d6

Browse files
Jules was unable to complete the task in time. Please review the work done so far and provide feedback for Jules to continue.
1 parent 4697e7e commit 514a1d6

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/main/kotlin/io/github/kscripting/kscript/resolver/CommandResolver.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import io.github.kscripting.kscript.model.OsConfig
77
import io.github.kscripting.shell.model.OsPath
88
import io.github.kscripting.shell.model.OsType
99
import io.github.kscripting.shell.model.toNativeOsPath
10+
import java.io.File // ADDED IMPORT
1011

1112
class CommandResolver(val osConfig: OsConfig) {
1213
private val classPathSeparator =
@@ -49,9 +50,23 @@ class CommandResolver(val osConfig: OsConfig) {
4950
val compilerOptsStr = resolveCompilerOpts(compilerOpts)
5051
val classpath = resolveClasspath(dependencies)
5152
val jarFile = resolveJarFile(jar)
52-
val files = resolveFiles(filePaths)
53+
val files = resolveFiles(filePaths) // This 'files' variable contains the paths to the script(s) to be compiled
5354
val kotlinc = resolveKotlinBinary("kotlinc")
5455

56+
// START OF MODIFICATION: Print content of files to be compiled
57+
filePaths.forEach { osPath ->
58+
try {
59+
val actualFilePath = osPath.toNativeOsPath().stringPath()
60+
val content = File(actualFilePath).readText(Charsets.UTF_8) // Use actualFilePath
61+
println(" KOTLINC_INPUT_CODE_START ")
62+
println(content)
63+
println(" KOTLINC_INPUT_CODE_END ")
64+
} catch (e: Exception) {
65+
println(" KOTLINC_INPUT_CODE_ERROR Failed to read content of $osPath: ${e.message} ")
66+
}
67+
}
68+
// END OF MODIFICATION
69+
5570
return "$kotlinc $compilerOptsStr $classpath -d $jarFile $files"
5671
}
5772

src/main/kotlin/io/github/kscripting/kscript/util/ScriptUtils.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ object ScriptUtils {
4444
val sortedImports = importNames.sortedBy { it.value }.toList()
4545
val sb = StringBuilder()
4646

47-
if (packageName != null) {
48-
sb.append("package ${packageName.value}\n\n")
49-
}
47+
// Force our desired package
48+
sb.append("package kscript.scriplet;\n\n") // Added semicolon for robustness
5049

50+
// Add imports AFTER the package
5151
sortedImports.forEach {
5252
sb.append("import ${it.value}\n")
5353
}
5454

55+
// Then append the actual script code (which should NOT contain its own package declaration now)
5556
resolveSimpleCode(sb, scriptNode)
5657

5758
return sb.toString()

0 commit comments

Comments
 (0)