Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
Process the buildscript block of project script plugins
Browse files Browse the repository at this point in the history
See #180
  • Loading branch information
bamboo committed Apr 18, 2018
1 parent d866927 commit c3f4257
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun projectScriptTarget(
KotlinScriptTarget(
host = KotlinScriptHost(project, scriptSource, serviceRegistryOf(project), baseScope, scriptHandler),
scriptTemplate = KotlinBuildScript::class,
buildscriptBlockTemplate = KotlinBuildscriptBlock::class.takeIf { topLevelScript },
buildscriptBlockTemplate = KotlinBuildscriptBlock::class,
pluginsBlockTemplate = KotlinPluginsBlock::class.takeIf { topLevelScript },
accessorsClassPath = accessorsClassPathProviderFor(project, topLevelScript),
onPrepare = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ class GradleKotlinDslIntegrationTest : AbstractIntegrationTest() {
build("compute").output.contains("*42*"))
}

@Test
fun `given a script plugin with a buildscript block, it will be used to compute its classpath`() {

withClassJar("fixture.jar", DeepThought::class.java)

withFile("other.gradle.kts", """
buildscript {
dependencies { classpath(files("fixture.jar")) }
}
task("compute") {
doLast {
val computer = ${DeepThought::class.qualifiedName}()
val answer = computer.compute()
println("*" + answer + "*")
}
}
""")

withBuildScript("""
apply(from = "other.gradle.kts")
""")

assert(
build("compute").output.contains("*42*"))
}

@Test
fun `given a buildSrc dir, it will be added to the compilation classpath`() {

Expand Down

0 comments on commit c3f4257

Please sign in to comment.