import org.jetbrains.intellij.platform.gradle.TestFrameworkType

plugins {
    id('java')
    id('org.jetbrains.intellij.platform') version('2.7.1') // IntelliJ Platform Gradle Plugin
}

// Configure project's dependencies
repositories {
    mavenCentral()
    // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
    intellijPlatform {
        defaultRepositories()
    }
}

java.sourceCompatibility = 21.0

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
    testRuntimeOnly('org.opentest4j:opentest4j:1.3.0')
    testImplementation('junit:junit:4.13.2')

    // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
    intellijPlatform {
        create(platformType, platformVersion)

        // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
        bundledPlugins(platformBundledPlugins.split(',').collect { it.trim() })

        // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
        plugins(platformPlugins.split(',').collect { it.trim() })

        instrumentationTools()
        pluginVerifier()
        testFramework(TestFrameworkType.Platform.INSTANCE)
        testFramework(TestFrameworkType.Plugin.Java.INSTANCE)
    }
}

group = pluginGroup
version = pluginVersion + '-' + platformVersion

intellijPlatform {
    pluginConfiguration {
        version = pluginVersion + '-' + platformVersion
        ideaVersion {
            sinceBuild = pluginSinceBuild
            untilBuild = pluginUntilBuild
        }
    }

    patchPluginXml {
        sinceBuild = pluginSinceBuild
        untilBuild = pluginUntilBuild
        changeNotes = """
                <ul>
                    <li>Fix infinite indexing (parameters)</li>
                </ul>
                <p><a href="https://github.com/giraud/reasonml-idea-plugin/blob/master/CHANGELOG.md">Full change log...</a></p>
                <p/>
                <p>To see how to integrate tools, go to the website.</p>
            """.stripIndent()
    }

    pluginVerification {
        ides {
            recommended()
        }
    }
}

runIde {
    systemProperty 'idea.is.internal', true
    jvmArgs '-Xmx2G'
    // MAVEN_CACHE C:\Users\hgiraud\scoop\persist\maven\.m2
    // MAVEN_HOME  C:\Users\hgiraud\scoop\apps\maven\current
    // MAVEN_REPOSITORY C:\Users\hgiraud\scoop\persist\maven\.m2\repository
}
