diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt index ca5875ea8a0..0565553d8a5 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt @@ -1,7 +1,10 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel +import org.gradle.tooling.GradleConnector import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.model.ModelContainer +import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction import org.jetbrains.kotlin.gradle.util.* import org.junit.After import org.junit.AfterClass @@ -274,6 +277,18 @@ abstract class BaseGradleIT { } } + fun Project.getModels(modelType: Class): ModelContainer { + if (!projectDir.exists()) { + setupWorkingDir() + } + + val connection = GradleConnector.newConnector().forProjectDirectory(projectDir).connect() + val options = defaultBuildOptions() + val model = connection.action(ModelFetcherBuildAction(modelType)) .withArguments("-Pkotlin_version=" + options.kotlinVersion).run() + connection.close() + return model + } + fun CompiledProject.assertSuccessful() { if (resultCode == 0) return diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/KotlinProjectIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/KotlinProjectIT.kt new file mode 100644 index 00000000000..7f595a83b55 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/KotlinProjectIT.kt @@ -0,0 +1,154 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model + +import org.jetbrains.kotlin.gradle.BaseGradleIT +import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class KotlinProjectIT : BaseGradleIT() { + + @Test + fun testKotlinProject() { + val project = Project("kotlinProject") + val kotlinProject = project.getModels(KotlinProject::class.java).getModel(":")!! + + kotlinProject.assertBasics("kotlinProject", defaultBuildOptions().kotlinVersion, KotlinProject.ProjectType.PLATFORM_JVM, "WARN") + assertTrue(kotlinProject.expectedByDependencies.isEmpty()) + + assertEquals(2, kotlinProject.sourceSets.size) + val mainSourceSet = kotlinProject.sourceSets.find { it.name == "main" }!! + val testSourceSet = kotlinProject.sourceSets.find { it.name == "test" }!! + + mainSourceSet.assertBasics("main", SourceSet.SourceSetType.PRODUCTION, emptySet()) + testSourceSet.assertBasics("test", SourceSet.SourceSetType.TEST, listOf("main")) + + assertEquals(2, mainSourceSet.sourceDirectories.size) + assertEquals(1, mainSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/main/kotlin") }.size) + assertEquals(1, mainSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/main/java") }.size) + assertEquals(1, mainSourceSet.resourcesDirectories.size) + assertEquals(1, mainSourceSet.resourcesDirectories.filter { it.absolutePath.contains("src/main/resources") }.size) + assertTrue(mainSourceSet.classesOutputDirectory.absolutePath.contains("build/classes/kotlin/main")) + assertTrue(mainSourceSet.resourcesOutputDirectory.absolutePath.contains("build/resources/main")) + assertTrue(mainSourceSet.compilerArguments.compileClasspath.any { it.absolutePath.contains("guava") }) + assertFalse(mainSourceSet.compilerArguments.compileClasspath.any { it.absolutePath.contains("testng") }) + + assertEquals(2, testSourceSet.sourceDirectories.size) + assertEquals(1, testSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/test/kotlin") }.size) + assertEquals(1, testSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/test/java") }.size) + assertEquals(1, testSourceSet.resourcesDirectories.size) + assertEquals(1, testSourceSet.resourcesDirectories.filter { it.absolutePath.contains("src/test/resources") }.size) + assertTrue(testSourceSet.classesOutputDirectory.absolutePath.contains("build/classes/kotlin/test")) + assertTrue(testSourceSet.resourcesOutputDirectory.absolutePath.contains("build/resources/test")) + assertTrue(testSourceSet.compilerArguments.compileClasspath.any { it.absolutePath.contains("guava") }) + assertTrue(testSourceSet.compilerArguments.compileClasspath.any { it.absolutePath.contains("testng") }) + } + + @Test + fun testKotlinJavaProject() { + val project = Project("kotlinJavaProject") + val kotlinProject = project.getModels(KotlinProject::class.java).getModel(":")!! + + kotlinProject.assertBasics( + "kotlinJavaProject", + defaultBuildOptions().kotlinVersion, + KotlinProject.ProjectType.PLATFORM_JVM, + "WARN" + ) + + assertEquals(3, kotlinProject.sourceSets.size) + val mainSourceSet = kotlinProject.sourceSets.find { it.name == "main" }!! + val deploySourceSet = kotlinProject.sourceSets.find { it.name == "deploy" }!! + val testSourceSet = kotlinProject.sourceSets.find { it.name == "test" }!! + + mainSourceSet.assertBasics("main", SourceSet.SourceSetType.PRODUCTION, emptySet()) + deploySourceSet.assertBasics("deploy", SourceSet.SourceSetType.PRODUCTION, emptySet()) + testSourceSet.assertBasics("test", SourceSet.SourceSetType.TEST, listOf("main")) + } + + @Test + fun testMultiplatformProject() { + val project = Project("multiplatformProject") + val models = project.getModels(KotlinProject::class.java) + + val libKotlinProject = models.getModel(":lib")!! + val libJsKotlinProject = models.getModel(":libJs")!! + val libJvmKotlinProject = models.getModel(":libJvm")!! + + libKotlinProject.assertBasics("lib", defaultBuildOptions().kotlinVersion, KotlinProject.ProjectType.PLATFORM_COMMON, "WARN") + libJsKotlinProject.assertBasics("libJs", defaultBuildOptions().kotlinVersion, KotlinProject.ProjectType.PLATFORM_JS, "WARN") + libJvmKotlinProject.assertBasics("libJvm", defaultBuildOptions().kotlinVersion, KotlinProject.ProjectType.PLATFORM_JVM, "WARN") + + assertEquals(1, libJsKotlinProject.expectedByDependencies.size) + assertTrue(libJsKotlinProject.expectedByDependencies.contains(":lib")) + + assertEquals(1, libJvmKotlinProject.expectedByDependencies.size) + assertTrue(libJvmKotlinProject.expectedByDependencies.contains(":lib")) + + + assertEquals(2, libJsKotlinProject.sourceSets.size) + val mainJsSourceSet = libJsKotlinProject.sourceSets.find { it.name == "main" }!! + val testJsSourceSet = libJsKotlinProject.sourceSets.find { it.name == "test" }!! + + mainJsSourceSet.assertBasics("main", SourceSet.SourceSetType.PRODUCTION, emptySet()) + testJsSourceSet.assertBasics("test", SourceSet.SourceSetType.TEST, listOf("main")) + + assertEquals(1, mainJsSourceSet.sourceDirectories.size) + assertEquals(1, mainJsSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/main/kotlin") }.size) + assertEquals(1, mainJsSourceSet.resourcesDirectories.size) + assertEquals(1, mainJsSourceSet.resourcesDirectories.filter { it.absolutePath.contains("src/main/resources") }.size) + assertTrue(mainJsSourceSet.classesOutputDirectory.absolutePath.contains("build/classes/kotlin/main")) + assertTrue(mainJsSourceSet.resourcesOutputDirectory.absolutePath.contains("build/resources/main")) + + assertEquals(1, testJsSourceSet.sourceDirectories.size) + assertEquals(1, testJsSourceSet.sourceDirectories.filter { it.absolutePath.contains("src/test/kotlin") }.size) + assertEquals(1, testJsSourceSet.resourcesDirectories.size) + assertEquals(1, testJsSourceSet.resourcesDirectories.filter { it.absolutePath.contains("src/test/resources") }.size) + assertTrue(testJsSourceSet.classesOutputDirectory.absolutePath.contains("build/classes/kotlin/test")) + assertTrue(testJsSourceSet.resourcesOutputDirectory.absolutePath.contains("build/resources/test")) + } + + @Test + fun testCoroutinesProjectDSL() { + val project = Project("coroutinesProjectDSL") + val kotlinProject = project.getModels(KotlinProject::class.java).getModel(":")!! + + kotlinProject.assertBasics( + "coroutinesProjectDSL", + defaultBuildOptions().kotlinVersion, + KotlinProject.ProjectType.PLATFORM_JVM, + "ENABLE" + ) + } + + companion object { + + private fun KotlinProject.assertBasics( + expectedName: String, + expectedKotlinVersion: String, + expectedProjectType: KotlinProject.ProjectType, + expectedCoroutines: String + ) { + assertEquals(1L, modelVersion) + assertEquals(expectedName, name) + assertEquals(expectedKotlinVersion, kotlinVersion) + assertEquals(expectedProjectType, projectType) + assertEquals(expectedCoroutines, experimentalFeatures.coroutines) + } + + private fun SourceSet.assertBasics( + expectedName: String, + expectedType: SourceSet.SourceSetType, + expectedFriendSourceSets: Collection + ) { + assertEquals(expectedName, name) + assertEquals(expectedType, type) + assertEquals(expectedFriendSourceSets.toList(), friendSourceSets.toList()) + } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelContainer.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelContainer.kt new file mode 100644 index 00000000000..21e18f4747f --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelContainer.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model + +import java.io.Serializable + +/** + * Wraps models of a given type for all different projects inside a Gradle multi project. + */ +class ModelContainer : Serializable { + // Key is the project path + private val modelContainer = HashMap() + + fun addModel(path: String, model: T) { + modelContainer[path] = model + } + + fun getModel(path: String): T? { + return modelContainer[path] + } + + fun hasModel(path: String): Boolean { + return modelContainer[path] != null + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelFetcherBuildAction.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelFetcherBuildAction.kt new file mode 100644 index 00000000000..23cff59ed70 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/model/ModelFetcherBuildAction.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model + +import org.gradle.tooling.BuildAction +import org.gradle.tooling.BuildController +import org.gradle.tooling.model.gradle.BasicGradleProject +import java.io.Serializable + +class ModelFetcherBuildAction(private val modelType: Class) : BuildAction>, Serializable { + + override fun execute(controller: BuildController): ModelContainer { + val modelContainer = ModelContainer() + modelContainer.populateModels(controller, controller.buildModel.rootProject) + return modelContainer + } + + private fun ModelContainer.populateModels(controller: BuildController, gradleProject: BasicGradleProject) { + val model = controller.findModel(gradleProject, modelType) + if (model != null && !hasModel(gradleProject.path)) { + addModel(gradleProject.path, model) + } + gradleProject.children.forEach { populateModels(controller, it) } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-model/build.gradle b/libraries/tools/kotlin-gradle-plugin-model/build.gradle new file mode 100644 index 00000000000..146ec471a88 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-model/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'kotlin' + +configureJvmProject(project) +configurePublishing(project) + +repositories { + mavenLocal() +} + +dependencies { + compile "org.jetbrains:annotations:13.0" +} + +artifacts { + archives sourcesJar + archives javadocJar +} + +jar { + manifestAttributes(manifest, project) +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/CompilerArguments.java b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/CompilerArguments.java new file mode 100644 index 00000000000..c5108e66cb6 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/CompilerArguments.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.List; + +/** + * Represents the compiler arguments for a given Kotlin source set. + * @see SourceSet + */ +public interface CompilerArguments { + + /** + * Return current arguments for the given source set. + * + * @return current arguments for the given source set. + */ + @NotNull + List getCurrentArguments(); + + /** + * Return default arguments for the given source set. + * + * @return default arguments for the given source set. + */ + @NotNull + List getDefaultArguments(); + + /** + * Return the classpath the given source set is compiled against. + * + * @return the classpath the given source set is compiled against. + */ + @NotNull + List getCompileClasspath(); +} diff --git a/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/ExperimentalFeatures.java b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/ExperimentalFeatures.java new file mode 100644 index 00000000000..85d023f88b2 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/ExperimentalFeatures.java @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model; + +import org.jetbrains.annotations.Nullable; + +/** + * Wraps all experimental features information for a given Kotlin project. + * @see KotlinProject + */ +public interface ExperimentalFeatures { + + /** + * Return coroutines string. + * + * @return coroutines. + */ + @Nullable + String getCoroutines(); +} diff --git a/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/KotlinProject.java b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/KotlinProject.java new file mode 100644 index 00000000000..b94c630b071 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/KotlinProject.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model; + +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; + +/** + * Entry point for the model of Kotlin Projects. + * Plugins 'kotlin', 'kotlin-platform-jvm', 'kotlin2js', 'kotlin-platform-js' and 'kotlin-platform-common' can produce this model. + */ +public interface KotlinProject { + + /** + * Possible Kotlin project types. + */ + enum ProjectType { + + /** Indicator of platform plugin id 'kotlin-platform-jvm' or 'kotlin'. */ + PLATFORM_JVM, + + /** Indicator of platform plugin id 'kotlin-platform-js' or 'kotlin2js'. */ + PLATFORM_JS, + + /** Indicator of platform plugin id 'kotlin-platform-common'. */ + PLATFORM_COMMON + } + + /** + * Return a number representing the version of this API. + * Always increasing if changed. + * + * @return the version of this model. + */ + long getModelVersion(); + + /** + * Returns the module (Gradle project) name. + * + * @return the module name. + */ + @NotNull + String getName(); + + /** + * Return the Kotlin version. + * + * @return the Kotlin version. + */ + @NotNull + String getKotlinVersion(); + + /** + * Return the type of the platform plugin applied. + * + * @return the type of the platform plugin applied. Possible values are defined in the enum. + */ + @NotNull + ProjectType getProjectType(); + + /** + * Return all source sets used by Kotlin. + * + * @return all source sets. + */ + @NotNull + Collection getSourceSets(); + + /** + * Return all modules (Gradle projects) registered as 'expectedBy' dependency. + * + * @return expectedBy dependencies. + */ + @NotNull + Collection getExpectedByDependencies(); + + /** + * Return an object containing a descriptor of the experimental features. + * + * @return experimental features. + */ + @NotNull + ExperimentalFeatures getExperimentalFeatures(); +} diff --git a/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/SourceSet.java b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/SourceSet.java new file mode 100644 index 00000000000..a8f3ae15fd7 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-model/src/main/java/org/jetbrains/kotlin/gradle/model/SourceSet.java @@ -0,0 +1,90 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.Collection; + +/** + * Represents a source set for a given Kotlin Gradle project. + * @see KotlinProject + */ +public interface SourceSet { + + /** + * Possible source set types. + */ + enum SourceSetType { + PRODUCTION, + TEST + } + + /** + * Return the source set name. + * + * @return the source set name. + */ + @NotNull + String getName(); + + /** + * Return the type of the source set. + * + * @return the type of the source set. + */ + @NotNull + SourceSetType getType(); + + /** + * Return the names of all friend source sets. + * + * @return friend source sets. + */ + @NotNull + Collection getFriendSourceSets(); + + /** + * Return all Kotlin sources directories. + * + * @return all Kotlin sources directories. + */ + @NotNull + Collection getSourceDirectories(); + + /** + * Return all Kotlin resources directories. + * + * @return all Kotlin resources directories. + */ + @NotNull + Collection getResourcesDirectories(); + + /** + * Return the classes output directory. + * + * @return the classes output directory. + */ + @NotNull + File getClassesOutputDirectory(); + + /** + * Return the resources output directory. + * + * @return the resources output directory. + */ + @NotNull + File getResourcesOutputDirectory(); + + /** + * Return an object containing all compiler arguments for this source set. + * + * @return compiler arguments for this source set. + */ + @NotNull + CompilerArguments getCompilerArguments(); +} diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle b/libraries/tools/kotlin-gradle-plugin/build.gradle index f6ff5131274..fe900af5c8e 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle @@ -32,6 +32,7 @@ pill { dependencies { compile project(':kotlin-gradle-plugin-api') + compile project(':kotlin-gradle-plugin-model') compileOnly project(':compiler') compileOnly project(':compiler:incremental-compilation-impl') compileOnly project(':compiler:daemon-common') @@ -77,6 +78,7 @@ dependencies { testCompile project(':kotlin-compiler-runner') testCompile project(':kotlin-test::kotlin-test-junit') testCompile "junit:junit:4.12" + testCompile "nl.jqno.equalsverifier:equalsverifier:2.1.5" testCompileOnly project(':kotlin-reflect-api') testCompileOnly project(':kotlin-annotation-processing') testCompileOnly project(':kotlin-annotation-processing-gradle') diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt new file mode 100644 index 00000000000..9d0c6c84979 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt @@ -0,0 +1,112 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.builder + +import org.gradle.api.Project +import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.ProjectDependency +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.tooling.provider.model.ToolingModelBuilder +import org.jetbrains.kotlin.gradle.model.CompilerArguments +import org.jetbrains.kotlin.gradle.model.ExperimentalFeatures +import org.jetbrains.kotlin.gradle.model.KotlinProject +import org.jetbrains.kotlin.gradle.model.SourceSet +import org.jetbrains.kotlin.gradle.model.impl.CompilerArgumentsImpl +import org.jetbrains.kotlin.gradle.model.impl.ExperimentalFeaturesImpl +import org.jetbrains.kotlin.gradle.model.impl.KotlinProjectImpl +import org.jetbrains.kotlin.gradle.model.impl.SourceSetImpl +import org.jetbrains.kotlin.gradle.plugin.KOTLIN_DSL_NAME +import org.jetbrains.kotlin.gradle.plugin.KOTLIN_JS_DSL_NAME +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.getConvention +import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile + +/** + * [ToolingModelBuilder] for [KotlinProject] models. + * This model builder is registered for base Kotlin JVM, Kotlin JS and Kotlin Common plugins. + */ +class KotlinModelBuilder(private val kotlinPluginVersion: String) : ToolingModelBuilder { + + override fun canBuild(modelName: String): Boolean { + return modelName == KotlinProject::class.java.name + } + + override fun buildAll(modelName: String, project: Project): Any? { + if (modelName == KotlinProject::class.java.name) { + val kotlinCompileTasks = project.tasks.withType(AbstractKotlinCompile::class.java) + val projectType = getProjectType(project) + return KotlinProjectImpl( + project.name, + kotlinPluginVersion, + projectType, + kotlinCompileTasks.mapNotNull { it.createSourceSet(project, projectType) }, + getExpectedByDependencies(project), + kotlinCompileTasks.first()!!.createExperimentalFeatures() + ) + } + return null + } + + companion object { + + private fun getProjectType(project: Project): KotlinProject.ProjectType { + return if (project.plugins.hasPlugin("kotlin") || project.plugins.hasPlugin("kotlin-platform-jvm")) { + KotlinProject.ProjectType.PLATFORM_JVM + } else if (project.plugins.hasPlugin("kotlin2js") || project.plugins.hasPlugin("kotlin-platform-js")) { + KotlinProject.ProjectType.PLATFORM_JS + } else { + KotlinProject.ProjectType.PLATFORM_COMMON + } + } + + private fun getExpectedByDependencies(project: Project): Collection { + return listOf("expectedBy", "implement") + .flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet() } + .filterIsInstance() + .mapNotNull { it.dependencyProject } + .map { it.pathOrName() } + } + + private fun Project.pathOrName() = if (path == ":") name else path + + private fun AbstractKotlinCompile<*>.createSourceSet(project: Project, projectType: KotlinProject.ProjectType): SourceSet? { + val javaSourceSet = + project.convention.findPlugin(JavaPluginConvention::class.java)?.sourceSets?.find { it.name == sourceSetName } + val kotlinSourceSet = + javaSourceSet?.getConvention(if (projectType == KotlinProject.ProjectType.PLATFORM_JS) KOTLIN_JS_DSL_NAME else KOTLIN_DSL_NAME) as? KotlinSourceSet + return if (kotlinSourceSet != null) { + SourceSetImpl( + sourceSetName, + if (sourceSetName.contains("test", true)) SourceSet.SourceSetType.TEST else SourceSet.SourceSetType.PRODUCTION, + findFriendSourceSets(), + kotlinSourceSet.kotlin.srcDirs, + javaSourceSet.resources.srcDirs, + destinationDir, + javaSourceSet.output.resourcesDir, + createCompilerArguments() + ) + } else null + } + + private fun AbstractKotlinCompile<*>.findFriendSourceSets(): Collection { + val friendSourceSets = ArrayList() + friendTask?.sourceSetName?.let { friendSourceSets.add(it) } + return friendSourceSets + } + + private fun AbstractKotlinCompile<*>.createCompilerArguments(): CompilerArguments { + return CompilerArgumentsImpl( + serializedCompilerArguments, + defaultSerializedCompilerArguments, + compileClasspath.toList() + ) + } + + private fun AbstractKotlinCompile<*>.createExperimentalFeatures(): ExperimentalFeatures { + return ExperimentalFeaturesImpl(coroutinesStr) + } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImpl.kt new file mode 100644 index 00000000000..bfc0b1d6fa3 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImpl.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import org.jetbrains.kotlin.gradle.model.CompilerArguments +import java.io.File +import java.io.Serializable + +/** + * Implementation of the [CompilerArguments] interface. + */ +data class CompilerArgumentsImpl( + private val myCurrentArguments: List, + private val myDefaultArguments: List, + private val myCompilerClasspath: List +) : CompilerArguments, Serializable { + + override fun getCurrentArguments(): List { + return myCurrentArguments + } + + override fun getDefaultArguments(): List { + return myDefaultArguments + } + + override fun getCompileClasspath(): List { + return myCompilerClasspath + } + + companion object { + private const val serialVersionUID = 1L + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImpl.kt new file mode 100644 index 00000000000..cb0f114fade --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImpl.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import org.jetbrains.kotlin.gradle.model.ExperimentalFeatures +import java.io.Serializable + +/** + * Implementation of the [ExperimentalFeatures] interface. + */ +data class ExperimentalFeaturesImpl( + private val myCoroutines: String? +) : ExperimentalFeatures, Serializable { + + override fun getCoroutines(): String? { + return myCoroutines + } + + companion object { + private const val serialVersionUID = 1L + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImpl.kt new file mode 100644 index 00000000000..4995020c9d3 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImpl.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import org.jetbrains.kotlin.gradle.model.ExperimentalFeatures +import org.jetbrains.kotlin.gradle.model.KotlinProject +import org.jetbrains.kotlin.gradle.model.SourceSet +import java.io.Serializable + +/** + * Implementation of the [KotlinProject] interface. + */ +data class KotlinProjectImpl( + private val myName: String, + private val myKotlinVersion: String, + private val myProjectType: KotlinProject.ProjectType, + private val mySourceSets: Collection, + private val myExpectedByDependencies: Collection, + private val myExperimentalFeatures: ExperimentalFeatures +) : KotlinProject, Serializable { + + override fun getModelVersion(): Long { + return serialVersionUID + } + + override fun getName(): String { + return myName + } + + override fun getKotlinVersion(): String { + return myKotlinVersion + } + + override fun getProjectType(): KotlinProject.ProjectType { + return myProjectType + } + + override fun getSourceSets(): Collection { + return mySourceSets + } + + override fun getExpectedByDependencies(): Collection { + return myExpectedByDependencies + } + + override fun getExperimentalFeatures(): ExperimentalFeatures { + return myExperimentalFeatures + } + + companion object { + private const val serialVersionUID = 1L + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImpl.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImpl.kt new file mode 100644 index 00000000000..4fb9a034f59 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImpl.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import org.jetbrains.kotlin.gradle.model.CompilerArguments +import org.jetbrains.kotlin.gradle.model.SourceSet +import java.io.File +import java.io.Serializable + +/** + * Implementation of the [SourceSet] interface. + */ +data class SourceSetImpl( + private val myName: String, + private val myType: SourceSet.SourceSetType, + private val myFriendSourceSets: Collection, + private val mySourceDirectories: Collection, + private val myResourcesDirectories: Collection, + private val myClassesOutputDirectory: File, + private val myResourcesOutputDirectory: File, + private val myCompilerArguments: CompilerArguments +) : SourceSet, Serializable { + + override fun getName(): String { + return myName + } + + override fun getType(): SourceSet.SourceSetType { + return myType + } + + override fun getFriendSourceSets(): Collection { + return myFriendSourceSets + } + + override fun getSourceDirectories(): Collection { + return mySourceDirectories + } + + override fun getResourcesDirectories(): Collection { + return myResourcesDirectories + } + + override fun getClassesOutputDirectory(): File { + return myClassesOutputDirectory + } + + override fun getResourcesOutputDirectory(): File { + return myResourcesOutputDirectory + } + + override fun getCompilerArguments(): CompilerArguments { + return myCompilerArguments + } + + companion object { + private const val serialVersionUID = 1L + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index 6e27084a85a..7152809ce66 100755 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -23,12 +23,14 @@ import org.gradle.api.tasks.SourceSetOutput import org.gradle.api.tasks.compile.AbstractCompile import org.gradle.api.tasks.compile.JavaCompile import org.gradle.jvm.tasks.Jar +import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin.Companion.getKaptGeneratedClassesDir import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin import org.jetbrains.kotlin.gradle.internal.KaptVariantData import org.jetbrains.kotlin.gradle.internal.checkAndroidAnnotationProcessorDependencyUsage +import org.jetbrains.kotlin.gradle.model.builder.KotlinModelBuilder import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin import org.jetbrains.kotlin.gradle.tasks.* import org.jetbrains.kotlin.gradle.utils.* @@ -333,7 +335,8 @@ internal class KotlinCommonSourceSetProcessor( internal abstract class AbstractKotlinPlugin( val tasksProvider: KotlinTasksProvider, val kotlinSourceSetProvider: KotlinSourceSetProvider, - protected val kotlinPluginVersion: String + protected val kotlinPluginVersion: String, + val registry: ToolingModelBuilderRegistry ) : Plugin { internal abstract fun buildSourceSetProcessor(project: Project, javaBasePlugin: JavaBasePlugin, sourceSet: SourceSet, kotlinPluginVersion: String): KotlinSourceSetProcessor<*> @@ -346,6 +349,7 @@ internal abstract class AbstractKotlinPlugin( configureSourceSetDefaults(project, javaBasePlugin, javaPluginConvention) configureDefaultVersionsResolutionStrategy(project) configureClassInspectionForIC(project) + registry.register(KotlinModelBuilder(kotlinPluginVersion)) } open protected fun configureSourceSetDefaults( @@ -402,8 +406,9 @@ internal abstract class AbstractKotlinPlugin( internal open class KotlinPlugin( tasksProvider: KotlinTasksProvider, kotlinSourceSetProvider: KotlinSourceSetProvider, - kotlinPluginVersion: String -) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) { + kotlinPluginVersion: String, + registry: ToolingModelBuilderRegistry +) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion, registry) { override fun buildSourceSetProcessor(project: Project, javaBasePlugin: JavaBasePlugin, sourceSet: SourceSet, kotlinPluginVersion: String) = Kotlin2JvmSourceSetProcessor(project, javaBasePlugin, sourceSet, tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) @@ -416,8 +421,9 @@ internal open class KotlinPlugin( internal open class KotlinCommonPlugin( tasksProvider: KotlinTasksProvider, kotlinSourceSetProvider: KotlinSourceSetProvider, - kotlinPluginVersion: String -) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) { + kotlinPluginVersion: String, + registry: ToolingModelBuilderRegistry +) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion, registry) { override fun buildSourceSetProcessor(project: Project, javaBasePlugin: JavaBasePlugin, sourceSet: SourceSet, kotlinPluginVersion: String) = KotlinCommonSourceSetProcessor(project, javaBasePlugin, sourceSet, tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) } @@ -425,8 +431,9 @@ internal open class KotlinCommonPlugin( internal open class Kotlin2JsPlugin( tasksProvider: KotlinTasksProvider, kotlinSourceSetProvider: KotlinSourceSetProvider, - kotlinPluginVersion: String -) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) { + kotlinPluginVersion: String, + registry: ToolingModelBuilderRegistry +) : AbstractKotlinPlugin(tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion, registry) { override fun buildSourceSetProcessor(project: Project, javaBasePlugin: JavaBasePlugin, sourceSet: SourceSet, kotlinPluginVersion: String) = Kotlin2JsSourceSetProcessor(project, javaBasePlugin, sourceSet, tasksProvider, kotlinSourceSetProvider, kotlinPluginVersion) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt index 1a8ceaff010..be22f74ee5f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt @@ -21,6 +21,7 @@ import org.gradle.api.Project import org.gradle.api.internal.file.FileResolver import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging +import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.dsl.createKotlinExtension @@ -60,27 +61,27 @@ abstract class KotlinBasePluginWrapper(protected val fileResolver: FileResolver) open val projectExtensionClass: KClass get() = KotlinProjectExtension::class } -open class KotlinPluginWrapper @Inject constructor(fileResolver: FileResolver): KotlinBasePluginWrapper(fileResolver) { +open class KotlinPluginWrapper @Inject internal constructor(fileResolver: FileResolver, protected val registry: ToolingModelBuilderRegistry): KotlinBasePluginWrapper(fileResolver) { override fun getPlugin(kotlinGradleBuildServices: KotlinGradleBuildServices) = - KotlinPlugin(KotlinTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion) + KotlinPlugin(KotlinTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion, registry) override val projectExtensionClass: KClass get() = KotlinJvmProjectExtension::class } -open class KotlinCommonPluginWrapper @Inject constructor(fileResolver: FileResolver): KotlinBasePluginWrapper(fileResolver) { +open class KotlinCommonPluginWrapper @Inject internal constructor(fileResolver: FileResolver, protected val registry: ToolingModelBuilderRegistry): KotlinBasePluginWrapper(fileResolver) { override fun getPlugin(kotlinGradleBuildServices: KotlinGradleBuildServices) = - KotlinCommonPlugin(KotlinCommonTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion) + KotlinCommonPlugin(KotlinCommonTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion, registry) } -open class KotlinAndroidPluginWrapper @Inject constructor(fileResolver: FileResolver): KotlinBasePluginWrapper(fileResolver) { +open class KotlinAndroidPluginWrapper @Inject internal constructor(fileResolver: FileResolver, protected val registry: ToolingModelBuilderRegistry): KotlinBasePluginWrapper(fileResolver) { override fun getPlugin(kotlinGradleBuildServices: KotlinGradleBuildServices) = KotlinAndroidPlugin(AndroidTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion) } -open class Kotlin2JsPluginWrapper @Inject constructor(fileResolver: FileResolver): KotlinBasePluginWrapper(fileResolver) { +open class Kotlin2JsPluginWrapper @Inject internal constructor(fileResolver: FileResolver, protected val registry: ToolingModelBuilderRegistry): KotlinBasePluginWrapper(fileResolver) { override fun getPlugin(kotlinGradleBuildServices: KotlinGradleBuildServices) = - Kotlin2JsPlugin(Kotlin2JsTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion) + Kotlin2JsPlugin(Kotlin2JsTasksProvider(), KotlinSourceSetProviderImpl(fileResolver), kotlinPluginVersion, registry) } fun Project.getKotlinPluginVersion(): String? = diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index fa942df1a9f..4c85eb69fcf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -148,7 +148,7 @@ abstract class AbstractKotlinCompile() : AbstractKo protected val additionalClasspath = arrayListOf() @get:Internal // classpath already participates in the checks - protected val compileClasspath: Iterable + val compileClasspath: Iterable get() = (classpath + additionalClasspath) .filterTo(LinkedHashSet(), File::exists) @@ -201,7 +201,7 @@ abstract class AbstractKotlinCompile() : AbstractKo @Suppress("UNCHECKED_CAST") @get:Internal - protected val friendTask: AbstractKotlinCompile? + val friendTask: AbstractKotlinCompile? get() = friendTaskName?.let { project.tasks.findByName(it) } as? AbstractKotlinCompile /** Classes directories that are not produced by this task but should be consumed by diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt new file mode 100644 index 00000000000..f204582edd8 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.builder + +import org.jetbrains.kotlin.gradle.model.KotlinProject +import org.junit.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class KotlinModelBuilderTest { + @Test + fun testCanBuild() { + val modelBuilder = KotlinModelBuilder("version") + assertTrue(modelBuilder.canBuild(KotlinProject::class.java.name)) + assertFalse(modelBuilder.canBuild("wrongModel")) + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImplTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImplTest.kt new file mode 100644 index 00000000000..978f35b1257 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/CompilerArgumentsImplTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import nl.jqno.equalsverifier.EqualsVerifier +import nl.jqno.equalsverifier.Warning +import org.junit.Test + +class CompilerArgumentsImplTest { + @Test + @Throws(Exception::class) + fun equals() { + EqualsVerifier.forClass(CompilerArgumentsImpl::class.java).suppress(Warning.NULL_FIELDS).verify() + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImplTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImplTest.kt new file mode 100644 index 00000000000..c079ca5b762 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/ExperimentalFeaturesImplTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import nl.jqno.equalsverifier.EqualsVerifier +import nl.jqno.equalsverifier.Warning +import org.junit.Test + +class ExperimentalFeaturesImplTest { + @Test + @Throws(Exception::class) + fun equals() { + EqualsVerifier.forClass(ExperimentalFeaturesImpl::class.java).suppress(Warning.NULL_FIELDS).verify() + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImplTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImplTest.kt new file mode 100644 index 00000000000..4d77928b3ae --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/KotlinProjectImplTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import nl.jqno.equalsverifier.EqualsVerifier +import nl.jqno.equalsverifier.Warning +import org.junit.Test + +class KotlinProjectImplTest { + @Test + @Throws(Exception::class) + fun equals() { + EqualsVerifier.forClass(KotlinProjectImpl::class.java).suppress(Warning.NULL_FIELDS).verify() + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImplTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImplTest.kt new file mode 100644 index 00000000000..28089f1c6a4 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/impl/SourceSetImplTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.model.impl + +import nl.jqno.equalsverifier.EqualsVerifier +import nl.jqno.equalsverifier.Warning +import org.junit.Test + +class SourceSetImplTest { + @Test + @Throws(Exception::class) + fun equals() { + EqualsVerifier.forClass(SourceSetImpl::class.java).suppress(Warning.NULL_FIELDS).verify() + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 4bb3199f498..0f10a910c31 100644 --- a/settings.gradle +++ b/settings.gradle @@ -141,6 +141,7 @@ include ":kotlin-build-common", ":tools:kotlinp", ":kotlin-gradle-plugin-api", ":kotlin-gradle-plugin", + ":kotlin-gradle-plugin-model", ":kotlin-gradle-plugin-test-utils-embeddable", ":kotlin-gradle-plugin-integration-tests", ":kotlin-allopen", @@ -251,6 +252,7 @@ project(':tools:kotlin-stdlib-gen').projectDir = "$rootDir/libraries/tools/kotli project(':tools:kotlinp').projectDir = "$rootDir/libraries/tools/kotlinp" as File project(':kotlin-gradle-plugin-api').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin-api" as File project(':kotlin-gradle-plugin').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin" as File +project(':kotlin-gradle-plugin-model').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin-model" as File project(':kotlin-gradle-plugin-test-utils-embeddable').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin-test-utils-embeddable" as File project(':kotlin-gradle-plugin-integration-tests').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugin-integration-tests" as File project(':kotlin-allopen').projectDir = "$rootDir/libraries/tools/kotlin-allopen" as File