mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Kotlin] Replace wizard default data generator to use velocity templates rather than using raw string templates
^KTIJ-29504 fixed GitOrigin-RevId: 3cfa81048700a199bf19be3acc398de5ed4e2844
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6cd36d56be
commit
619aea07d6
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
@@ -31,6 +31,6 @@ internal val DEFAULT_DEPENDENCY_DATA = DependencyVersionState(
|
||||
"org.jetbrains.kotlin-wrappers:kotlin-redux" to "4.1.2",
|
||||
"org.jetbrains.kotlinx:kotlinx-html-jvm" to "0.7.2",
|
||||
"org.jetbrains.kotlinx:kotlinx-nodejs" to "0.0.7",
|
||||
"org.junit.jupiter:junit-jupiter-engine" to "5.10.0"
|
||||
"org.junit.jupiter:junit-jupiter-engine" to "5.10.0",
|
||||
)
|
||||
)
|
||||
+14
-14
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
@@ -35,63 +35,63 @@ internal val DEFAULT_KOTLIN_GRADLE_COMPATIBILITY_DATA = KotlinGradleCompatibilit
|
||||
"1.5.21",
|
||||
"1.5.20",
|
||||
"1.5.10",
|
||||
"1.5.0"
|
||||
"1.5.0",
|
||||
),
|
||||
compatibility = listOf(
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.9.20-1.9.30",
|
||||
gradle = "6.8.3-8.7",
|
||||
maxJvmTarget = 21
|
||||
maxJvmTarget = 21,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.9.0-1.9.20",
|
||||
gradle = "6.8.3-8.7",
|
||||
maxJvmTarget = 20
|
||||
maxJvmTarget = 20,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.8.20-1.8.30",
|
||||
gradle = "6.8.3-8.6",
|
||||
maxJvmTarget = 19
|
||||
maxJvmTarget = 19,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.8.0-1.8.20",
|
||||
gradle = "6.8.3-7.4.0",
|
||||
maxJvmTarget = 19
|
||||
maxJvmTarget = 19,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.7.20-1.7.30",
|
||||
gradle = "6.7.1-7.2.0",
|
||||
maxJvmTarget = 18
|
||||
maxJvmTarget = 18,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.7.0-1.7.20",
|
||||
gradle = "6.7.1-7.0.2",
|
||||
maxJvmTarget = 18
|
||||
maxJvmTarget = 18,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.6.20-1.7.0",
|
||||
gradle = "6.1.1-7.0.2",
|
||||
maxJvmTarget = 18
|
||||
maxJvmTarget = 18,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.6.0-1.6.20",
|
||||
gradle = "6.1.1-7.0",
|
||||
maxJvmTarget = 17
|
||||
maxJvmTarget = 17,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.5.30-1.6.0",
|
||||
gradle = "6.1.1-7.0",
|
||||
maxJvmTarget = 16
|
||||
maxJvmTarget = 16,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.5.20-1.5.30",
|
||||
gradle = "6.1.1-7.0",
|
||||
maxJvmTarget = 16
|
||||
maxJvmTarget = 16,
|
||||
),
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "1.5.0-1.5.20",
|
||||
gradle = "6.1-7.0",
|
||||
maxJvmTarget = 16
|
||||
)
|
||||
maxJvmTarget = 16,
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ internal val COROUTINES_LIBRARY_COMPATIBILITY_DEFAULT_DATA = KotlinLibraryCompat
|
||||
groupId = "org.jetbrains.kotlinx",
|
||||
artifactId = "kotlinx-coroutines-core",
|
||||
versions = mapOf(
|
||||
"1.5" to "1.5.2",
|
||||
"1.6" to "1.6.4",
|
||||
"1.9" to "1.8.0",
|
||||
"1.8" to "1.7.3",
|
||||
"1.9" to "1.8.0"
|
||||
"1.6" to "1.6.4",
|
||||
"1.5" to "1.5.2",
|
||||
)
|
||||
)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright 2000-${YEAR} JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.DependencyVersionState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_DEPENDENCY_DATA = DependencyVersionState(
|
||||
versions = mapOf(
|
||||
#foreach ($dependency in $DEPENDENCIES)
|
||||
"${dependency.first}" to "${dependency.second}",
|
||||
#end
|
||||
)
|
||||
)
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Copyright 2000-${YEAR} JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinGradleCompatibilityState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_KOTLIN_GRADLE_COMPATIBILITY_DATA = KotlinGradleCompatibilityState(
|
||||
kotlinVersions = listOf(
|
||||
#foreach ($version in $KOTLIN_VERSIONS)
|
||||
"$version",
|
||||
#end
|
||||
),
|
||||
compatibility = listOf(
|
||||
#foreach ($entry in $COMPATIBILITY_ENTRIES)
|
||||
KotlinGradleVersionMapping(
|
||||
kotlin = "${entry.kotlin}",
|
||||
gradle = "${entry.gradle}",
|
||||
maxJvmTarget = ${entry.maxJvmTarget},
|
||||
#if ($entry.comment)
|
||||
comment = "${entry.comment}"
|
||||
#end
|
||||
),
|
||||
#end
|
||||
)
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Copyright 2000-${YEAR} JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries.KotlinLibraryCompatibilityState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val ${DEFAULT_DATA_NAME} = KotlinLibraryCompatibilityState(
|
||||
groupId = "$GROUP_ID",
|
||||
artifactId = "$ARTIFACT_ID",
|
||||
versions = mapOf(
|
||||
#foreach($version in $VERSIONS)
|
||||
"${version.first}" to "${version.second}",
|
||||
#end
|
||||
)
|
||||
)
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-${YEAR} JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinWizardVersionState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_KOTLIN_WIZARD_VERSIONS = KotlinWizardVersionState(
|
||||
kotlinPluginVersion = "$kotlinPluginVersion",
|
||||
kotlinForComposeVersion = "$kotlinForComposeVersion",
|
||||
composeCompilerExtension = "$composeCompilerExtension",
|
||||
minGradleFoojayVersion = "$minGradleFoojayVersion",
|
||||
minKotlinFoojayVersion = "$minKotlinFoojayVersion",
|
||||
foojayVersion = "$foojayVersion",
|
||||
failsafeVersion = "$failsafeVersion",
|
||||
surefireVersion = "$surefireVersion",
|
||||
gradleAndroidVersion = "$gradleAndroidVersion",
|
||||
codehausMojoExecVersion = "$codehausMojoExecVersion"
|
||||
)
|
||||
+3
-20
@@ -5,6 +5,7 @@ import com.google.gson.JsonObject
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.service
|
||||
import org.apache.velocity.VelocityContext
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.*
|
||||
|
||||
class DependencyVersionState() : IdeVersionedDataState() {
|
||||
@@ -54,25 +55,7 @@ class DependencyVersionStore : IdeVersionedDataStorage<DependencyVersionState>(
|
||||
}
|
||||
}
|
||||
|
||||
internal fun DependencyVersionState.generateDefaultData(): String {
|
||||
internal fun DependencyVersionState.provideDefaultDataContext(context: VelocityContext) {
|
||||
val sortedDependencies = versions.toList().sortedBy { it.first }
|
||||
return """
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.DependencyVersionState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_DEPENDENCY_DATA = DependencyVersionState(
|
||||
versions = mapOf(
|
||||
${sortedDependencies.joinToString("," + System.lineSeparator()) {
|
||||
" ".repeat(8) + "\"${it.first}\" to \"${it.second}\""
|
||||
}}
|
||||
)
|
||||
)
|
||||
""".trimIndent()
|
||||
context.put("DEPENDENCIES", sortedDependencies)
|
||||
}
|
||||
+4
-21
@@ -6,6 +6,7 @@ import com.intellij.openapi.components.BaseState
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.service
|
||||
import org.apache.velocity.VelocityContext
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.IdeKotlinVersion
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.*
|
||||
@@ -146,25 +147,7 @@ private fun KotlinGradleVersionMapping.toDefaultDataString(): String {
|
||||
}.toString()
|
||||
}
|
||||
|
||||
internal fun KotlinGradleCompatibilityState.generateDefaultData(): String {
|
||||
return """
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinGradleCompatibilityState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_KOTLIN_GRADLE_COMPATIBILITY_DATA = KotlinGradleCompatibilityState(
|
||||
kotlinVersions = listOf(
|
||||
${kotlinVersions.joinToString("," + System.lineSeparator()) { " ".repeat(8) + "\"$it\"" }}
|
||||
),
|
||||
compatibility = listOf(
|
||||
${compatibility.toList().joinToString("," + System.lineSeparator()) { it.toDefaultDataString() }}
|
||||
)
|
||||
)
|
||||
""".trimIndent()
|
||||
internal fun KotlinGradleCompatibilityState.provideDefaultDataContext(context: VelocityContext) {
|
||||
context.put("KOTLIN_VERSIONS", kotlinVersions)
|
||||
context.put("COMPATIBILITY_ENTRIES", compatibility)
|
||||
}
|
||||
+32
-7
@@ -1,19 +1,27 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility
|
||||
|
||||
import org.apache.velocity.VelocityContext
|
||||
import org.apache.velocity.app.VelocityEngine
|
||||
import org.apache.velocity.runtime.RuntimeConstants
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries.KotlinLibraryCompatibilityParser
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries.generateDefaultData
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries.provideDefaultDataContext
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.IdeVersionedDataParser
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.IdeVersionedDataState
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.readAppVersion
|
||||
import java.io.StringWriter
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.Paths
|
||||
import java.time.LocalDate
|
||||
|
||||
|
||||
class WizardDefaultDataGeneratorSettings<T : IdeVersionedDataState>(
|
||||
val jsonPath: String,
|
||||
val ktFileName: String,
|
||||
val parser: IdeVersionedDataParser<T>,
|
||||
val generator: (T).() -> String
|
||||
val templatePath: String,
|
||||
val contextProvider: (T).(context: VelocityContext) -> Unit
|
||||
) {
|
||||
companion object {
|
||||
fun getGenerators() = listOf(
|
||||
@@ -21,25 +29,29 @@ class WizardDefaultDataGeneratorSettings<T : IdeVersionedDataState>(
|
||||
jsonPath = "/compatibility/dependencies.json",
|
||||
ktFileName = "DependencyDefaultData.kt",
|
||||
parser = DependencyVersionParser,
|
||||
generator = DependencyVersionState::generateDefaultData
|
||||
templatePath = "compatibility/templates/KotlinDependencyDefaultData.kt.vm",
|
||||
contextProvider = DependencyVersionState::provideDefaultDataContext
|
||||
),
|
||||
WizardDefaultDataGeneratorSettings(
|
||||
jsonPath = "/compatibility/kotlin_gradle_compatibility.json",
|
||||
ktFileName = "KotlinGradleCompatibilityDefaultData.kt",
|
||||
parser = KotlinGradleCompatibilityParser,
|
||||
generator = KotlinGradleCompatibilityState::generateDefaultData
|
||||
templatePath = "compatibility/templates/KotlinGradleCompatibilityDefaultData.kt.vm",
|
||||
contextProvider = KotlinGradleCompatibilityState::provideDefaultDataContext
|
||||
),
|
||||
WizardDefaultDataGeneratorSettings(
|
||||
jsonPath = "/compatibility/wizard_versions.json",
|
||||
ktFileName = "KotlinWizardVersionDefaultData.kt",
|
||||
parser = KotlinWizardVersionParser,
|
||||
generator = KotlinWizardVersionState::generateDefaultData
|
||||
templatePath = "compatibility/templates/KotlinWizardVersionDefaultData.kt.vm",
|
||||
contextProvider = KotlinWizardVersionState::provideDefaultDataContext
|
||||
),
|
||||
WizardDefaultDataGeneratorSettings(
|
||||
jsonPath = "/compatibility/libraries/coroutines.json",
|
||||
ktFileName = "libraries/CoroutinesLibraryCompatibilityDefaultData.kt",
|
||||
parser = KotlinLibraryCompatibilityParser,
|
||||
generator = { generateDefaultData("COROUTINES_LIBRARY_COMPATIBILITY_DEFAULT_DATA") }
|
||||
templatePath = "compatibility/templates/KotlinLibraryDefaultData.kt.vm",
|
||||
contextProvider = { provideDefaultDataContext("COROUTINES_LIBRARY_COMPATIBILITY_DEFAULT_DATA", it) }
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -50,7 +62,20 @@ class WizardDefaultDataGeneratorSettings<T : IdeVersionedDataState>(
|
||||
.toString(Charset.forName("utf8"))
|
||||
val parsedData = parser.parseVersionedJson(jsonData, applicationVersion)!!
|
||||
|
||||
return generator(parsedData)
|
||||
val velocityEngine = VelocityEngine()
|
||||
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADERS, "classpath");
|
||||
velocityEngine.setProperty("resource.loader.classpath.class", ClasspathResourceLoader::class.java.name)
|
||||
velocityEngine.init()
|
||||
|
||||
val template = velocityEngine.getTemplate(templatePath)
|
||||
val context = VelocityContext()
|
||||
|
||||
context.put("YEAR", LocalDate.now().year)
|
||||
contextProvider(parsedData, context)
|
||||
val writer = StringWriter()
|
||||
template.merge(context, writer)
|
||||
|
||||
return writer.toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-25
@@ -5,7 +5,9 @@ import com.google.gson.JsonObject
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.service
|
||||
import org.apache.velocity.VelocityContext
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.*
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
internal object KotlinWizardVersionParser : IdeVersionedDataParser<KotlinWizardVersionState>() {
|
||||
override fun parseJson(data: JsonObject): KotlinWizardVersionState? {
|
||||
@@ -82,29 +84,8 @@ class KotlinWizardVersionStore : IdeVersionedDataStorage<KotlinWizardVersionStat
|
||||
}
|
||||
|
||||
|
||||
internal fun KotlinWizardVersionState.generateDefaultData(): String {
|
||||
return """
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.KotlinWizardVersionState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val DEFAULT_KOTLIN_WIZARD_VERSIONS = KotlinWizardVersionState(
|
||||
kotlinPluginVersion = "$kotlinPluginVersion",
|
||||
kotlinForComposeVersion = "$kotlinForComposeVersion",
|
||||
composeCompilerExtension = "$composeCompilerExtension",
|
||||
minGradleFoojayVersion = "$minGradleFoojayVersion",
|
||||
minKotlinFoojayVersion = "$minKotlinFoojayVersion",
|
||||
foojayVersion = "$foojayVersion",
|
||||
failsafeVersion = "$failsafeVersion",
|
||||
surefireVersion = "$surefireVersion",
|
||||
gradleAndroidVersion = "$gradleAndroidVersion",
|
||||
codehausMojoExecVersion = "$codehausMojoExecVersion"
|
||||
)
|
||||
""".trimIndent()
|
||||
internal fun KotlinWizardVersionState.provideDefaultDataContext(context: VelocityContext) {
|
||||
KotlinWizardVersionState::class.members.filter { it.returnType == typeOf<String?>() }.forEach { field ->
|
||||
context.put(field.name, field.call(this))
|
||||
}
|
||||
}
|
||||
+6
-23
@@ -2,6 +2,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import org.apache.velocity.VelocityContext
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.IdeVersionedDataParser
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.IdeVersionedDataState
|
||||
import org.jetbrains.plugins.gradle.jvmcompat.asSafeJsonObject
|
||||
@@ -36,27 +37,9 @@ internal object KotlinLibraryCompatibilityParser : IdeVersionedDataParser<Kotlin
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KotlinLibraryCompatibilityState.generateDefaultData(variableName: String): String {
|
||||
val versions = versions.toList().sortedBy { it.first }
|
||||
return """
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries;
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.compatibility.libraries.KotlinLibraryCompatibilityState
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate Kotlin Wizard Default Data" configuration instead
|
||||
*/
|
||||
internal val $variableName = KotlinLibraryCompatibilityState(
|
||||
groupId = "$groupId",
|
||||
artifactId = "$artifactId",
|
||||
versions = mapOf(
|
||||
${versions.joinToString("," + System.lineSeparator()) {
|
||||
" ".repeat(8) + "\"${it.first}\" to \"${it.second}\""
|
||||
}}
|
||||
)
|
||||
)
|
||||
""".trimIndent()
|
||||
internal fun KotlinLibraryCompatibilityState.provideDefaultDataContext(defaultDataName: String, context: VelocityContext) {
|
||||
context.put("DEFAULT_DATA_NAME", defaultDataName)
|
||||
context.put("GROUP_ID", groupId)
|
||||
context.put("ARTIFACT_ID", artifactId)
|
||||
context.put("VERSIONS", versions.toList().sortedByDescending { it.first })
|
||||
}
|
||||
+7
-12
@@ -3,17 +3,10 @@ package org.jetbrains.kotlin.tools.projectWizard.compatibility
|
||||
|
||||
import com.intellij.openapi.application.ApplicationInfo
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.idea.base.test.KotlinRoot
|
||||
import java.io.File
|
||||
|
||||
class DefaultDataUpToDateTest : BasePlatformTestCase() {
|
||||
private val newLineRegex = Regex("[\\r\\n]+")
|
||||
|
||||
private fun String.stripNewLines(): String {
|
||||
return replace(newLineRegex, "")
|
||||
}
|
||||
|
||||
fun testDefaultDataUpToDate() {
|
||||
val applicationVersion = ApplicationInfo.getInstance().fullVersion
|
||||
val generatedFolder = File(KotlinRoot.DIR, "project-wizard/core/generated")
|
||||
@@ -22,17 +15,19 @@ class DefaultDataUpToDateTest : BasePlatformTestCase() {
|
||||
val generatedOutput = generator.generateDefaultData(applicationVersion)
|
||||
val existingFile = File(generatedFolder, generator.ktFileName)
|
||||
|
||||
TestCase.assertTrue(
|
||||
assertTrue(
|
||||
"Could not find generated ${generator.ktFileName}. Please run the 'Generate Kotlin Wizard Default Data' task.",
|
||||
existingFile.isFile
|
||||
)
|
||||
|
||||
val existingContent = existingFile.readText()
|
||||
// We drop the copyright notice because we do not care for the year to be up-to-date here
|
||||
val generatedContent = generatedOutput.lines().drop(1)
|
||||
val existingContent = existingFile.readLines().drop(1)
|
||||
|
||||
TestCase.assertEquals(
|
||||
assertEquals(
|
||||
"Generated file ${generator.ktFileName} differs from Json content and is likely outdated. Please run the 'Generate Kotlin Wizard Default Data' task.",
|
||||
generatedOutput.stripNewLines(),
|
||||
existingContent.stripNewLines()
|
||||
generatedContent,
|
||||
existingContent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user