[kotlin] Replace Java version with placeholders in testNewModuleInJavaProject to make it work on any version

^KTIJ-29188 Fixed


Merge-request: IJ-MR-130054
Merged-by: Victoria Petrakovich <Victoria.Petrakovich@jetbrains.com>

GitOrigin-RevId: ab7c48fbf745e6bdb5047ee4111a85f8397659d8
This commit is contained in:
Victoria.Petrakovich
2024-03-26 17:15:08 +00:00
committed by intellij-monorepo-bot
parent 3b91d4d47c
commit 8867b57c84
2 changed files with 17 additions and 3 deletions
@@ -329,7 +329,8 @@ class MavenNewKotlinModuleTest : MavenNewProjectWizardTestCase(), NewKotlinProje
}
override fun postprocessOutputFile(relativePath: String, fileContents: String): String {
return substituteArtifactsVersions(fileContents)
val result = substituteCompilerSourceAndTargetLevels(fileContents)
return substituteArtifactsVersions(result)
}
override fun getTestFolderName(): String {
@@ -367,4 +368,17 @@ class MavenNewKotlinModuleTest : MavenNewProjectWizardTestCase(), NewKotlinProje
}
return result
}
private fun substituteCompilerSourceAndTargetLevels(fileContents: String): String {
val compilerSourceRegex = Regex("<maven.compiler.source>(\\d\\d)")
val compilerTargetRegex = Regex("<maven.compiler.target>(\\d\\d)")
var result = fileContents
if (result.contains(compilerSourceRegex)) {
result = result.replace(compilerSourceRegex, "<maven.compiler.source>VERSION")
}
if (result.contains(compilerTargetRegex)) {
result = result.replace(compilerTargetRegex, "<maven.compiler.target>VERSION")
}
return result
}
}
@@ -13,8 +13,8 @@
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>VERSION</maven.compiler.source>
<maven.compiler.target>VERSION</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>