/*
 * Copyright 2022 Arunkumar
 *
 * 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.intellij.tasks.RunPluginVerifierTask.FailureLevel

plugins {
  id "org.jetbrains.intellij" version "1.0"
  id "kotlin-library-plugin"
}

repositories {
  mavenCentral()
}

dependencies {
  testImplementation deps.junit
  testImplementation deps.truth
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
  updateSinceUntilBuild.set(false)
  version.set("202.7660.26") // AS 4.2.1
  type.set("IC")

  plugins.set([
    "Kotlin", "IntelliLang", "java", "android"
  ])
  pluginName.set("Scabbard - Dagger 2 Visualizer")
  // localPath.set("C:\\Users\\arunk\\AppData\\Local\\JetBrains\\Toolbox\\apps\\AndroidStudio\\ch-0\\202.7351085")
}

patchPluginXml {
  changeNotes.set(provider {
    """
      0.5.0
      Square Anvil support
      Visualize Missing Binding error directly from console logs
      Support latest Hilt and Dagger changes
      Provide gutter icon option to open SVG files directly in system web browser
      Migrate artifacts to mavenCentral
      Support Android Studio 4.2.1
      0.4.0
      Dagger Hilt and Visualizing component hierarchy support
      0.3.0
      New Gutter Icon, inherited bindings support in subcomponent graphs, and ability to open multiple images via gutter popup
      0.2.0
      Gutter icons on @ContributesAndroidInjector to open generated subcomponent image.
      <br>  
      Initial release - 0.1.0
      <br>
      Gutter icons on @Component, @Subcomponent and @Module to open graph generated by Scabbard Gradle plugin"""
  })
}

runPluginVerifier {
  ideVersions = [
    "IC-2020.1.4",
    "IC-2020.2.4",
    "IC-2020.3.2",
    "IC-2021.1",
  ]

  def customFailureLevel = FailureLevel.ALL
  customFailureLevel.remove(FailureLevel.DEPRECATED_API_USAGES)
  customFailureLevel.remove(FailureLevel.EXPERIMENTAL_API_USAGES)
  customFailureLevel.remove(FailureLevel.INTERNAL_API_USAGES)
  customFailureLevel.remove(FailureLevel.NOT_DYNAMIC)

  setFailureLevel(customFailureLevel)
}

runIde {
  systemProperty "idea.ProcessCanceledException", "disabled"
}

publishPlugin {
  token.set(project.findProperty("intellijPublishToken"))
}
