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. 14
      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 {
id("org.jetbrains.kotlin.jvm") version "1.6.21"
id("org.jetbrains.kotlin.jvm")
}
@ -20,5 +20,13 @@ java {
}
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

14
web/buildSrc/settings.gradle.kts

@ -1,12 +1,22 @@
pluginManagement {
val kotlinVersion: String = settings.extra["kotlin.version"] as String
repositories {
gradlePluginPortal()
mavenCentral()
maven {
url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven {
url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
maven {
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,
failureExpected: Boolean = false,
composeVersion: String,
kotlinVersion: String,
vararg buildCmd: String = arrayOf("build", "jsNodeRun")
) {
val isWin = System.getProperty("os.name").startsWith("Win")
val arguments = buildCmd.toMutableList().also {
it.add("-PCOMPOSE_CORE_VERSION=$composeVersion")
it.add("-Pkotlin.version=$kotlinVersion")
}.toTypedArray()
val procBuilder = if (isWin) {
@ -121,7 +123,8 @@ fun runCasesInDirectory(
dir: File,
filterPath: String,
expectCompilationError: Boolean,
composeVersion: String
composeVersion: String,
kotlinVersion: String
): RunChecksResult {
return dir.listFiles()!!.filter { it.absolutePath.contains(filterPath) }.mapIndexed { _, file ->
println("Running check for ${file.name}, expectCompilationError = $expectCompilationError, composeVersion = $composeVersion")
@ -160,7 +163,8 @@ fun runCasesInDirectory(
caseName = caseName,
directory = tmpDir,
failureExpected = expectCompilationError,
composeVersion = composeVersion
composeVersion = composeVersion,
kotlinVersion = kotlinVersion
)
}.exceptionOrNull()
@ -173,13 +177,15 @@ tasks.register("checkComposeCases") {
doLast {
val filterCases = project.findProperty("FILTER_CASES")?.toString() ?: ""
val composeVersion = project.findProperty("COMPOSE_CORE_VERSION")?.toString() ?: "0.0.0-SNASPHOT"
val kotlinVersion = kotlin.coreLibrariesVersion
val expectedFailingCasesDir = File("${projectDir.absolutePath}/testcases/failing")
val expectedFailingResult = runCasesInDirectory(
dir = expectedFailingCasesDir,
expectCompilationError = true,
filterPath = filterCases,
composeVersion = composeVersion
composeVersion = composeVersion,
kotlinVersion = kotlinVersion
)
val passingCasesDir = File("${projectDir.absolutePath}/testcases/passing")
@ -187,7 +193,8 @@ tasks.register("checkComposeCases") {
dir = passingCasesDir,
expectCompilationError = false,
filterPath = filterCases,
composeVersion = composeVersion
composeVersion = composeVersion,
kotlinVersion = kotlinVersion
)
expectedFailingResult.printResults()

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

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

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

@ -8,6 +8,8 @@ pluginManagement {
}
resolutionStrategy {
val kotlinVersion = extra["kotlin.version"] as String
println("KotlinVersion=[$kotlinVersion]")
eachPlugin {
if (requested.id.id == "org.jetbrains.compose") {
val useVersion = if (extra.has("COMPOSE_CORE_VERSION")) {
@ -17,6 +19,8 @@ pluginManagement {
}
println("COMPOSE_INTEGRATION_VERSION=[$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 {
if (requested.id.id == "org.jetbrains.compose") {
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
// 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);
const consoleLog = logger.create("NewReporter-KotlinReporter");
@ -39,8 +44,6 @@ const NewReporter = function(baseReporterDecorator, config, emitter) {
}
}
NewReporter.$inject = KotlinReporter.$inject;
module.exports = {
'reporter:karma-kotlin-reporter': ['type', NewReporter]
};

Loading…
Cancel
Save