Skip to content

Commit 345fd4f

Browse files
committed
Switch to Kotlin 1.4.0
1 parent eb83a6f commit 345fd4f

File tree

15 files changed

+111
-73
lines changed

15 files changed

+111
-73
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
plugins {
3-
kotlin("jvm") version "1.3.70"
3+
kotlin("jvm") version "1.4.0"
44
}
55

6-
val kotlinVersion: String by extra("1.3.70")
6+
val kotlinVersion: String by extra("1.4.0")
77

88
allprojects {
99
repositories {

jvm/basic/jvm-embeddable-host/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
implementation(project(":jvm:basic:jvm-simple-script:script"))
1010
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
1111
compileOnly("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
12-
testRuntimeOnly("org.jetbrains.kotlin:kotlin-scripting-jvm-host-embeddable:$kotlinVersion")
12+
testRuntimeOnly("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
1313
testRuntimeOnly("com.google.guava:guava:28.2-jre")
1414
testImplementation("junit:junit:4.12")
1515
}

jvm/basic/jvm-maven-deps/host/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ val kotlinVersion: String by rootProject.extra
77

88
dependencies {
99
implementation(project(":jvm:basic:jvm-maven-deps:script"))
10+
implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
11+
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
1012
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
1113
testImplementation("junit:junit:4.12")
1214
testRuntimeOnly("org.slf4j:slf4j-nop:1.7.28")

jvm/basic/jvm-maven-deps/host/src/test/kotlin/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/test/resolveTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class ResolveTest {
3939
val res = evalFile(File("testData/hello-maven-resolve-error.scriptwithdeps.kts"))
4040

4141
Assert.assertTrue(
42-
"test failed - expecting a failure with the message \"Unknown set of arguments to maven resolver: abracadabra\" but received " +
43-
(if (res is ResultWithDiagnostics.Failure) "failure" else "success") +
44-
":\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}",
45-
res is ResultWithDiagnostics.Failure && res.reports.any { it.message.contains("Unknown set of arguments to maven resolver: abracadabra") })
42+
"test failed - expecting a failure with the message \"File 'abracadabra' not found\" but received " +
43+
(if (res is ResultWithDiagnostics.Failure) "failure" else "success") +
44+
":\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}",
45+
res is ResultWithDiagnostics.Failure && res.reports.any { it.message.contains("File 'abracadabra' not found") })
4646
}
4747
}

jvm/basic/jvm-maven-deps/script/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ plugins {
66
val kotlinVersion: String by rootProject.extra
77

88
dependencies {
9+
implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
910
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
10-
implementation("org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion")
11-
runtimeOnly("com.jcabi:jcabi-aether:0.10.1")
12-
runtimeOnly("org.sonatype.aether:aether-api:1.13.1")
13-
runtimeOnly("org.apache.maven:maven-core:3.0.3")
11+
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:$kotlinVersion")
12+
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven:$kotlinVersion")
1413
}

jvm/basic/jvm-maven-deps/script/src/main/kotlin/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55

66
package org.jetbrains.kotlin.script.examples.jvm.resolve.maven
77

8-
import org.jetbrains.kotlin.script.util.DependsOn
9-
import org.jetbrains.kotlin.script.util.FilesAndMavenResolver
10-
import org.jetbrains.kotlin.script.util.Repository
11-
import java.io.File
12-
import kotlin.script.dependencies.ScriptContents
13-
import kotlin.script.dependencies.ScriptDependenciesResolver
8+
import kotlinx.coroutines.runBlocking
149
import kotlin.script.experimental.annotations.KotlinScript
1510
import kotlin.script.experimental.api.*
16-
import kotlin.script.experimental.jvm.compat.mapLegacyDiagnosticSeverity
17-
import kotlin.script.experimental.jvm.compat.mapLegacyScriptPosition
11+
import kotlin.script.experimental.dependencies.*
12+
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver
13+
import kotlin.script.experimental.jvm.JvmDependency
1814
import kotlin.script.experimental.jvm.dependenciesFromCurrentContext
1915
import kotlin.script.experimental.jvm.jvm
20-
import kotlin.script.experimental.jvm.withUpdatedClasspath
2116

2217
@KotlinScript(
2318
fileExtension = "scriptwithdeps.kts",
@@ -31,7 +26,7 @@ object ScriptWithMavenDepsConfiguration : ScriptCompilationConfiguration(
3126
jvm {
3227
dependenciesFromCurrentContext(
3328
"script", // script library jar name
34-
"kotlin-script-util" // DependsOn annotation is taken from script-util
29+
"kotlin-scripting-dependencies" // DependsOn annotation is taken from this jar
3530
)
3631
}
3732
refineConfiguration {
@@ -40,35 +35,18 @@ object ScriptWithMavenDepsConfiguration : ScriptCompilationConfiguration(
4035
}
4136
)
4237

43-
private val resolver = FilesAndMavenResolver()
38+
private val resolver = CompoundDependenciesResolver(FileSystemDependenciesResolver(), MavenDependenciesResolver())
4439

4540
fun configureMavenDepsOnAnnotations(context: ScriptConfigurationRefinementContext): ResultWithDiagnostics<ScriptCompilationConfiguration> {
46-
val annotations = context.collectedData?.get(ScriptCollectedData.foundAnnotations)?.takeIf { it.isNotEmpty() }
47-
?: return context.compilationConfiguration.asSuccess()
48-
val scriptContents = object : ScriptContents {
49-
override val annotations: Iterable<Annotation> = annotations
50-
override val file: File? = null
51-
override val text: CharSequence? = null
52-
}
53-
val diagnostics = arrayListOf<ScriptDiagnostic>()
54-
fun report(severity: ScriptDependenciesResolver.ReportSeverity, message: String, position: ScriptContents.Position?) {
55-
diagnostics.add(
56-
ScriptDiagnostic(
57-
message,
58-
mapLegacyDiagnosticSeverity(severity),
59-
context.script.locationId,
60-
mapLegacyScriptPosition(position)
61-
)
62-
)
63-
}
64-
return try {
65-
val newDepsFromResolver = resolver.resolve(scriptContents, emptyMap(), ::report, null).get()
66-
?: return context.compilationConfiguration.asSuccess(diagnostics)
67-
val resolvedClasspath = newDepsFromResolver.classpath.toList().takeIf { it.isNotEmpty() }
68-
?: return context.compilationConfiguration.asSuccess(diagnostics)
69-
context.compilationConfiguration.withUpdatedClasspath(resolvedClasspath).asSuccess(diagnostics)
70-
} catch (e: Throwable) {
71-
ResultWithDiagnostics.Failure(*diagnostics.toTypedArray(), e.asDiagnostics(path = context.script.locationId))
41+
val annotations = context.collectedData?.get(ScriptCollectedData.collectedAnnotations)?.takeIf { it.isNotEmpty() }
42+
?: return context.compilationConfiguration.asSuccess()
43+
return runBlocking {
44+
resolver.resolveFromScriptSourceAnnotations(annotations)
45+
}.onSuccess {
46+
context.compilationConfiguration.with {
47+
dependencies.append(JvmDependency(it))
48+
}.asSuccess()
7249
}
7350
}
7451

52+

jvm/basic/jvm-simple-script/host/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ val kotlinVersion: String by rootProject.extra
77

88
dependencies {
99
implementation(project(":jvm:basic:jvm-simple-script:script"))
10+
implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
11+
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
1012
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
1113
testImplementation("junit:junit:4.12")
1214
}

jvm/simple-main-kts/simple-main-kts-test/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ val kotlinVersion: String by rootProject.extra
77

88
dependencies {
99
testImplementation(project(":jvm:simple-main-kts:simple-main-kts"))
10+
testImplementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
11+
testImplementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
1012
testImplementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
1113
testImplementation("junit:junit:4.12")
1214
}

jvm/simple-main-kts/simple-main-kts-test/src/test/kotlin/org/jetbrains/kotlin/script/examples/simpleMainKts/test/SimpleMainKtsTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package org.jetbrains.kotlin.script.examples.simpleMainKts.test
66

77
import org.jetbrains.kotlin.script.examples.simpleMainKts.COMPILED_SCRIPTS_CACHE_DIR_PROPERTY
8+
import org.jetbrains.kotlin.script.examples.simpleMainKts.MainKtsEvaluationConfiguration
89
import org.jetbrains.kotlin.script.examples.simpleMainKts.SimpleMainKtsScript
910
import org.junit.Assert
1011
import org.junit.Test
@@ -21,7 +22,7 @@ fun evalFile(scriptFile: File, cacheDir: File? = null): ResultWithDiagnostics<Ev
2122
withMainKtsCacheDir(cacheDir?.absolutePath ?: "") {
2223
val scriptDefinition = createJvmCompilationConfigurationFromTemplate<SimpleMainKtsScript>()
2324

24-
val evaluationEnv = ScriptEvaluationConfiguration {
25+
val evaluationEnv = MainKtsEvaluationConfiguration.with {
2526
jvm {
2627
baseClassLoader(null)
2728
}

jvm/simple-main-kts/simple-main-kts-test/testData/compile-java6.smain.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ TestImpl().run {
1616
printSuper()
1717
printRandom()
1818
}
19+
20+
val x = length // drop(4)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy