-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specifically... - gradlew vs gradlew.bat - Psi parsing confused by \r - Gradle daemon using a different working directory than *nix (so we have to be explicit about the roots that we use) Fixes #46
- Loading branch information
1 parent
223ba88
commit a299672
Showing
13 changed files
with
71 additions
and
48 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
cli/kobweb/src/main/kotlin/com/varabyte/kobweb/cli/common/OsUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.varabyte.kobweb.cli.common | ||
|
||
object Os { | ||
fun isWindows() = System.getProperty("os.name").lowercase().contains("windows") | ||
} |
10 changes: 10 additions & 0 deletions
10
cli/kobweb/src/main/kotlin/com/varabyte/kobweb/cli/common/RuntimeUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.varabyte.kobweb.cli.common | ||
|
||
fun Runtime.gradlew(vararg args: String): Process { | ||
val finalArgs = mutableListOf( | ||
if (!Os.isWindows()) "./gradlew" else "./gradlew.bat" | ||
) | ||
|
||
finalArgs.addAll(args) | ||
return exec(finalArgs.toTypedArray()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...plication/src/main/kotlin/com/varabyte/kobweb/gradle/application/project/KotlinProject.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...le/application/src/main/kotlin/com/varabyte/kobweb/gradle/application/project/PsiUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.varabyte.kobweb.gradle.application.project | ||
|
||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles | ||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment | ||
import org.jetbrains.kotlin.com.intellij.openapi.project.Project | ||
import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer | ||
import org.jetbrains.kotlin.com.intellij.psi.PsiManager | ||
import org.jetbrains.kotlin.com.intellij.testFramework.LightVirtualFile | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
import org.jetbrains.kotlin.idea.KotlinFileType | ||
import org.jetbrains.kotlin.psi.KtFile | ||
import java.io.File | ||
|
||
object PsiUtils { | ||
// For now, we're directly parsing Kotlin code using the embedded Kotlin compiler. This is a temporary approach. | ||
// In the future, this should use KSP to navigate through source files. See also: Bug #4 | ||
fun createKotlinProject(): Project { | ||
return KotlinCoreEnvironment.createForProduction( | ||
Disposer.newDisposable(), | ||
CompilerConfiguration(), | ||
EnvironmentConfigFiles.JS_CONFIG_FILES | ||
).project | ||
} | ||
} | ||
|
||
fun Project.parseKotlinFile(file: File): KtFile { | ||
return PsiManager.getInstance(this) | ||
.findFile( | ||
LightVirtualFile( | ||
file.name, | ||
KotlinFileType.INSTANCE, | ||
// Standardize newlines or else PSI parsing gets confused (e.g. by \r on Windows) | ||
file.readText().replace(System.lineSeparator(), "\n"), | ||
) | ||
) as KtFile | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...le/application/src/main/kotlin/com/varabyte/kobweb/gradle/application/tasks/KobwebTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters