Browse Source

web: pass kotlin.version property (#2044)

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/2047/head
Oleksandr Karpovich 2 years ago committed by GitHub
parent
commit
5c0a72e677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      web/buildSrc/build.gradle.kts
  2. 2
      web/buildSrc/gradle.properties
  3. 10
      web/buildSrc/settings.gradle.kts
  4. 15
      web/compose-compiler-integration/build.gradle.kts
  5. 2
      web/compose-compiler-integration/main-template/build.gradle.kts
  6. 4
      web/compose-compiler-integration/main-template/settings.gradle.kts
  7. 2
      web/settings.gradle.kts
  8. 15
      web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js

12
web/buildSrc/build.gradle.kts

@ -10,7 +10,7 @@ repositories {
} }
plugins { plugins {
id("org.jetbrains.kotlin.jvm") version "1.6.21" id("org.jetbrains.kotlin.jvm")
} }
@ -20,5 +20,13 @@ java {
} }
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
// Write kotlin.version into a file, so it can be read by karma-test-runner patch (see test-utils/conf)
File(projectDir.resolve("build"), "kotlin.version").apply {
val kotlinVersion = extra["kotlin.version"].toString()
println("Writing kotlin.version=$kotlinVersion into $absolutePath")
createNewFile()
writeText(kotlinVersion)
} }

2
web/buildSrc/gradle.properties

@ -0,0 +1,2 @@
# __KOTLIN_COMPOSE_VERSION__
kotlin.version=1.6.10

10
web/buildSrc/settings.gradle.kts

@ -1,4 +1,6 @@
pluginManagement { pluginManagement {
val kotlinVersion: String = settings.extra["kotlin.version"] as String
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
mavenCentral() mavenCentral()
@ -9,4 +11,12 @@ pluginManagement {
url = uri("https://packages.jetbrains.team/maven/p/ui/dev") url = uri("https://packages.jetbrains.team/maven/p/ui/dev")
} }
} }
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
useVersion(kotlinVersion)
}
}
}
} }

15
web/compose-compiler-integration/build.gradle.kts

