Create source sets for generated by kapt sources during import
#KT-30739 Fixed
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import com.intellij.openapi.roots.DependencyScope
|
||||
import org.jetbrains.jps.model.java.JavaResourceRootType
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
|
||||
import org.junit.Test
|
||||
|
||||
class KaptImportingTest : MultiplePluginVersionGradleImportingTestCase() {
|
||||
|
||||
override fun isApplicableTest(): Boolean {
|
||||
return !gradleVersion.startsWith("3")
|
||||
}
|
||||
|
||||
fun importProject(modulePerSourceSet: Boolean) {
|
||||
currentExternalProjectSettings.isResolveModulePerSourceSet = modulePerSourceSet
|
||||
val isCreateEmptyContentRootDirectories = currentExternalProjectSettings.isCreateEmptyContentRootDirectories
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = true
|
||||
try {
|
||||
super.importProject()
|
||||
} finally {
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = isCreateEmptyContentRootDirectories
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testModulePerSourceSet() {
|
||||
configureByFiles()
|
||||
importProject(true)
|
||||
|
||||
checkProjectStructure(myProject, projectPath, true, true, true) {
|
||||
module("project")
|
||||
module("project_main") {
|
||||
sourceFolder("build/generated/source/kapt/main", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("build/generated/source/kaptKotlin/main", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/java", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/kotlin", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/resources", JavaResourceRootType.RESOURCE)
|
||||
libraryDependency("Gradle: kaptGeneratedClasses", DependencyScope.COMPILE)
|
||||
}
|
||||
module("project_test") {
|
||||
sourceFolder("build/generated/source/kapt/test", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("build/generated/source/kaptKotlin/test", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/java", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/kotlin", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/resources", JavaResourceRootType.TEST_RESOURCE)
|
||||
moduleDependency("project_main", DependencyScope.COMPILE)
|
||||
libraryDependency("Gradle: kaptGeneratedClasses", DependencyScope.COMPILE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testModulePerSourceSetDisabled() {
|
||||
configureByFiles()
|
||||
importProject(false)
|
||||
|
||||
checkProjectStructure(myProject, projectPath, true, true, true) {
|
||||
module("project") {
|
||||
sourceFolder("build/generated/source/kapt/main", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("build/generated/source/kaptKotlin/main", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/java", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/kotlin", JavaSourceRootType.SOURCE)
|
||||
sourceFolder("src/main/resources", JavaResourceRootType.RESOURCE)
|
||||
sourceFolder("build/generated/source/kapt/test", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("build/generated/source/kaptKotlin/test", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/java", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/kotlin", JavaSourceRootType.TEST_SOURCE)
|
||||
sourceFolder("src/test/resources", JavaResourceRootType.TEST_RESOURCE)
|
||||
libraryDependency("Gradle: kaptGeneratedClasses", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun testDataDirName(): String {
|
||||
return "kaptImportingTest"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
buildscript {
|
||||
apply from: "include.gradle"
|
||||
ext.kotlin_version = gradleKotlinPluginVersion('1.3.10')
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
buildscript {
|
||||
apply from: "include.gradle"
|
||||
ext.kotlin_version = gradleKotlinPluginVersion('1.3.10')
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
Reference in New Issue
Block a user