mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-32514 Add project import tests for the Gradle project isolation feature (jvm)
Some tests are muted until related issues are resolved: - testJvmOnJvmJavaAndKotlin, testJvmSharedResources: muted until KTIJ-32507 is fixed - testSimpleMultiTargetProject: muted until Kotlin is updated to bootstrap version 2.2.0, which includes KT-74727 GitOrigin-RevId: 76e29ecb587d4159b25a1ab7f066e4935455d45d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7abd052062
commit
cda6881f89
+50
-3
@@ -6,12 +6,13 @@ import org.jetbrains.kotlin.gradle.multiplatformTests.testFeatures.NoErrorEvents
|
||||
import org.jetbrains.kotlin.gradle.multiplatformTests.testFeatures.checkers.highlighting.HighlightingChecker
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
|
||||
@TestMetadata("multiplatform/core/features/projectIsolation")
|
||||
class KotlinMppProjectIsolationTest : AbstractKotlinMppGradleImportingTest() {
|
||||
@Test
|
||||
@PluginTargetVersions(pluginVersion = "2.1.20-dev-10000+")
|
||||
@PluginTargetVersions(pluginVersion = "2.1.20-dev-3305+", gradleVersion = "8.10+")
|
||||
fun testJvmOnly() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
@@ -21,9 +22,10 @@ class KotlinMppProjectIsolationTest : AbstractKotlinMppGradleImportingTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Check and unmute when KTIJ-32507 is fixed")
|
||||
@Test
|
||||
@PluginTargetVersions(pluginVersion = "2.1.20-dev-10000+")
|
||||
fun testSimpleMultiTargetProject() {
|
||||
@PluginTargetVersions(gradleVersion = "8.10+")
|
||||
fun testJvmOnJvmJavaAndKotlin() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
NoErrorEventsDuringImportFeature,
|
||||
@@ -32,4 +34,49 @@ class KotlinMppProjectIsolationTest : AbstractKotlinMppGradleImportingTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(pluginVersion = "2.1.20-dev-3305+", gradleVersion = "8.10+")
|
||||
fun testJvmAndKapt() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
NoErrorEventsDuringImportFeature,
|
||||
HighlightingChecker
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Check and unmute when KTIJ-32507 is fixed")
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersion = "8.10+")
|
||||
fun testJvmSharedResources() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
NoErrorEventsDuringImportFeature,
|
||||
HighlightingChecker
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PluginTargetVersions(pluginVersion = "2.1.20-dev-3305+", gradleVersion = "8.10+")
|
||||
fun testJvmIncludedBuild() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
NoErrorEventsDuringImportFeature,
|
||||
HighlightingChecker
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Unmute when the latest kotlin is updated to bootstrap version 2.2.0 and bootstrap version includes KT-74727")
|
||||
@Test
|
||||
@PluginTargetVersions(gradleVersion = "8.10+")
|
||||
fun testSimpleMultiTargetProject() {
|
||||
doTest {
|
||||
onlyCheckers(
|
||||
NoErrorEventsDuringImportFeature,
|
||||
HighlightingChecker
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.kotlinGradlePlugin)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "buildSrc"
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package buildsrc.convention
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension> {
|
||||
sourceSets.configureEach {
|
||||
languageSettings.optIn("kotlin.RequiresOptIn")
|
||||
}
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xcontext-receivers")
|
||||
suppressWarnings.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package buildsrc.convention
|
||||
|
||||
plugins {
|
||||
id("buildsrc.convention.kotlin-jvm")
|
||||
kotlin("kapt")
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
org.gradle.unsafe.isolated-projects=true
|
||||
kapt.verbose=true
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
[versions]
|
||||
kotlin = "{{kgp_version}}"
|
||||
dagger = "2.55"
|
||||
junit = "5.11.4"
|
||||
|
||||
[libraries]
|
||||
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
dagger = { group = "com.google.dagger", name = "dagger", version.ref = "dagger" }
|
||||
dagger-compiler = { group = "com.google.dagger", name = "dagger-compiler", version.ref = "dagger" }
|
||||
junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id("buildsrc.convention.kotlin-kapt")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.dagger)
|
||||
kapt(libs.dagger.compiler)
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import dagger.Component
|
||||
|
||||
@Component
|
||||
interface AppComponent {
|
||||
fun <!LINE_MARKER("descr='getModule1() exposes Module1(Dependency)'")!>getModule1<!>(): Module1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import javax.inject.Inject
|
||||
|
||||
class Dependency @Inject <!LINE_MARKER("descr='Dependency() provides for Module1'")!>constructor<!>() {
|
||||
fun provideInfo(): String = "I'm a dependency!"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import javax.inject.Inject
|
||||
|
||||
class Module1 @Inject <!LINE_MARKER("descr='Module1(Dependency) exposed in AppComponent'")!>constructor<!>(private val <!LINE_MARKER("descr='dependency consumes Dependency()'")!>dependency<!>: Dependency) {
|
||||
fun greet(): String = "Hello from Module1 and ${dependency.provideInfo()}"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class <!LINE_MARKER("descr='Run Test'")!>Module1Test<!> {
|
||||
|
||||
@Test
|
||||
fun <!LINE_MARKER("descr='Run Test'")!>`test Module1 greet`<!>() {
|
||||
val dependency = Dependency()
|
||||
val module1 = Module1(dependency)
|
||||
|
||||
val expected = "Hello from Module1 and I'm a dependency!"
|
||||
assertEquals(expected, module1.greet())
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
id("buildsrc.convention.kotlin-jvm")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Module2 {
|
||||
fun calculate(a: Int, b: Int): Int = a + b
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class <!LINE_MARKER("descr='Run Test'")!>Module2Test<!> {
|
||||
@Test
|
||||
fun <!LINE_MARKER("descr='Run Test'")!>`test calculate`<!>() {
|
||||
val module2 = Module2()
|
||||
assertEquals(5, module2.calculate(2, 3))
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rootProject.name = "jvmAndKapt"
|
||||
|
||||
include("module1")
|
||||
include("module2")
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.unsafe.isolated-projects=true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
[versions]
|
||||
kotlin = "{{kgp_version}}"
|
||||
|
||||
[plugins]
|
||||
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
id("org.example.my-plugin")
|
||||
}
|
||||
|
||||
group = "org.example.my-app"
|
||||
version = "1.0"
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.example.myapp
|
||||
|
||||
fun <!LINE_MARKER!>main<!>() {
|
||||
println("Hello from my app!")
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
`java-gradle-plugin`
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
group = "org.example.my-plugin"
|
||||
version = "1.0"
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("myPlugin") {
|
||||
id = "org.example.my-plugin"
|
||||
implementationClass = "org.example.myplugin.MyPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.example.myplugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.register
|
||||
|
||||
class MyPlugin : Plugin<Project> {
|
||||
override fun <!LINE_MARKER("descr='Implements function in Plugin (org.gradle.api) Press ... to navigate'")!>apply<!>(project: Project) {
|
||||
project.tasks.register<org.gradle.api.DefaultTask>("helloFromPlugin") {
|
||||
group = "MyPluginTasks"
|
||||
description = "Example task from custom plugin"
|
||||
doLast {
|
||||
println("Hello from MyPlugin!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "jvmIncludedBuild"
|
||||
|
||||
include(":my-app")
|
||||
|
||||
includeBuild("my-plugin")
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":utils"))
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.example.app
|
||||
|
||||
import com.example.utils.DateUtils
|
||||
|
||||
fun <!LINE_MARKER!>main<!>() {
|
||||
val currentDate = <!HIGHLIGHTING("severity='ERROR'; descr='[UNRESOLVED_REFERENCE] Unresolved reference: DateUtils'")!>DateUtils<!>.<!HIGHLIGHTING("severity='ERROR'; descr='[DEBUG] Reference is not resolved to anything, but is not marked unresolved'")!>getCurrentDate<!>()
|
||||
println("Today's date is: $<!HIGHLIGHTING("severity='ERROR'; descr='[DEBUG] Resolved to error element'")!>currentDate<!>")
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
org.gradle.unsafe.isolated-projects=true
|
||||
kotlin.code.style=official
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
|
||||
plugins {
|
||||
val kotlinVersion = "{{kgp_version}}"
|
||||
kotlin("jvm") version kotlinVersion
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "jvmOnJvmJavaAndKotlin"
|
||||
include("app", "utils")
|
||||
|
||||
gradle.lifecycle.beforeProject {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.example.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class DateUtils {
|
||||
public static String <!LINE_MARKER("descr='Inferred annotations available.Full signature: @NotNull StringgetCurrentDate()'")!>getCurrentDate<!>() {
|
||||
return LocalDate.now().toString();
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
application
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":service"))
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("com.example.AppMain")
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
dependsOn(":common:build")
|
||||
doLast {
|
||||
println("App build depends on common build.")
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.example
|
||||
|
||||
fun startApp() {
|
||||
println("Starting App...")
|
||||
serviceFunction()
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
}
|
||||
|
||||
tasks.register("prepareResources") {
|
||||
val outputDir = layout.buildDirectory.dir("shared-resources")
|
||||
outputs.dir(outputDir)
|
||||
|
||||
val parentProjectName = rootProject.name
|
||||
val currentProjectName = project.name
|
||||
val currentProjectVersion = "1.0.0"
|
||||
|
||||
doLast {
|
||||
println("Preparing shared resources in the 'common' module...")
|
||||
|
||||
val jsonConfig = """
|
||||
{
|
||||
"parentProject": "$parentProjectName",
|
||||
"currentProject": {
|
||||
"name": "$currentProjectName",
|
||||
"version": "$currentProjectVersion",
|
||||
"description": "shared resources"
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val configFile = outputDir.get().asFile.resolve("config.json")
|
||||
configFile.parentFile.mkdirs()
|
||||
configFile.writeText(jsonConfig)
|
||||
|
||||
println("Shared resources prepared at: ${configFile.absolutePath}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.example
|
||||
|
||||
object Utils {
|
||||
fun sayHello(name: String): String {
|
||||
return "Hello, $name!"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.unsafe.isolated-projects=true
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
[versions]
|
||||
kotlin = "{{kgp_version}}"
|
||||
|
||||
[plugins]
|
||||
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":common"))
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
dependsOn(":common:prepareResources")
|
||||
|
||||
doLast {
|
||||
println("Building 'service' module...")
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.example
|
||||
|
||||
fun serviceFunction() {
|
||||
println(Utils.sayHello("Service"))
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
{{kts_kotlin_plugin_repositories}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rootProject.name = "jvmSharedResources"
|
||||
|
||||
include(":common", ":service", ":app")
|
||||
+1
-3
@@ -3,9 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm() {
|
||||
withJava()
|
||||
}
|
||||
jvm()
|
||||
macosArm64()
|
||||
|
||||
sourceSets.nativeMain.dependencies {
|
||||
|
||||
+1
-3
@@ -3,9 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm() {
|
||||
withJava()
|
||||
}
|
||||
jvm()
|
||||
macosArm64()
|
||||
macosX64()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user