| description = 'Kotlin Standard Library for JVM' |
| |
| apply plugin: 'kotlin-platform-jvm' |
| |
| archivesBaseName = 'kotlin-stdlib' |
| |
| JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_8) |
| |
| configurePublishing(project) |
| configureJavadocJar() |
| configureSourcesJar() |
| |
| configurations { |
| distSources |
| } |
| |
| sourceSets { |
| compileOnlyDeclarations { |
| java { |
| srcDir 'compileOnly' |
| } |
| } |
| main { |
| java { |
| srcDir "${rootDir}/core/builtins/src" |
| srcDir 'runtime' |
| srcDir 'src' |
| } |
| } |
| mainJdk7 { |
| kotlin { |
| srcDir '../jdk7/src' |
| } |
| } |
| mainJdk8 { |
| kotlin { |
| srcDir '../jdk8/src' |
| } |
| } |
| test { |
| kotlin { |
| srcDir 'test' |
| srcDir '../jdk7/test' |
| srcDir '../jdk8/test' |
| } |
| } |
| longRunningTest { |
| kotlin { |
| srcDir 'testLongRunning' |
| } |
| } |
| java9 { |
| 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') |
| } |
| |
| jar { |
| dependsOn(configurations.builtins) |
| manifestAttributes(manifest, project, 'Main', true) |
| from { |
| zipTree(configurations.builtins.singleFile) |
| } |
| from sourceSets.mainJdk7.output |
| from sourceSets.mainJdk8.output |
| from sourceSets.java9.output |
| } |
| |
| sourcesJar { |
| from "${rootDir}/core/builtins/native" |
| from(sourceSets.mainJdk7.allSource) { |
| into 'jdk7' |
| } |
| from(sourceSets.mainJdk8.allSource) { |
| into 'jdk8' |
| } |
| } |
| |
| task distSourcesJar(type: Jar) { |
| dependsOn(sourcesJar, configurations.commonSources) |
| destinationDirectory = file("$buildDir/lib/dist") |
| classifier = '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(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", |
| "-XXLanguage:+RangeUntilOperator", |
| "-Xno-new-java-annotation-targets", |
| "-Xuse-old-innerclasses-logic", |
| ] |
| 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", |
| "-XXLanguage:+RangeUntilOperator", |
| "-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" |
| } |
| |
| configureFrontendIr(project) |
| |
| task longRunningTest(type: 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) |
| } |