In some cases IC needs to perform a rebuild. Before this change IC was not clearing output directories besides destination dir for classes, so for example kapt stubs were not cleared. Stalled stubs might lead to compile errors. For example: 1. foo/XGen.java is generated from annotated class foo/X (XGen also references X). 2. foo/X is moved to bar/X and some other change forces IC to rebuild. 3. kapt generates bar/X stub, but foo/X stub was not removed because stubs dir is not cleared. 4. kapt runs annotation processors, foo/XGen.java is generated from foo/X stub, bar/XGen.java is generated from bar/X stub. 5. kotlinc rebuilds. Since destination dir is cleared properly, only bar/X.class exists. 6. javac tries to compile foo/XGen and fails, because it compiles against actual Kotlin classes, not stubs. This commit fixes the issue by passing all output directories of a task from Gradle to Kotlin IC. #KT-21735 fixed
Gradle Plugin Integration Tests
This module contains integration tests for libraries/tools/kotlin-gradle-plugin (and the subplugins mentioned there).
How to run
There are three Gradle tasks that run the tests:
-
Run all tests with the oldest possible Gradle version for each test:
./gradlew :kotlin-gradle-plugin-integration-tests:test -
Run with the new Gradle release, choose only the tests that support this Gradle version:
./gradlew :kotlin-gradle-plugin-integration-tests:testAdvanceGradleVersion -
Run the incremental compilation tests generated from the JPS ones
./gradlew :kotlin-gradle-plugin-integration-tests:testFromJps
The tests that use the Gradle plugins DSL (PluginsDslIT) also require the Gradle plugin marker artifacts to be installed:
./gradlew -Pdeploy_version=1.2-test :kotlin-gradle-plugin:plugin-marker:install :kotlin-noarg:plugin-marker:install :kotlin-allopen:plugin-marker:install
./gradlew -Pdeploy_version=1.2-test :kotlin-gradle-plugin-integration-tests:test
How to work with the tests
When you create a new test, figure out which Gradle versions it is supposed to run on. Then, when you instantiate a test project, specify one of:
project("someProjectName", GradleVersionRequired.None)or justproject("someProjectName")– the test can run on the whole range of the supported Gradle versions;project("someProjectName", GradleVersionRequired.AtLeast("X.Y"))– the test is supposed to run on Gradle versionX.Yand newer (e.g. it tests integration with a Gradle feature that was released in versionX.Y);project("someProjectName", GradleVersionRequired.Exact("X.Y"))– the test is supposed to run only with Gradle versionX.Y(e.g. it tests a workaround for that version or records some special behavior that is not reproducible with newer versions).
⚠️ When your tests target multiple Gradle versions, make sure they pass when run with both tasks test and testAdvanceGradleVersion (see above). In the IDE, you can modify a test run configuration to use a Gradle task other than test.
You can check a Gradle version that the test runs with using Project.testGradleVersionAtLeast("X.Y") and Project.testGradleVersionBelow("X.Y").
Since Gradle output layouts differ from version to version, you can access classes and resources output directories using the functions that adapt to the Gradle version that is used for each test:
-
CompiledProject.kotlinClassesDir()with optional arguments for subproject and source set, and its Java counterpartCompiledProject.javaClassesDir()(note that Gradle versions below 4.0 use the same directory for both) -
Project.resourcesDir()(with optional arguments for subproject and source set) for the resources directory; -
Project.classesDir(), which is a general way to get the output directory for a specific subproject, source set, and language.