Remove 'kotlin-dce-js' Gradle plugin
^KT-48276 In Progress
This commit is contained in:
+7
-16
@@ -72,27 +72,18 @@ class BuildCacheRelocationIT : KGPBaseTest() {
|
||||
@JsGradlePluginTests
|
||||
@DisplayName("works with JS/DCE project")
|
||||
@GradleTest
|
||||
fun testRelocationKotlin2JsDce(gradleVersion: GradleVersion) {
|
||||
fun testRelocationKotlinJs(gradleVersion: GradleVersion) {
|
||||
val (firstProject, secondProject) = prepareTestProjects(
|
||||
"kotlin2JsDceProject",
|
||||
gradleVersion
|
||||
) { testProject ->
|
||||
// Fix the problem that the destinationDir of compile task (i.e. buildDir) contains files from other tasks:
|
||||
testProject.subProject("mainProject").buildGradle.modify {
|
||||
it.replace("/exampleapp.js", "/web/exampleapp.js")
|
||||
}
|
||||
testProject.subProject("libraryProject").buildGradle.modify {
|
||||
it.replace("/exampleapp.js", "/web/exampleapp.js")
|
||||
// Fix assembling the JAR from the whole buildDir
|
||||
it.replace("from buildDir", "from compileKotlin2Js.destinationDirectory")
|
||||
}
|
||||
}
|
||||
"kotlin-js-dce",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(warningMode = WarningMode.Summary) // Jar tasks produces deprecation warnings
|
||||
)
|
||||
|
||||
checkBuildCacheRelocation(
|
||||
firstProject,
|
||||
secondProject,
|
||||
listOf("assemble", "runDceKotlinJs"),
|
||||
listOf(":libraryProject:compileKotlin2Js", ":mainProject:compileKotlin2Js", ":mainProject:runDceKotlinJs")
|
||||
listOf("assemble"),
|
||||
listOf(":libraryProject:compileKotlinJs", ":mainProject:compileKotlinJs", ":mainProject:processDceKotlinJs")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -299,12 +299,12 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@DisplayName("DCE minifies output file")
|
||||
@GradleTest
|
||||
fun testDce(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsDceProject", gradleVersion) {
|
||||
project("kotlin-js-dce", gradleVersion) {
|
||||
build("runRhino") {
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/main"
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min"
|
||||
assertFileInProjectExists("$pathPrefix/exampleapp.js.map")
|
||||
assertFileInProjectExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js")
|
||||
assertFileExists(kotlinJs)
|
||||
@@ -319,14 +319,20 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@DisplayName("DCE output directory can be changed")
|
||||
@GradleTest
|
||||
fun testDceOutputPath(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsDceProject", gradleVersion) {
|
||||
project("kotlin-js-dce", gradleVersion) {
|
||||
subProject("mainProject").buildGradle.modify { originalScript ->
|
||||
buildString {
|
||||
append(originalScript)
|
||||
append(
|
||||
originalScript
|
||||
.lines()
|
||||
.filterNot { it.contains("destinationDirectory") }
|
||||
.joinToString(separator = "\n")
|
||||
)
|
||||
append(
|
||||
"""
|
||||
|
|
||||
|runDceKotlinJs.dceOptions.outputDirectory = "${'$'}{buildDir}/min"
|
||||
|tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach {
|
||||
| destinationDirectory = project.layout.buildDirectory.dir("min")
|
||||
|}
|
||||
|runRhino.args = ["-f", "min/kotlin.js", "-f", "min/examplelib.js", "-f", "min/exampleapp.js", "-f", "../check.js"]
|
||||
""".trimMargin()
|
||||
)
|
||||
@@ -348,19 +354,18 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@DisplayName("DCE in dev mode doesn't minify output file")
|
||||
@GradleTest
|
||||
fun testDceDevMode(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsDceProject", gradleVersion) {
|
||||
subProject("mainProject").buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|runDceKotlinJs.dceOptions.devMode = true
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
project("kotlin-js-dce", gradleVersion) {
|
||||
subProject("mainProject").buildGradle.modify {
|
||||
it.replace(
|
||||
"browser()",
|
||||
"browser { dceTask { dceOptions.devMode = true }}"
|
||||
)
|
||||
}
|
||||
|
||||
build("runRhino") {
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/main"
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min"
|
||||
assertFileInProjectExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js")
|
||||
assertFileExists(kotlinJs)
|
||||
@@ -372,15 +377,15 @@ class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@DisplayName("DCE minifies FileCollection dependencies")
|
||||
@GradleTest
|
||||
fun testDceFileCollectionDependency(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsDceProject", gradleVersion) {
|
||||
project("kotlin-js-dce", gradleVersion) {
|
||||
subProject("mainProject").buildGradle.modify {
|
||||
it.replace("compile project(\":libraryProject\")", "compile project(\":libraryProject\").sourceSets.main.output")
|
||||
}
|
||||
|
||||
build("runRhino") {
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/main"
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min"
|
||||
assertFileInProjectExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
assertFileInProjectContains("$pathPrefix/exampleapp.js.map", "\"../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
val kotlinJs = projectPath.resolve("$pathPrefix/kotlin.js")
|
||||
assertFileExists(kotlinJs)
|
||||
@@ -693,10 +698,10 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
)
|
||||
fun testNewKotlinJsPlugin(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-plugin-project", gradleVersion) {
|
||||
build("publish", "runDceKotlin", "test", "runDceBenchmarkKotlin") {
|
||||
build("publish", "processDceKotlinJs", "test", "processDceBenchmarkKotlinJs") {
|
||||
assertTasksExecuted(
|
||||
":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs",
|
||||
":runDceKotlin", ":runDceBenchmarkKotlin"
|
||||
":processDceKotlinJs", ":processDceBenchmarkKotlinJs"
|
||||
)
|
||||
|
||||
val moduleDir = projectPath.resolve("build/repo/com/example/kotlin-js-plugin/1.0/")
|
||||
@@ -710,7 +715,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
val publishedPom = moduleDir.resolve("kotlin-js-plugin-1.0.pom")
|
||||
val kotlinVersion = defaultBuildOptions.kotlinVersion
|
||||
val pomText = publishedPom.readText().replace(Regex("\\s+"), "")
|
||||
assertTrue { "kotlinx-html-js</artifactId><version>0.6.12</version><scope>compile</scope>" in pomText }
|
||||
assertTrue { "kotlinx-html-js</artifactId><version>0.7.5</version><scope>compile</scope>" in pomText }
|
||||
assertTrue { "kotlin-stdlib-js</artifactId><version>$kotlinVersion</version><scope>runtime</scope>" in pomText }
|
||||
|
||||
assertFileExists(moduleDir.resolve("kotlin-js-plugin-1.0-sources.jar"))
|
||||
@@ -726,12 +731,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map")
|
||||
|
||||
// Gradle 6.6+ slightly changed format of xml test results
|
||||
if (gradleVersion < GradleVersion.version("6.6")) {
|
||||
assertTestResults(projectPath.resolve("tests_pre6.6.xml"), "nodeTest")
|
||||
} else {
|
||||
assertTestResults(projectPath.resolve("tests.xml"), "nodeTest")
|
||||
}
|
||||
assertTestResults(projectPath.resolve("tests.xml"), "nodeTest")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1484,12 +1484,12 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) {
|
||||
build("runRhino", options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":mainProject:runDceNodeJsKotlin")
|
||||
assertTasksExecuted(":mainProject:processDceBrowserKotlinJs")
|
||||
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/nodeJs/main"
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/"
|
||||
assertFileExists("$pathPrefix/exampleapp.js.map")
|
||||
assertFileExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../../../src/nodeJsMain/kotlin/exampleapp/main.kt\"")
|
||||
assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../src/browserMain/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
assertFileExists("$pathPrefix/kotlin.js")
|
||||
assertTrue(fileInWorkingDir("$pathPrefix/kotlin.js").length() < 500 * 1000, "Looks like kotlin.js file was not minified by DCE")
|
||||
|
||||
+5
-21
@@ -6,11 +6,9 @@
|
||||
package org.jetbrains.kotlin.gradle.native
|
||||
|
||||
import com.intellij.testFramework.TestDataFile
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jdom.input.SAXBuilder
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||
import org.jetbrains.kotlin.gradle.GradleVersionRequired
|
||||
import org.jetbrains.kotlin.gradle.chooseWrapperVersionOrFinishTest
|
||||
import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_DISABLE_WARNING_PROPERTY_NAME
|
||||
import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_WARNING_PREFIX
|
||||
import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_PROPERTY_WARNING
|
||||
@@ -737,25 +735,11 @@ class GeneralNativeIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
// Gradle 6.6+ slightly changed format of xml test results
|
||||
// If, in the test project, preset name was updated,
|
||||
// update accordingly test result output for Gradle6.6+
|
||||
val testGradleVersion = project.chooseWrapperVersionOrFinishTest()
|
||||
val expectedHostTestResult: String
|
||||
val expectedIOSTestResults: List<String>
|
||||
if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) {
|
||||
expectedHostTestResult = "testProject/native-tests/TEST-TestKt_pre6.6.xml"
|
||||
expectedIOSTestResults = listOf(
|
||||
"testProject/native-tests/TEST-TestKt_pre6.6.xml",
|
||||
"testProject/native-tests/TEST-TestKt-iOSsim_pre6.6.xml",
|
||||
)
|
||||
} else {
|
||||
expectedHostTestResult = "testProject/native-tests/TEST-TestKt.xml"
|
||||
expectedIOSTestResults = listOf(
|
||||
"testProject/native-tests/TEST-TestKt-iOSsim.xml",
|
||||
"testProject/native-tests/TEST-TestKt-iOSArm64sim.xml",
|
||||
)
|
||||
}
|
||||
val expectedHostTestResult = "testProject/native-tests/TEST-TestKt.xml"
|
||||
val expectedIOSTestResults = listOf(
|
||||
"testProject/native-tests/TEST-TestKt-iOSsim.xml",
|
||||
"testProject/native-tests/TEST-TestKt-iOSArm64sim.xml",
|
||||
)
|
||||
|
||||
assertTestResults(expectedHostTestResult, hostTestTask)
|
||||
// K/N doesn't report line numbers correctly on Linux (see KT-35408).
|
||||
|
||||
-4
@@ -50,9 +50,6 @@ internal val DEFAULT_GROOVY_SETTINGS_FILE =
|
||||
case "com.android.feature":
|
||||
useModule("com.android.tools.build:gradle:${'$'}android_tools_version")
|
||||
break
|
||||
case "kotlin-dce-js":
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
break
|
||||
case "kotlin2js":
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
break
|
||||
@@ -106,7 +103,6 @@ internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||
"com.android.lint",
|
||||
"com.android.instantapp",
|
||||
"com.android.feature" -> useModule("com.android.tools.build:gradle:${'$'}android_tools_version")
|
||||
"kotlin-dce-js" -> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
"kotlin2js" -> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -68,6 +68,11 @@ internal fun readAndCleanupTestResults(
|
||||
e.attributes.forEach {
|
||||
if (it.name in skipAttrs) {
|
||||
it.value = "..."
|
||||
} else if (it.name == "name" &&
|
||||
e.name == "testcase" &&
|
||||
it.value.contains("[browser")
|
||||
) {
|
||||
it.value = it.value.replace("\\[browser,.*]".toRegex(), "[browser]")
|
||||
}
|
||||
}
|
||||
if (e.name == "system-out") {
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.js")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
|
||||
def compileKotlinJs = tasks.named('compileKotlinJs') {
|
||||
it.kotlinOptions.outputFile = "${buildDir}/web/examplelib.js"
|
||||
it.kotlinOptions.sourceMap = true
|
||||
}
|
||||
|
||||
tasks.register('jar', Jar).configure {
|
||||
dependsOn(compileKotlinJs)
|
||||
from compileKotlinJs.map { it.destinationDirectory }
|
||||
include "**/*.js"
|
||||
include "**/*.js.map"
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.js")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":libraryProject")
|
||||
implementation "org.mozilla:rhino:1.7.7.1"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
browser()
|
||||
}
|
||||
}
|
||||
|
||||
def compileKotlinJs = tasks.named('compileKotlinJs') {
|
||||
kotlinOptions {
|
||||
sourceMap = true
|
||||
outputFile = "${buildDir}/app/exampleapp.js"
|
||||
suppressWarnings = true
|
||||
verbose = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach {
|
||||
keep("exampleapp.exampleapp.status")
|
||||
destinationDirectory = project.layout.buildDirectory.dir("kotlin-js-min")
|
||||
}
|
||||
|
||||
tasks.register('runRhino', JavaExec) {
|
||||
dependsOn(tasks.named('processDceKotlinJs'))
|
||||
classpath = configurations.runtimeClasspath
|
||||
workingDir = "${buildDir}"
|
||||
mainClass = 'org.mozilla.javascript.tools.shell.Main'
|
||||
args = ["-opt", "-1",
|
||||
"-f", "kotlin-js-min/kotlin.js",
|
||||
"-f", "kotlin-js-min/examplelib.js",
|
||||
"-f", "kotlin-js-min/exampleapp.js",
|
||||
"-f", "../check.js"]
|
||||
}
|
||||
+11
-3
@@ -1,6 +1,5 @@
|
||||
plugins {
|
||||
kotlin("js")
|
||||
id("kotlin-dce-js")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
@@ -10,13 +9,13 @@ version = "1.0"
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jcenter.bintray.com/") }
|
||||
maven { setUrl("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") }
|
||||
}
|
||||
|
||||
kotlin.sourceSets {
|
||||
getByName("main") {
|
||||
dependencies {
|
||||
api("org.jetbrains.kotlinx:kotlinx-html-js:0.6.12")
|
||||
api("org.jetbrains.kotlinx:kotlinx-html-js:0.7.5")
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
@@ -29,6 +28,15 @@ kotlin.sourceSets {
|
||||
|
||||
kotlin.target {
|
||||
nodejs()
|
||||
browser {
|
||||
testTask {
|
||||
useKarma {
|
||||
useChromeHeadless()
|
||||
}
|
||||
enabled = false // Task is disabled because it requires browser to be installed. That may be a problem on CI.
|
||||
// Disabled but configured task allows us to check at least a part of configuration cache correctness.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin.target.compilations.create("benchmark") {
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="com.example.MainTest" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testHello" classname="com.example.MainTest" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
</results>
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin2js'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/examplelib.js"
|
||||
compileKotlin2Js.kotlinOptions.sourceMap = true
|
||||
|
||||
jar {
|
||||
from buildDir
|
||||
include "**/*.js"
|
||||
include "**/*.js.map"
|
||||
}
|
||||
|
||||
jar.dependsOn(compileKotlin2Js)
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin2js"
|
||||
apply plugin: "kotlin-dce-js"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":libraryProject")
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
implementation "org.mozilla:rhino:1.7.7.1"
|
||||
}
|
||||
|
||||
compileKotlin2Js.kotlinOptions.sourceMap = true
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/exampleapp.js"
|
||||
compileKotlin2Js.kotlinOptions.suppressWarnings = true
|
||||
compileKotlin2Js.kotlinOptions.verbose = true
|
||||
runDceKotlinJs.keep("exampleapp.exampleapp.status")
|
||||
|
||||
task runRhino(type: JavaExec) {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
workingDir = "${buildDir}"
|
||||
main = 'org.mozilla.javascript.tools.shell.Main'
|
||||
args = ["-opt", "-1",
|
||||
"-f", "kotlin-js-min/main/kotlin.js",
|
||||
"-f", "kotlin-js-min/main/examplelib.js",
|
||||
"-f", "kotlin-js-min/main/exampleapp.js",
|
||||
"-f", "../check.js"]
|
||||
}
|
||||
|
||||
runRhino.dependsOn(runDceKotlinJs)
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="org.foo.test.TestKt" tests="4" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties/>
|
||||
<testcase name="fooTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="barTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="barfooTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="fail" classname="org.foo.test.TestKt" time="...">
|
||||
<failure message="..." type="kotlin.IllegalStateException">...</failure>
|
||||
</testcase>
|
||||
<system-out><![CDATA[Foo call
|
||||
Bar call
|
||||
42
|
||||
Invalid connection: com.apple.coresymbolicationd
|
||||
]]></system-out>
|
||||
<system-err><![CDATA[]]></system-err>
|
||||
</testsuite>
|
||||
</results>
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="org.foo.test.TestKt" tests="4" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties/>
|
||||
<testcase name="fooTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="barTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="barfooTest" classname="org.foo.test.TestKt" time="..."/>
|
||||
<testcase name="fail" classname="org.foo.test.TestKt" time="...">
|
||||
<failure message="..." type="kotlin.IllegalStateException">...</failure>
|
||||
</testcase>
|
||||
<system-out><![CDATA[Foo call
|
||||
Bar call
|
||||
42]]></system-out>
|
||||
<system-err/>
|
||||
</testsuite>
|
||||
</results>
|
||||
+3
-1
@@ -15,7 +15,9 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'nodeJs')
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'nodeJs') {
|
||||
nodejs()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
nodeJsMainApi "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
|
||||
+25
-17
@@ -9,36 +9,44 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: "kotlin-multiplatform"
|
||||
apply plugin: "kotlin-dce-js"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'nodeJs')
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'browser') {
|
||||
browser()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
nodeJsImplementation project(":libraryProject")
|
||||
nodeJsImplementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||
nodeJsImplementation "org.mozilla:rhino:1.7.7.1"
|
||||
browserImplementation project(":libraryProject")
|
||||
browserImplementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||
browserImplementation "org.mozilla:rhino:1.7.7.1"
|
||||
}
|
||||
|
||||
compileKotlinNodeJs.kotlinOptions.sourceMap = true
|
||||
compileKotlinNodeJs.kotlinOptions.outputFile = "${buildDir}/exampleapp.js"
|
||||
compileKotlinNodeJs.kotlinOptions.suppressWarnings = true
|
||||
compileKotlinNodeJs.kotlinOptions.verbose = true
|
||||
runDceNodeJsKotlin.keep("exampleapp.exampleapp.status")
|
||||
tasks.named('compileKotlinBrowser') {
|
||||
kotlinOptions {
|
||||
sourceMap = true
|
||||
outputFile = "${buildDir}/web/exampleapp.js"
|
||||
suppressWarnings = true
|
||||
verbose = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach {
|
||||
keep("exampleapp.exampleapp.status")
|
||||
destinationDirectory = project.layout.buildDirectory.dir("kotlin-js-min")
|
||||
}
|
||||
|
||||
task runRhino(type: JavaExec) {
|
||||
classpath = kotlin.targets.nodeJs.compilations.main.runtimeDependencyFiles
|
||||
dependsOn(tasks.named('processDceBrowserKotlinJs'))
|
||||
classpath = kotlin.targets.browser.compilations.main.runtimeDependencyFiles
|
||||
workingDir = "${buildDir}"
|
||||
main = 'org.mozilla.javascript.tools.shell.Main'
|
||||
mainClass = 'org.mozilla.javascript.tools.shell.Main'
|
||||
args = ["-opt", "-1",
|
||||
"-f", "kotlin-js-min/nodeJs/main/kotlin.js",
|
||||
"-f", "kotlin-js-min/nodeJs/main/examplelib.js",
|
||||
"-f", "kotlin-js-min/nodeJs/main/exampleapp.js",
|
||||
"-f", "kotlin-js-min/kotlin.js",
|
||||
"-f", "kotlin-js-min/examplelib.js",
|
||||
"-f", "kotlin-js-min/exampleapp.js",
|
||||
"-f", "../check.js"]
|
||||
}
|
||||
|
||||
runRhino.dependsOn(runDceNodeJsKotlin)
|
||||
+3
@@ -38,6 +38,9 @@ internal fun KotlinCompilation<*>.composeName(prefix: String? = null, suffix: St
|
||||
internal fun KotlinCompilation<*>.isMain(): Boolean =
|
||||
name == KotlinCompilation.MAIN_COMPILATION_NAME
|
||||
|
||||
internal fun KotlinCompilation<*>.isTest(): Boolean =
|
||||
name == KotlinCompilation.TEST_COMPILATION_NAME
|
||||
|
||||
/**
|
||||
* see https://youtrack.jetbrains.com/issue/KT-45412
|
||||
* Some implementations of [KotlinCompilation] are not including their [KotlinCompilation.defaultSourceSet] into [kotlinSourceSet]s
|
||||
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce
|
||||
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import java.io.File
|
||||
|
||||
class KotlinJsDcePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.logger.warn(
|
||||
"""
|
||||
The `kotlin-dce-js` Gradle plugin has been deprecated.
|
||||
DCE is now integrated in the `org.jetbrains.kotlin.js` plugin.
|
||||
For plugin usage details, see https://kotlinlang.org/docs/reference/js-project-setup.html.
|
||||
For more details about JavaScript DCE, see https://kotlinlang.org/docs/reference/javascript-dce.html
|
||||
""".trimIndent()
|
||||
)
|
||||
val kotlinExtension =
|
||||
project.multiplatformExtensionOrNull
|
||||
?: project.extensions.getByName("kotlin") as? KotlinSingleTargetExtension
|
||||
?: run {
|
||||
project.pluginManager.apply(Kotlin2JsPluginWrapper::class.java)
|
||||
project.kotlinExtension as KotlinSingleTargetExtension
|
||||
}
|
||||
|
||||
fun forEachJsTarget(action: (KotlinTarget) -> Unit) {
|
||||
when (kotlinExtension) {
|
||||
is KotlinSingleTargetExtension -> action(kotlinExtension.target)
|
||||
is KotlinMultiplatformExtension ->
|
||||
kotlinExtension.targets
|
||||
.matching { it.platformType == KotlinPlatformType.js }
|
||||
.all { action(it) }
|
||||
}
|
||||
}
|
||||
|
||||
forEachJsTarget {
|
||||
it.compilations.all { processCompilation(project, it) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun processCompilation(project: Project, kotlinCompilation: KotlinCompilation<*>) {
|
||||
val kotlinTask = kotlinCompilation.compileKotlinTaskProvider
|
||||
val dceTaskName = lowerCamelCaseName(
|
||||
DCE_TASK_PREFIX,
|
||||
kotlinCompilation.target.disambiguationClassifier,
|
||||
kotlinCompilation.name.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME },
|
||||
if (kotlinCompilation.target is KotlinWithJavaTarget<*>) TASK_SUFFIX else MPP_TASK_SUFFIX
|
||||
)
|
||||
|
||||
val dceTask = project.registerTask<KotlinJsDce>(dceTaskName) {
|
||||
it.dependsOn(kotlinTask)
|
||||
it.defaultCompilerClasspath.setFrom(project.configurations.named(COMPILER_CLASSPATH_CONFIGURATION_NAME))
|
||||
}
|
||||
project.tasks.named("build").dependsOn(dceTask)
|
||||
|
||||
project.afterEvaluate {
|
||||
val outputDir = project.buildDir
|
||||
.resolve(DEFAULT_OUT_DIR)
|
||||
.resolve(kotlinCompilation.target.disambiguationClassifier?.let { "$it/" }.orEmpty() + kotlinCompilation.name)
|
||||
|
||||
val configuration = project.configurations.getByName(kotlinCompilation.compileDependencyConfigurationName)
|
||||
|
||||
dceTask.configure {
|
||||
it.libraries.from(configuration)
|
||||
it.destinationDirectory.set(it.dceOptions.outputDirectory?.let { File(it) } ?: outputDir)
|
||||
it.setSource(kotlinTask.map { task -> (task as Kotlin2JsCompile).outputFileProperty })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TASK_SUFFIX = "kotlinJs"
|
||||
private const val MPP_TASK_SUFFIX = "kotlin"
|
||||
private const val DCE_TASK_PREFIX = "runDce"
|
||||
private const val DEFAULT_OUT_DIR = "kotlin-js-min"
|
||||
}
|
||||
}
|
||||
+21
-8
@@ -14,6 +14,8 @@ import org.jetbrains.kotlin.gradle.plugin.COMPILER_CLASSPATH_CONFIGURATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isMain
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isTest
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.executeTaskBaseName
|
||||
@@ -90,15 +92,12 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
}
|
||||
|
||||
override fun configureMain(compilation: KotlinJsCompilation) {
|
||||
val dceTaskProvider = configureDce(
|
||||
compilation = compilation,
|
||||
dev = false
|
||||
)
|
||||
val (dceTaskProvider, devDceTaskProvider) = compilation.configureDceTasks()
|
||||
|
||||
val devDceTaskProvider = configureDce(
|
||||
compilation = compilation,
|
||||
dev = true
|
||||
)
|
||||
// Adding dce tasks to additional JS compilations
|
||||
target.compilations.configureEach {
|
||||
if (!it.isMain() && !it.isTest()) it.configureDceTasks()
|
||||
}
|
||||
|
||||
configureRun(
|
||||
compilation = compilation,
|
||||
@@ -112,6 +111,20 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
)
|
||||
}
|
||||
|
||||
private fun KotlinJsCompilation.configureDceTasks(): Pair<TaskProvider<KotlinJsDceTask>, TaskProvider<KotlinJsDceTask>> {
|
||||
val dceTaskProvider = configureDce(
|
||||
compilation = this,
|
||||
dev = false
|
||||
)
|
||||
|
||||
val devDceTaskProvider = configureDce(
|
||||
compilation = this,
|
||||
dev = true
|
||||
)
|
||||
|
||||
return dceTaskProvider to devDceTaskProvider
|
||||
}
|
||||
|
||||
private fun configureRun(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDceTask>,
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinJsDcePlugin
|
||||
Reference in New Issue
Block a user