/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
  kotlin("jvm")
  id("org.jetbrains.intellij.platform.module")
  id("org.jetbrains.compose")
  id("org.jetbrains.kotlin.plugin.compose") version "2.1.10"
}

repositories {
  maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
  maven("https://packages.jetbrains.team/maven/p/kpm/public/")
  google()
  mavenCentral()
  intellijPlatform {
    defaultRepositories()
  }
}

kotlin { jvmToolchain(17) }

dependencies {
  intellijPlatform {
    intellijIdeaCommunity(libs.versions.idea)
    bundledPlugin("org.jetbrains.kotlin")
    // Add dependency on Compose and Jewel modules
    bundledModule("intellij.platform.jewel.foundation")
    bundledModule("intellij.platform.jewel.ideLafBridge")
    bundledModule("intellij.platform.jewel.markdown.core")
    bundledModule("intellij.platform.jewel.markdown.ideLafBridgeStyling")
    bundledModule("intellij.platform.jewel.ui")
    bundledModule("intellij.libraries.compose.foundation.desktop")
    bundledModule("intellij.libraries.skiko")
  }
}

dependencies {
  api("androidx.lifecycle:lifecycle-runtime:2.8.7")
  testApi(compose.desktop.uiTestJUnit4)
  testApi("org.jetbrains.jewel:jewel-int-ui-standalone:0.28.0-251.26137")
  testApi("org.jetbrains.jewel:jewel-markdown-int-ui-standalone-styling:0.28.0-251.26137")
  testImplementation("com.google.truth:truth:0.42")
}

sourceSets {
  main {
    resources { srcDirs("src/resources") }
    kotlin { srcDirs("src") }
  }
  test {
    resources { srcDirs("testResources") }
    kotlin {
      srcDirs("testSrc")
      exclude("com/android/tools/adtui/compose/ComposeTestSuite.kt")
    }
  }
}

tasks {
  withType<KotlinCompile> {
    compilerOptions {
      jvmTarget.set(JvmTarget.JVM_17)
      apiVersion.set(KotlinVersion.KOTLIN_1_9)
      languageVersion.set(KotlinVersion.KOTLIN_1_9)
    }
  }
}

configurations {
  val test by creating {
    // Copy from testImplementation
    extendsFrom(configurations.testImplementation.get())
  }
}

tasks.register<Jar>("testJar") {
  archiveClassifier.set("tests")
  from(sourceSets.test.get().output)
}

artifacts {
  // Used by other modules' tests
  add("test", tasks.named<Jar>("testJar"))
}
