Kotlin Gradle scripts. Part 2 of 2#534
Conversation
Codecov Report
@@ Coverage Diff @@
## master #534 +/- ##
=========================================
Coverage 73.71% 73.71%
Complexity 2936 2936
=========================================
Files 503 503
Lines 11904 11904
Branches 670 670
=========================================
Hits 8775 8775
Misses 2905 2905
Partials 224 224 |
|
@armiol, PTAL. |
armiol
left a comment
There was a problem hiding this comment.
@dmdashenkov please see my comments and suggestions.
| testAnnotationProcessor deps.build.autoService.processor | ||
| testCompileOnly deps.build.autoService.annotations | ||
| plugins { | ||
| kotlin("jvm").version("1.3.72") |
There was a problem hiding this comment.
Please consider commenting on the string literal here (e.g. https://kotlinlang.org/docs/reference/using-gradle.html#targeting-the-jvm).
| @@ -0,0 +1,32 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
I would rename this file to sameDirectory.sh.
There was a problem hiding this comment.
Can we have it same-dir.sh, please? To avoid the case issues under different OS.
|
|
||
| /** | ||
| * Creates {@link #FILE_NAME} file in the root of the test project, copying it from resources. | ||
| * Creates {@link #BUILD_GRADLE build.gradle} or {@link #BUILD_GRADLE_KTS build.gradle.kts} file in |
There was a problem hiding this comment.
Please also say in which case either of these two is supposed to be created/copied.
There was a problem hiding this comment.
Added a paragraph on the priority order of build.gradle and build.gradle.kts.
| testEnvGradle.createFile(); | ||
| } | ||
|
|
||
| private void whiteBuildSrc() throws IOException { |
tools/smoke-tests/README.md
Outdated
|
|
||
| Some Gradle build files in this project rely on `modelCompiler` heavily. We cannot get a type-safe | ||
| accessor for the extension. In those build files we use Groovy instead of Kotlin. At alternative | ||
| would be using Kotlin and `withGroovyBuilder(..)`. |
There was a problem hiding this comment.
Not sure if this is still the case. I am not able to locate any withGroovyBuilder(..) usages.
| modelCompiler { | ||
|
|
||
| interfaces { | ||
| mark(messages().inFiles(mapOf("suffix" to "documents.proto")), asType("io.spine.tools.protoc.DocumentMessage")) |
There was a problem hiding this comment.
Previously it was a much clearer code piece:
mark messages().inFiles(suffix: 'documents.proto'), asType('io.spine.tools.protoc.DocumentMessage')Maybe we could wrap mapOf("suffix" to "documents.proto") with some method to avoid those repeated literals and mapOfs? E.g.
mark(messages().inFiles(withSuffix("documents.proto"))), asType("io.spine.tools.protoc.DocumentMessage"))|
@armiol, PTAL again. |
This PR finalizes the transition to Kotlin Gradle scripts for the
baserepository. Here we translatesmoke-testsandbase-validating-buildersinto Kotlin.Custom
pullscriptsKotlin is a strictly-typed language which does not allow unresolved references at compile time. One of the ways to add classes into a Kotlin build script compile classpath is declaring those classes in the
buildSrcproject.The
buildSrcproject is a conventionally-named Gradle plugin, which applied to all the projects in the hierarchy implicitly. We use this feature for extracting common dependencies and configuration routines viadeps.kt. The wholebuildSrcproject is copied from theconfigGit submodule into the root project dir, where it is found by Gradle by convention.However, the
smoke-testsandbase-validating-builders, being separate builds, do not receive thebuildSrcfrom our main build. Furthermore, it is impossible to configure thebuildSrclocation.In order for the separate builds to receive
buildSrcin their script compile classpath, we copy thebuildSrcdirectory into the root project directories of those builds:./tools/smoke-testsand./base-validating-builders. To automate this, we introduce custom scripts:./pulland.\pull.bat. Those scrips do whatever theirconfigcounterparts do and also copy thebuildSrcdir from the root project into the included builds.Those scripts now should be used instead of
./config/pulland.\config\pull.bat.Fixes in the test lib
In the
plugin-testlibwe've got tools for creating temporary Gradle projects to test our plugins on. For that, some of the project's own files were copied into a temporary directory. To find those files, we need to find the root project. That is done by looking for aversion.gradlefile. However, while renaming that file toversion.gradle.kts, we did not leave a room for using old name and so if a project using aversion.gradleused that tool, an obscure exception would pop up.In this PR we allow projects to use either
version.gradleorversion.gradle.kts.