diff --git a/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt b/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt index c4b6487fe10..e0639dc98e2 100644 --- a/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt +++ b/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsTest.kt @@ -47,6 +47,18 @@ class MainKtsTest { assertSucceeded(res) } + @Test + fun testResolveHamcrestViaJunit() { + val resOk = evalFile(File("$TEST_DATA_ROOT/resolve-hamcrest-via-junit.main.kts")) + assertSucceeded(resOk) + + val resErr = evalFile(File("$TEST_DATA_ROOT/resolve-error-hamcrest-via-junit.main.kts")) + Assert.assertTrue( + resErr is ResultWithDiagnostics.Failure && + resErr.reports.any { it.message == "Unresolved reference: hamcrest" } + ) + } + // @Test // this test is disabled: the resolving works fine, but ivy resolver is not processing "pom"-type dependencies correctly ( // as far as I can tell) diff --git a/libraries/tools/kotlin-main-kts-test/testData/resolve-error-hamcrest-via-junit.main.kts b/libraries/tools/kotlin-main-kts-test/testData/resolve-error-hamcrest-via-junit.main.kts new file mode 100644 index 00000000000..0c491de0a59 --- /dev/null +++ b/libraries/tools/kotlin-main-kts-test/testData/resolve-error-hamcrest-via-junit.main.kts @@ -0,0 +1,7 @@ + +@file:DependsOn("junit:junit:4.11", options = ["transitive=false"]) + +org.hamcrest.Description.NullDescription() + +println("Hello, World!") + diff --git a/libraries/tools/kotlin-main-kts-test/testData/resolve-hamcrest-via-junit.main.kts b/libraries/tools/kotlin-main-kts-test/testData/resolve-hamcrest-via-junit.main.kts new file mode 100644 index 00000000000..c6af239f7f9 --- /dev/null +++ b/libraries/tools/kotlin-main-kts-test/testData/resolve-hamcrest-via-junit.main.kts @@ -0,0 +1,7 @@ + +@file:DependsOn("junit:junit:4.11") + +org.hamcrest.Description.NullDescription() + +println("Hello, World!") + diff --git a/libraries/tools/kotlin-main-kts/src/org/jetbrains/kotlin/mainKts/impl/ivy.kt b/libraries/tools/kotlin-main-kts/src/org/jetbrains/kotlin/mainKts/impl/ivy.kt index ecf5d0e3d4d..55561588b4f 100644 --- a/libraries/tools/kotlin-main-kts/src/org/jetbrains/kotlin/mainKts/impl/ivy.kt +++ b/libraries/tools/kotlin-main-kts/src/org/jetbrains/kotlin/mainKts/impl/ivy.kt @@ -51,6 +51,7 @@ class IvyResolver : ExternalDependenciesResolver { artifactId[0], artifactId[1], artifactId[2], if (artifactId.size > 3) artifactId[3] else null, if (artifactType.isNotEmpty()) artifactType else null, + options, sourceCodeLocation ) } catch (e: Exception) { @@ -69,6 +70,7 @@ class IvyResolver : ExternalDependenciesResolver { revision: String, conf: String? = null, type: String? = null, + options: ExternalDependenciesResolver.Options, sourceCodeLocation: SourceCode.LocationWithId? = null ): ResultWithDiagnostics> { @@ -112,10 +114,15 @@ class IvyResolver : ExternalDependenciesResolver { depsDescriptor.addDependencyConfiguration("default", "master,compile") moduleDescriptor.addDependency(depsDescriptor) + val isTransitive = options.flag("transitive") != false + val resolveOptions = ResolveOptions().apply { confs = arrayOf("default") log = LogOptions.LOG_QUIET isOutputReport = false + if (!isTransitive) { + this.isTransitive = false + } } //init resolve report