@ -56,11 +56,13 @@ fun build(
directory: File, directory: File,
failureExpected: Boolean = false, failureExpected: Boolean = false,
composeVersion: String, composeVersion: String,
kotlinVersion: String,
vararg buildCmd: String = arrayOf("build", "jsNodeRun") vararg buildCmd: String = arrayOf("build", "jsNodeRun")
) { ) {
val isWin = System.getProperty("os.name").startsWith("Win") val isWin = System.getProperty("os.name").startsWith("Win")
val arguments = buildCmd.toMutableList().also { val arguments = buildCmd.toMutableList().also {
it.add("-PCOMPOSE_CORE_VERSION=$composeVersion") it.add("-PCOMPOSE_CORE_VERSION=$composeVersion")
it.add("-Pkotlin.version=$kotlinVersion")
}.toTypedArray() }.toTypedArray()
val procBuilder = if (isWin) { val procBuilder = if (isWin) {
@ -121,7 +123,8 @@ fun runCasesInDirectory(
dir: File, dir: File,
filterPath: String, filterPath: String,
expectCompilationError: Boolean, expectCompilationError: Boolean,
composeVersion: String composeVersion: String,
kotlinVersion: String
): RunChecksResult { ): RunChecksResult {
return dir.listFiles()!!.filter { it.absolutePath.contains(filterPath) }.mapIndexed { _, file -> return dir.listFiles()!!.filter { it.absolutePath.contains(filterPath) }.mapIndexed { _, file ->
println("Running check for ${file.name}, expectCompilationError = $expectCompilationError, composeVersion = $composeVersion") println("Running check for ${file.name}, expectCompilationError = $expectCompilationError, composeVersion = $composeVersion")
@ -160,7 +163,8 @@ fun runCasesInDirectory(
caseName = caseName, caseName = caseName,
directory = tmpDir, directory = tmpDir,
failureExpected = expectCompilationError, failureExpected = expectCompilationError,
composeVersion = composeVersion composeVersion = composeVersion,
kotlinVersion = kotlinVersion
) )
}.exceptionOrNull() }.exceptionOrNull()
@ -173,13 +177,15 @@ tasks.register("checkComposeCases") {
doLast { doLast {
val filterCases = project.findProperty("FILTER_CASES")?.toString() ?: "" val filterCases = project.findProperty("FILTER_CASES")?.toString() ?: ""
val composeVersion = project.findProperty("COMPOSE_CORE_VERSION")?.toString() ?: "0.0.0-SNASPHOT" val composeVersion = project.findProperty("COMPOSE_CORE_VERSION")?.toString() ?: "0.0.0-SNASPHOT"
val kotlinVersion = kotlin.coreLibrariesVersion
val expectedFailingCasesDir = File("${projectDir.absolutePath}/testcases/failing") val expectedFailingCasesDir = File("${projectDir.absolutePath}/testcases/failing")
val expectedFailingResult = runCasesInDirectory( val expectedFailingResult = runCasesInDirectory(
dir = expectedFailingCasesDir, dir = expectedFailingCasesDir,
expectCompilationError = true, expectCompilationError = true,
filterPath = filterCases, filterPath = filterCases,
composeVersion = composeVersion composeVersion = composeVersion,
kotlinVersion = kotlinVersion
) )
val passingCasesDir = File("${projectDir.absolutePath}/testcases/passing") val passingCasesDir = File("${projectDir.absolutePath}/testcases/passing")
@ -187,7 +193,8 @@ tasks.register("checkComposeCases") {
dir = passingCasesDir, dir = passingCasesDir,
expectCompilationError = false, expectCompilationError = false,
filterPath = filterCases, filterPath = filterCases,
composeVersion = composeVersion composeVersion = composeVersion,
kotlinVersion = kotlinVersion
) )
expectedFailingResult.printResults() expectedFailingResult.printResults()

2
web/compose-compiler-integration/main-template/build.gradle.kts

@ -1,5 +1,5 @@
plugins { plugins {
kotlin("multiplatform") version "1.6.21" kotlin("multiplatform")
id("org.jetbrains.compose") id("org.jetbrains.compose")
} }

4
web/compose-compiler-integration/main-template/settings.gradle.kts

@ -8,6 +8,8 @@ pluginManagement {
} }
resolutionStrategy { resolutionStrategy {
val kotlinVersion = extra["kotlin.version"] as String
println("KotlinVersion=[$kotlinVersion]")
eachPlugin { eachPlugin {
if (requested.id.id == "org.jetbrains.compose") { if (requested.id.id == "org.jetbrains.compose") {
val useVersion = if (extra.has("COMPOSE_CORE_VERSION")) { val useVersion = if (extra.has("COMPOSE_CORE_VERSION")) {
@ -17,6 +19,8 @@ pluginManagement {
} }
println("COMPOSE_INTEGRATION_VERSION=[$useVersion]") println("COMPOSE_INTEGRATION_VERSION=[$useVersion]")
useVersion(useVersion) useVersion(useVersion)
} else if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
useVersion(kotlinVersion)
} }
} }
} }

2
web/settings.gradle.kts

@ -43,8 +43,6 @@ pluginManagement {
eachPlugin { eachPlugin {
if (requested.id.id == "org.jetbrains.compose") { if (requested.id.id == "org.jetbrains.compose") {
useModule("org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:$COMPOSE_CORE_VERSION") useModule("org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:$COMPOSE_CORE_VERSION")
} else if (requested.id.id == "org.jetbrains.kotlin.multiplatform") {
useModule("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.6.21")
} }
} }
} }

15
web/test-utils/conf/karma-kotlin-runner-decorator/karma-kotlin-reporter-decorated.js

@ -1,13 +1,18 @@
// This is a workaround for https://github.com/karma-runner/karma-teamcity-reporter/issues/86 // This is a workaround for https://github.com/karma-runner/karma-teamcity-reporter/issues/86
// logger is needed only to log cases when `browser.id` is not in browserResults // logger is needed only to log cases when `browser.id` is not in browserResults
const logger = require('../../../build/js/node_modules/karma/lib/logger') const logger = require('../../../build/js/node_modules/karma/lib/logger');
const kotlinReporterModule = require("../../../build/js/packages_imported/kotlin-test-js-runner/1.6.21/karma-kotlin-reporter"); const NewReporter = function(baseReporterDecorator, config, emitter) {
const KotlinReporter = kotlinReporterModule['reporter:karma-kotlin-reporter'][1]; const path = require('path');
const fs = require('fs');
const kotlinVersion = fs.readFileSync(path.resolve(__dirname, "../../../buildSrc/build/kotlin.version"), 'utf8');
const kotlinReporterModule = require(`../../../build/js/packages_imported/kotlin-test-js-runner/${kotlinVersion}/karma-kotlin-reporter`);
const KotlinReporter = kotlinReporterModule['reporter:karma-kotlin-reporter'][1];
this.$inject = KotlinReporter.$inject
const NewReporter = function(baseReporterDecorator, config, emitter) {
KotlinReporter.call(this, baseReporterDecorator, config, emitter); KotlinReporter.call(this, baseReporterDecorator, config, emitter);
const consoleLog = logger.create("NewReporter-KotlinReporter"); const consoleLog = logger.create("NewReporter-KotlinReporter");
@ -39,8 +44,6 @@ const NewReporter = function(baseReporterDecorator, config, emitter) {
} }
} }
NewReporter.$inject = KotlinReporter.$inject;
module.exports = { module.exports = {
'reporter:karma-kotlin-reporter': ['type', NewReporter] 'reporter:karma-kotlin-reporter': ['type', NewReporter]
}; };

Loading…
Cancel
Save