[stdlib-mpp] Remove stdlib projects no longer included in build
This commit is contained in:
committed by
Space Team
parent
222f996d45
commit
93b107000a
@@ -1,206 +0,0 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js(IR) {
|
||||
nodejs {
|
||||
testTask(Action {
|
||||
useMocha {
|
||||
timeout = "10s"
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val unimplementedNativeBuiltIns =
|
||||
(file("$rootDir/core/builtins/native/kotlin/").list().toSortedSet() - file("$rootDir/libraries/stdlib/js-ir/builtins/").list())
|
||||
.map { "core/builtins/native/kotlin/$it" }
|
||||
|
||||
// Required to compile native builtins with the rest of runtime
|
||||
val builtInsHeader = """@file:Suppress(
|
||||
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
|
||||
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
|
||||
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
|
||||
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
|
||||
"WRONG_MODIFIER_TARGET",
|
||||
"UNUSED_PARAMETER"
|
||||
)
|
||||
"""
|
||||
|
||||
val commonMainSources by task<Sync> {
|
||||
dependsOn(":prepare:build.version:writeStdlibVersion")
|
||||
|
||||
val sources = listOf(
|
||||
"libraries/stdlib/common/src/",
|
||||
"libraries/stdlib/src/kotlin/",
|
||||
"libraries/stdlib/unsigned/"
|
||||
)
|
||||
|
||||
sources.forEach { path ->
|
||||
from("$rootDir/$path") {
|
||||
into(path.dropLastWhile { it != '/' })
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/commonMainSources")
|
||||
}
|
||||
|
||||
val jsMainSources by task<Sync> {
|
||||
val sources = listOf(
|
||||
"core/builtins/src/kotlin/",
|
||||
"libraries/stdlib/js/src/",
|
||||
"libraries/stdlib/js/runtime/"
|
||||
) + unimplementedNativeBuiltIns
|
||||
|
||||
val excluded = listOf(
|
||||
// stdlib/js/src/generated is used exclusively for current `js-v1` backend.
|
||||
"libraries/stdlib/js/src/generated/**",
|
||||
"libraries/stdlib/js/src/kotlin/browser",
|
||||
"libraries/stdlib/js/src/kotlin/dom",
|
||||
"libraries/stdlib/js/src/org.w3c",
|
||||
"libraries/stdlib/js/src/kotlinx",
|
||||
|
||||
// JS-specific optimized version of emptyArray() already defined
|
||||
"core/builtins/src/kotlin/ArrayIntrinsics.kt"
|
||||
)
|
||||
|
||||
sources.forEach { path ->
|
||||
from("$rootDir/$path") {
|
||||
into(path.dropLastWhile { it != '/' })
|
||||
excluded.filter { it.startsWith(path) }.forEach {
|
||||
exclude(it.substring(path.length))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/jsMainSources")
|
||||
|
||||
val unimplementedNativeBuiltIns = unimplementedNativeBuiltIns
|
||||
val buildDir = buildDir
|
||||
val builtInsHeader = builtInsHeader
|
||||
doLast {
|
||||
unimplementedNativeBuiltIns.forEach { path ->
|
||||
val file = File("$buildDir/jsMainSources/$path")
|
||||
val sourceCode = builtInsHeader + file.readText()
|
||||
file.writeText(sourceCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val commonTestSources by task<Sync> {
|
||||
val sources = listOf(
|
||||
"libraries/stdlib/test/",
|
||||
"libraries/stdlib/common/test/"
|
||||
)
|
||||
|
||||
sources.forEach { path ->
|
||||
from("$rootDir/$path") {
|
||||
into(path.dropLastWhile { it != '/' })
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/commonTestSources")
|
||||
}
|
||||
|
||||
val jsTestSources by task<Sync> {
|
||||
from("$rootDir/libraries/stdlib/js/test/")
|
||||
into("$buildDir/jsTestSources")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
named("commonMain") {
|
||||
kotlin.srcDir(files(commonMainSources.map { it.destinationDir }))
|
||||
}
|
||||
named("jsMain") {
|
||||
kotlin.srcDir(files(jsMainSources.map { it.destinationDir }))
|
||||
if (!kotlinBuildProperties.isInIdeaSync)
|
||||
kotlin.srcDir("builtins")
|
||||
if (!kotlinBuildProperties.isInIdeaSync)
|
||||
kotlin.srcDir("runtime")
|
||||
if (!kotlinBuildProperties.isInIdeaSync)
|
||||
kotlin.srcDir("src")
|
||||
}
|
||||
named("commonTest") {
|
||||
dependencies {
|
||||
api(project(":kotlin-test:kotlin-test-js-ir"))
|
||||
}
|
||||
kotlin.srcDir(files(commonTestSources.map { it.destinationDir }))
|
||||
}
|
||||
named("jsTest") {
|
||||
dependencies {
|
||||
api(project(":kotlin-test:kotlin-test-js-ir"))
|
||||
}
|
||||
kotlin.srcDir(files(jsTestSources.map { it.destinationDir }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile<*>>().configureEach {
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xallow-kotlin-package",
|
||||
"-opt-in=kotlin.ExperimentalMultiplatform",
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
)
|
||||
}
|
||||
|
||||
val compileKotlinJs by tasks.existing(KotlinCompile::class) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xir-module-name=kotlin"
|
||||
|
||||
if (!kotlinBuildProperties.disableWerror) {
|
||||
kotlinOptions.allWarningsAsErrors = true
|
||||
}
|
||||
}
|
||||
|
||||
val compileTestKotlinJs by tasks.existing(KotlinCompile::class) {
|
||||
val sources: FileCollection = kotlin.sourceSets["commonTest"].kotlin
|
||||
doFirst {
|
||||
// Note: common test sources are copied to the actual source directory by commonMainSources task,
|
||||
// so can't do this at configuration time:
|
||||
kotlinOptions.freeCompilerArgs += "-Xcommon-sources=${sources.joinToString(",")}"
|
||||
}
|
||||
}
|
||||
|
||||
val packFullRuntimeKLib by tasks.registering(Jar::class) {
|
||||
dependsOn(compileKotlinJs)
|
||||
from(buildDir.resolve("classes/kotlin/js/main"))
|
||||
destinationDirectory.set(rootProject.buildDir.resolve("js-ir-runtime"))
|
||||
archiveFileName.set("full-runtime.klib")
|
||||
}
|
||||
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
dependsOn(jsMainSources)
|
||||
val jsMainSourcesDir = jsMainSources.get().destinationDir
|
||||
archiveClassifier.set("sources")
|
||||
includeEmptyDirs = false
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
from("${rootDir}/core/builtins/native/kotlin") {
|
||||
into("kotlin")
|
||||
include("Comparable.kt")
|
||||
include("Enum.kt")
|
||||
}
|
||||
from("$jsMainSourcesDir/core/builtins/native") {
|
||||
exclude("kotlin/Comparable.kt")
|
||||
}
|
||||
from("$jsMainSourcesDir/core/builtins/src")
|
||||
from("$jsMainSourcesDir/libraries/stdlib/js/src")
|
||||
from("builtins") {
|
||||
into("kotlin")
|
||||
exclude("Enum.kt")
|
||||
}
|
||||
from("runtime") {
|
||||
into("runtime")
|
||||
}
|
||||
from("src") {
|
||||
include("**/*.kt")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,386 +0,0 @@
|
||||
plugins {
|
||||
id "com.github.node-gradle.node" version "5.0.0"
|
||||
}
|
||||
|
||||
description = 'Kotlin Standard Library for JS'
|
||||
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
apply plugin: 'idea'
|
||||
|
||||
RepoArtifacts.publish(project)
|
||||
RepoArtifacts.javadocJar(project)
|
||||
|
||||
configurations {
|
||||
sources
|
||||
commonSources
|
||||
distSources
|
||||
distJs
|
||||
distLibrary
|
||||
}
|
||||
|
||||
def builtinsSrcDir = "${buildDir}/builtin-sources"
|
||||
def builtinsSrcDir2 = "${buildDir}/builtin-sources-for-builtins"
|
||||
def jsCommonDir = "${projectDir}/../js"
|
||||
|
||||
def builtinsDir = "${rootDir}/core/builtins"
|
||||
|
||||
def jsSrcDir = "src"
|
||||
def jsCommonSrcDir = "${jsCommonDir}/src"
|
||||
def jsTestSrcDir = "test"
|
||||
def jsCommonTestSrcDir = "${jsCommonDir}/test"
|
||||
|
||||
def jsSrcJsDir = "${jsSrcDir}/js"
|
||||
def jsOutputFileName = "${buildDir}/classes/kotlin.js"
|
||||
def jsOutputMapFileName = "${jsOutputFileName}.map"
|
||||
def jsOutputMetaFileName = "${buildDir}/classes/kotlin.meta.js"
|
||||
|
||||
def kotlinTestJsOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/main/kotlin-test.js"
|
||||
|
||||
// TODO: take from sourcesets' outputs
|
||||
def jsTestOutputFile = "${buildDir}/classes/kotlin/test/kotlin-stdlib-js_test.js"
|
||||
def kotlinTestJsTestOutputFile = "${project(':kotlin-test:kotlin-test-js').buildDir}/classes/kotlin/test/kotlin-test-js_test.js"
|
||||
|
||||
sourceSets {
|
||||
builtins {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir builtinsSrcDir2
|
||||
srcDir "${jsCommonDir}/runtime"
|
||||
srcDir 'runtime'
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir builtinsSrcDir
|
||||
srcDir jsCommonSrcDir
|
||||
srcDir jsSrcDir
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir jsTestSrcDir
|
||||
srcDir jsCommonTestSrcDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":kotlin-stdlib-common")
|
||||
commonSources project(path: ":kotlin-stdlib-common", configuration: "sources")
|
||||
testApi(project(':kotlin-test:kotlin-test-js')) {
|
||||
exclude(group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib')
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("prepareComparableSource", Copy) {
|
||||
def fs = services.get(FileSystemOperations)
|
||||
doFirst {
|
||||
fs.delete {
|
||||
delete builtinsSrcDir2
|
||||
}
|
||||
}
|
||||
from("${builtinsDir}/native/kotlin") {
|
||||
include "Comparable.kt"
|
||||
}
|
||||
into builtinsSrcDir2
|
||||
}
|
||||
|
||||
tasks.register("prepareBuiltinsSources", Copy) {
|
||||
def fs = services.get(FileSystemOperations)
|
||||
doFirst {
|
||||
fs.delete {
|
||||
delete builtinsSrcDir
|
||||
}
|
||||
}
|
||||
from("${builtinsDir}/native/kotlin") {
|
||||
include "Iterator.kt"
|
||||
include "Collections.kt"
|
||||
include "CharSequence.kt"
|
||||
include "Annotation.kt"
|
||||
}
|
||||
from("${builtinsDir}/src/kotlin/") {
|
||||
include "annotation/Annotations.kt"
|
||||
include "Function.kt"
|
||||
include "Unit.kt"
|
||||
}
|
||||
into builtinsSrcDir
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile) {
|
||||
kotlinOptions {
|
||||
main = "noCall"
|
||||
moduleKind = "commonjs"
|
||||
freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
compileBuiltinsKotlin2Js {
|
||||
dependsOn prepareComparableSource
|
||||
kotlinOptions {
|
||||
metaInfo = false
|
||||
outputFile = "${buildDir}/classes/builtins/kotlin.js"
|
||||
sourceMap = true
|
||||
sourceMapPrefix = "./"
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin2Js {
|
||||
dependsOn prepareBuiltinsSources
|
||||
kotlinOptions {
|
||||
outputFile = "${buildDir}/classes/main/kotlin.js"
|
||||
sourceMap = true
|
||||
freeCompilerArgs += [
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalMultiplatform",
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xforce-deprecated-legacy-compiler-usage"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
compileTestKotlin2Js {
|
||||
kotlinOptions {
|
||||
moduleKind = "umd"
|
||||
freeCompilerArgs += [
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("compileJs", NoDebugJavaExec) {
|
||||
dependsOn compileBuiltinsKotlin2Js, compileKotlin2Js
|
||||
inputs.files(compileBuiltinsKotlin2Js.outputs.files).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.files(compileKotlin2Js.outputs.files).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir(jsSrcDir).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir(jsCommonSrcDir).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
outputs.file(jsOutputFileName)
|
||||
outputs.file(jsOutputMapFileName)
|
||||
outputs.file(jsOutputMetaFileName)
|
||||
outputs.cacheIf { true }
|
||||
|
||||
def inputFiles = fileTree(jsSrcJsDir) {
|
||||
include '**/*.js'
|
||||
}
|
||||
|
||||
mainClass = "org.jetbrains.kotlin.cli.js.internal.JSStdlibLinker"
|
||||
|
||||
// local variables for configuration cache work
|
||||
def rootDir = rootDir
|
||||
def projectDir = projectDir
|
||||
|
||||
def compileBuiltinsKotlin2JsFiles = compileBuiltinsKotlin2Js.destinationDirectory
|
||||
def compileKotlin2JsFiles = compileKotlin2Js.destinationDirectory
|
||||
doFirst {
|
||||
args = [jsOutputFileName, rootDir, "$jsSrcDir/wrapper.js"] + inputFiles.collect { it.path }.sort() +
|
||||
(compileBuiltinsKotlin2JsFiles.asFileTree.files.sort() +
|
||||
compileKotlin2JsFiles.asFileTree.files.sort()).findAll {
|
||||
it.name.endsWith(".js") && !it.name.endsWith(".meta.js")
|
||||
}
|
||||
}
|
||||
classpath = configurations.kotlinCompilerClasspath
|
||||
|
||||
def sourceMapFile = file(jsOutputMapFileName)
|
||||
def jsOutputMetaFile = file(jsOutputMetaFileName)
|
||||
def compileMetaFile = file(compileKotlin2Js.outputFileProperty.map { it.path.replaceAll('\\.js$', '.meta.js') })
|
||||
def mainJsOutputDir = compileKotlin2Js.destinationDirectory
|
||||
doLast {
|
||||
ant.replaceregexp(
|
||||
file: jsOutputFileName,
|
||||
match: "module.exports,\\s*require\\([^)]+\\)",
|
||||
replace: "",
|
||||
byline: "true", encoding: "UTF-8")
|
||||
ant.replaceregexp(
|
||||
file: jsOutputFileName,
|
||||
match: "function\\s*\\(_,\\s*Kotlin\\)",
|
||||
replace: "function()",
|
||||
byline: "true", encoding: "UTF-8")
|
||||
ant.replaceregexp(
|
||||
file: jsOutputFileName,
|
||||
match: "return\\s+_;",
|
||||
replace: "",
|
||||
byline: "true", encoding: "UTF-8")
|
||||
|
||||
def sourceMap = new groovy.json.JsonSlurper().parseText(sourceMapFile.text)
|
||||
|
||||
def sourceMapSourcesBaseDirs = [mainJsOutputDir.get(), "${jsCommonDir}/runtime", projectDir, rootDir]
|
||||
|
||||
sourceMap.sourcesContent = sourceMap.sources.collect { sourceName ->
|
||||
def text = sourceMapSourcesBaseDirs.collect { new File("$it/$sourceName") }.find { it.exists() }?.text
|
||||
if (text == null) logger.warn("Sources missing for file $sourceName")
|
||||
text
|
||||
}
|
||||
|
||||
def sourceMapBasePaths = [
|
||||
"../../../../",
|
||||
"../../../",
|
||||
"../../",
|
||||
"./",
|
||||
"libraries/stdlib/js-v1/src/"
|
||||
]
|
||||
def shortPaths = sourceMap.sources.collect { sourcePath ->
|
||||
def prefixToRemove = sourceMapBasePaths.find { basePath -> sourcePath.startsWith(basePath) }
|
||||
if (prefixToRemove != null) sourcePath.substring(prefixToRemove.length()) else sourcePath
|
||||
}
|
||||
if (shortPaths.size != shortPaths.toUnique().size) {
|
||||
logger.warn("Duplicate source file names found:\n${sourceMap.sources.toSorted().join("\n")}")
|
||||
}
|
||||
sourceMap.sources = shortPaths
|
||||
|
||||
sourceMapFile.text = groovy.json.JsonOutput.toJson(sourceMap)
|
||||
|
||||
jsOutputMetaFile.text = compileMetaFile.text
|
||||
}
|
||||
}
|
||||
|
||||
classes.dependsOn compileJs
|
||||
|
||||
|
||||
jar {
|
||||
enabled false
|
||||
}
|
||||
|
||||
tasks.register("libraryJarWithoutIr", Jar) {
|
||||
dependsOn(compileJs)
|
||||
archiveClassifier = null
|
||||
LibrariesCommon.manifestAttributes(project, manifest, 'Main')
|
||||
destinationDirectory = file("$buildDir/lib/dist")
|
||||
|
||||
// TODO: Use standard implementation title after js stdlib detector becomes more flexible (KT-17655)
|
||||
Properties properties = new Properties()
|
||||
new File("${rootDir}/resources/kotlinManifest.properties").withInputStream {
|
||||
properties.load(it)
|
||||
}
|
||||
manifest.attributes 'Implementation-Title': properties."manifest.impl.title.kotlin.javascript.stdlib"
|
||||
|
||||
includeEmptyDirs false
|
||||
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||
from jsOutputFileName
|
||||
from jsOutputMetaFileName
|
||||
from "${jsOutputFileName}.map"
|
||||
from sourceSets.main.kotlin.classesDirectory
|
||||
filesMatching("*.*") { it.mode = 0b110100100 } // KTI-401
|
||||
}
|
||||
|
||||
tasks.register("libraryJarWithIr", Zip) {
|
||||
dependsOn(libraryJarWithoutIr)
|
||||
archiveExtension = "jar"
|
||||
destinationDirectory = file("$buildDir/libs")
|
||||
|
||||
duplicatesStrategy DuplicatesStrategy.FAIL
|
||||
|
||||
def archiveOperations = services.get(ArchiveOperations)
|
||||
from { libraryJarWithoutIr.archiveFile.map {archiveOperations.zipTree(it) } }
|
||||
dependsOn(":kotlin-stdlib-js-ir:compileKotlinJs")
|
||||
from {
|
||||
def irKlib = tasks.getByPath(":kotlin-stdlib-js-ir:compileKotlinJs")
|
||||
fileTree(irKlib.outputs.files.first().path)
|
||||
}
|
||||
filesMatching("*.*") { it.mode = 0b110100100 } // KTI-401
|
||||
}
|
||||
|
||||
jar.dependsOn(libraryJarWithIr)
|
||||
|
||||
tasks.register("sourcesJar", Jar) {
|
||||
dependsOn(compileJs)
|
||||
dependsOn(":kotlin-stdlib-js-ir:sourcesJar")
|
||||
archiveClassifier.set('sources')
|
||||
includeEmptyDirs false
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
from({
|
||||
def irSources = tasks.getByPath(":kotlin-stdlib-js-ir:sourcesJar")
|
||||
zipTree(irSources.outputs.files.first().path)
|
||||
}) {
|
||||
exclude 'META-INF/*'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("distSourcesJar", Jar) {
|
||||
dependsOn(sourcesJar, configurations.commonSources)
|
||||
destinationDirectory = file("$buildDir/lib/dist")
|
||||
archiveClassifier.set('sources')
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
from zipTree(sourcesJar.outputs.files.singleFile)
|
||||
|
||||
from(zipTree(configurations.commonSources.singleFile)) {
|
||||
it.includeEmptyDirs = false
|
||||
exclude 'META-INF/*'
|
||||
into 'common'
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
publishedRuntime libraryJarWithIr
|
||||
publishedRuntime sourcesJar
|
||||
sources sourcesJar
|
||||
distSources distSourcesJar
|
||||
distLibrary libraryJarWithIr
|
||||
|
||||
compileJs.outputs.files.forEach { artifact ->
|
||||
distJs(artifact) { builtBy(compileJs) }
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
download = true
|
||||
version = RepoDependencies.getNodejsVersion(project)
|
||||
nodeProjectDir = buildDir
|
||||
}
|
||||
|
||||
// Otherwise Node ignores nodeModulesDir
|
||||
tasks.register("deleteLegacyNodeModules", Delete) {
|
||||
delete "$projectDir/node_modules"
|
||||
}
|
||||
|
||||
tasks.register("installMocha", NpmTask) {
|
||||
dependsOn(deleteLegacyNodeModules)
|
||||
args = ['install', 'mocha@8.0.1']
|
||||
}
|
||||
|
||||
tasks.register("installTeamcityReporter", NpmTask) {
|
||||
dependsOn(deleteLegacyNodeModules)
|
||||
args = ['install', 'mocha-teamcity-reporter@3.0.0']
|
||||
}
|
||||
|
||||
tasks.register("runMocha", NodeTask) {
|
||||
dependsOn(testClasses, installMocha, ':kotlin-test:kotlin-test-js:testClasses')
|
||||
script = file("${buildDir}/node_modules/mocha/bin/mocha")
|
||||
|
||||
if (project.hasProperty("teamcity")) {
|
||||
dependsOn installTeamcityReporter
|
||||
args = ['--reporter', 'mocha-teamcity-reporter']
|
||||
}
|
||||
else {
|
||||
args = ['--reporter', 'min']
|
||||
}
|
||||
|
||||
args = args.get() + ['--timeout', '10s']
|
||||
args = args.get() + [jsTestOutputFile, kotlinTestJsTestOutputFile]
|
||||
|
||||
execOverrides {
|
||||
it.ignoreExitValue = rootProject.ignoreTestFailures
|
||||
it.environment('NODE_PATH', [file(jsOutputFileName).parent, file(kotlinTestJsOutputFile).parent].join(File.pathSeparator))
|
||||
it.workingDir = buildDir
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
if (BuildPropertiesExtKt.getKotlinStdlibMpp(project.kotlinBuildProperties)) {
|
||||
afterEvaluate {
|
||||
tasks.withType(AbstractPublishToMaven).configureEach {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
plugins {
|
||||
id("kotlin-platform-jvm")
|
||||
}
|
||||
|
||||
description = 'Kotlin Standard Library for JVM'
|
||||
|
||||
archivesBaseName = 'kotlin-stdlib'
|
||||
|
||||
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_8)
|
||||
|
||||
RepoArtifacts.publish(project)
|
||||
RepoArtifacts.javadocJar(project)
|
||||
RepoArtifacts.sourcesJar(project)
|
||||
|
||||
configurations {
|
||||
distSources
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
compileOnlyDeclarations {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
java {
|
||||
srcDir 'compileOnly'
|
||||
}
|
||||
}
|
||||
main {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
java {
|
||||
srcDir "${rootDir}/core/builtins/src"
|
||||
srcDir 'runtime'
|
||||
srcDir 'src'
|
||||
}
|
||||
}
|
||||
mainJdk7 {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir '../jdk7/src'
|
||||
}
|
||||
}
|
||||
mainJdk8 {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir '../jdk8/src'
|
||||
}
|
||||
}
|
||||
test {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir 'test'
|
||||
srcDir '../jdk7/test'
|
||||
srcDir '../jdk8/test'
|
||||
}
|
||||
}
|
||||
longRunningTest {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
kotlin {
|
||||
srcDir 'testLongRunning'
|
||||
}
|
||||
}
|
||||
java9 {
|
||||
if (!BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync)
|
||||
java {
|
||||
srcDir 'java9'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LibrariesCommon.configureJava9Compilation(project, 'kotlin.stdlib', [sourceSets.main.output, sourceSets.mainJdk7.output, sourceSets.mainJdk8.output])
|
||||
|
||||
configurations {
|
||||
commonSources
|
||||
longRunningTestCompile.extendsFrom(testCompile)
|
||||
builtins {
|
||||
attributes {
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
|
||||
}
|
||||
}
|
||||
compileOnly.extendsFrom(builtins)
|
||||
mainJdk7CompileOnly.extendsFrom(compileClasspath)
|
||||
mainJdk8CompileOnly.extendsFrom(compileClasspath)
|
||||
testCompileOnly.extendsFrom(builtins)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":kotlin-stdlib-common")
|
||||
|
||||
commonSources project(path: ":kotlin-stdlib-common", configuration: "sources")
|
||||
|
||||
api group: 'org.jetbrains', name: 'annotations', version:'13.0'
|
||||
|
||||
compileOnly sourceSets.compileOnlyDeclarations.output
|
||||
mainJdk7Api sourceSets.main.output
|
||||
mainJdk8Api sourceSets.main.output
|
||||
mainJdk8Api sourceSets.mainJdk7.output
|
||||
|
||||
testApi project(':kotlin-test:kotlin-test-junit')
|
||||
if (BuildPropertiesKt.getKotlinBuildProperties(project).inIdeaSync) {
|
||||
testCompileOnly sourceSets.mainJdk7.output
|
||||
testCompileOnly sourceSets.mainJdk8.output
|
||||
}
|
||||
|
||||
builtins project(':core:builtins')
|
||||
}
|
||||
|
||||
tasks.named("jar", Jar) {
|
||||
dependsOn(configurations.builtins)
|
||||
LibrariesCommon.manifestAttributes(project, manifest, 'Main', true)
|
||||
from {
|
||||
zipTree(configurations.builtins.singleFile)
|
||||
}
|
||||
from sourceSets.mainJdk7.output
|
||||
from sourceSets.mainJdk8.output
|
||||
from sourceSets.java9.output
|
||||
}
|
||||
|
||||
tasks.named("sourcesJar", Jar) {
|
||||
from "${rootDir}/core/builtins/native"
|
||||
from(sourceSets.mainJdk7.allSource) {
|
||||
into 'jdk7'
|
||||
}
|
||||
from(sourceSets.mainJdk8.allSource) {
|
||||
into 'jdk8'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("distSourcesJar", Jar) {
|
||||
dependsOn(sourcesJar, configurations.commonSources)
|
||||
destinationDirectory = file("$buildDir/lib/dist")
|
||||
archiveClassifier.set('sources')
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
|
||||
from zipTree(sourcesJar.outputs.files.singleFile)
|
||||
|
||||
from(zipTree(configurations.commonSources.singleFile)) {
|
||||
it.includeEmptyDirs = false
|
||||
exclude 'META-INF/*'
|
||||
into 'common'
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
sources sourcesJar
|
||||
distSources distSourcesJar
|
||||
}
|
||||
|
||||
DexMethodCountKt.dexMethodCount(project) { task ->
|
||||
task.from(tasks.named("jar", Jar))
|
||||
task.ownPackages = ['kotlin']
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinJavaToolchain.toolchain.use(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_1_6))
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalMultiplatform",
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
"-Xuse-14-inline-classes-mangling-scheme",
|
||||
"-Xbuiltins-from-sources",
|
||||
"-Xno-new-java-annotation-targets",
|
||||
]
|
||||
moduleName = "kotlin-stdlib"
|
||||
}
|
||||
}
|
||||
|
||||
compileMainJdk7Kotlin {
|
||||
kotlinJavaToolchain.toolchain.use(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_1_7))
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xno-new-java-annotation-targets",
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||
]
|
||||
kotlinOptions.moduleName = "kotlin-stdlib-jdk7"
|
||||
}
|
||||
|
||||
compileMainJdk8Kotlin {
|
||||
kotlinOptions.freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xno-new-java-annotation-targets",
|
||||
]
|
||||
kotlinOptions.moduleName = "kotlin-stdlib-jdk8"
|
||||
}
|
||||
|
||||
compileCompileOnlyDeclarationsKotlin {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += [
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.path.ExperimentalPathApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-Xallow-kotlin-package", // TODO: maybe rename test packages
|
||||
]
|
||||
if (project.kotlinBuildProperties.useFir) {
|
||||
freeCompilerArgs += "-Xuse-k2"
|
||||
}
|
||||
// This is needed for JavaTypeTest; typeOf for non-reified type parameters doesn't work otherwise, for implementation reasons.
|
||||
def args = new ArrayList(freeCompilerArgs)
|
||||
args.remove("-Xno-optimized-callable-references")
|
||||
freeCompilerArgs = args
|
||||
}
|
||||
}
|
||||
|
||||
[JdkMajorVersion.JDK_9_0, JdkMajorVersion.JDK_10_0, JdkMajorVersion.JDK_11_0].forEach { jvmVersion ->
|
||||
check.dependsOn(tasks.register("jdk${jvmVersion.majorVersion}Test", Test) { thisTask ->
|
||||
group = "verification"
|
||||
thisTask.javaLauncher.set(JvmToolchain.getToolchainLauncherFor(project, jvmVersion))
|
||||
})
|
||||
}
|
||||
|
||||
compileLongRunningTestKotlin {
|
||||
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.ExperimentalStdlibApi"
|
||||
}
|
||||
|
||||
LibrariesCommon.configureFrontendIr(project)
|
||||
|
||||
tasks.register("longRunningTest", Test) {
|
||||
dependsOn(longRunningTestClasses)
|
||||
group = "verification"
|
||||
testClassesDirs = sourceSets.longRunningTest.output.classesDirs
|
||||
classpath = sourceSets.longRunningTest.runtimeClasspath
|
||||
}
|
||||
|
||||
if (project.hasProperty("kotlin.stdlib.test.long.running")) {
|
||||
check.dependsOn(longRunningTest)
|
||||
}
|
||||
Reference in New Issue
Block a user