Merge kotlin-experimental into kotlin standard library (KT-23055 fixed)

* kotlin-experimental.js has been already merged into kotlin.js
* change library name to kotlin in kotlin-experimental.meta.js in order to produce correct require calls
* concatenate kotlin-experimental.meta.js with kotlin.meta.js
* suppress multiple module declaration warning for such use case
This commit is contained in:
Anton Bannykh
2018-03-21 14:11:08 +03:00
committed by Anton Bannykh
parent d0e71acaa5
commit 7b860eab36
8 changed files with 20 additions and 18 deletions
@@ -4,7 +4,5 @@ kotlinProject/
kotlinProject.js
kotlinProject.meta.js
lib/
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
@@ -11,8 +11,6 @@ kotlinProject/
file0.js
jslib-example.js
jslib-example.meta.js
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
res0.js
@@ -4,7 +4,5 @@ kotlinProject/
kotlinProject.js
kotlinProject.meta.js
lib/
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
@@ -11,8 +11,6 @@ kotlinProject/
file0.js
jslib-example.js
jslib-example.meta.js
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
res0.js
@@ -7,8 +7,6 @@ kotlinProject/
file0.js
jslib-example.js
jslib-example.meta.js
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
res0.js
@@ -4,14 +4,10 @@ kotlinProject/
kotlinProject.js
kotlinProject.meta.js
lib/
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
module2/
lib/
kotlin-experimental.js
kotlin-experimental.meta.js
kotlin.js
kotlin.meta.js
module2/
@@ -202,6 +202,8 @@ public class JsConfig {
continue;
}
Set<String> moduleNames = new LinkedHashSet<>();
for (KotlinJavascriptMetadata metadata : metadataList) {
if (!metadata.getVersion().isCompatible() && !skipMetadataVersionCheck) {
report.error("File '" + path + "' was compiled with an incompatible version of Kotlin. " +
@@ -209,8 +211,13 @@ public class JsConfig {
", expected version is " + JsMetadataVersion.INSTANCE);
return true;
}
if (!modules.add(metadata.getModuleName())) {
report.warning("Module \"" + metadata.getModuleName() + "\" is defined in more than one file");
moduleNames.add(metadata.getModuleName());
}
for (String moduleName : moduleNames) {
if (!modules.add(moduleName)) {
report.warning("Module \"" + moduleName + "\" is defined in more than one file");
}
}
+11 -2
View File
@@ -17,11 +17,13 @@ def commonSrcDir = "${buildDir}/common-sources"
def commonTestSrcDir = "${buildDir}/common-test-sources"
def builtinsDir = "${rootDir}/core/builtins"
def experimentalSrcDir = "${rootDir}/libraries/stdlib/experimental"
def experimentalJsModuleName = 'kotlin-experimental'
def jsSrcGeneratedDir = "${rootDir}/js/js.libraries/src/core/generated" // to be removed soon
def jsSrcDir = "src"
def jsTestSrcDir = "test"
def jsSrcJsDir = "${jsSrcDir}/js"
def jsOutputFile = "${buildDir}/classes/kotlin.js"
def jsOutputMetaFile = "${buildDir}/classes/kotlin.meta.js"
def kotlinTestJsOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/main/kotlin-test.js"
@@ -147,7 +149,7 @@ compileExperimentalKotlin2Js {
kotlinOptions {
languageVersion = "1.3"
apiVersion = "1.3"
outputFile = "${buildDir}/classes/main/kotlin-experimental.js"
outputFile = "${buildDir}/classes/experimental/${experimentalJsModuleName}.js"
sourceMap = true
sourceMapPrefix = "./"
freeCompilerArgs += ["-source-map-base-dirs", [experimentalSrcDir].join(File.pathSeparator)]
@@ -215,7 +217,7 @@ task compileJs(type: JavaExec) {
if (prefixToRemove != null) sourcePath.substring(prefixToRemove.length()) else sourcePath
}
def sourceMapSourcesBaseDirs = [jsSrcDir, jsSrcJsDir, jsSrcGeneratedDir, builtinsSrcDir, commonSrcDir, projectDir]
def sourceMapSourcesBaseDirs = [jsSrcDir, jsSrcJsDir, jsSrcGeneratedDir, builtinsSrcDir, commonSrcDir, projectDir, experimentalSrcDir]
sourceMap.sourcesContent = sourceMap.sources.collect { sourceName ->
def text = sourceMapSourcesBaseDirs.collect { file("$it/$sourceName") }.find { it.exists() }?.text
@@ -224,6 +226,10 @@ task compileJs(type: JavaExec) {
}
sourceMapFile.text = groovy.json.JsonOutput.toJson(sourceMap)
file(jsOutputMetaFile).text = file(compileKotlin2Js.outputFile.path.replaceAll('\\.js$', '.meta.js')).text +
file(compileExperimentalKotlin2Js.outputFile.path.replaceAll('\\.js$', '.meta.js')).text
.replaceFirst(experimentalJsModuleName, 'kotlin')
}
}
@@ -248,8 +254,11 @@ task mergedJar(type: Jar, dependsOn: classes) {
includeEmptyDirs false
duplicatesStrategy DuplicatesStrategy.EXCLUDE
from jsOutputFile
from jsOutputMetaFile
from "${jsOutputFile}.map"
from sourceSets.main.output
from sourceSets.experimental.output
exclude "${experimentalJsModuleName}.*"
}
task sourcesJar(type: Jar, dependsOn: classes) {