mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-04 00:21:30 +00:00
Compare commits
32 Commits
abannykh/n
...
v1.2-beta2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a3a4df93a | ||
|
|
2f1d4c15c9 | ||
|
|
4c3b9d58fb | ||
|
|
46b005bafc | ||
|
|
5d4d444f97 | ||
|
|
7a5051128a | ||
|
|
fa2d276718 | ||
|
|
7b873eb8ce | ||
|
|
979c7c06ef | ||
|
|
6e0e4a634e | ||
|
|
c7bc8b280c | ||
|
|
d363f5be7e | ||
|
|
e8b944ebbf | ||
|
|
ead2cb374a | ||
|
|
ba040ebd61 | ||
|
|
f3921a3d24 | ||
|
|
2d50bef4f7 | ||
|
|
323ec39ac6 | ||
|
|
acb2850260 | ||
|
|
0da4bf4c08 | ||
|
|
765fe92165 | ||
|
|
ed4f3d3bf6 | ||
|
|
7e49e17ce5 | ||
|
|
5052ae5cf8 | ||
|
|
24e218afc8 | ||
|
|
ab6360a7d5 | ||
|
|
058b832b71 | ||
|
|
b460b89df5 | ||
|
|
c7253584c5 | ||
|
|
c4e4298eac | ||
|
|
e4b4475235 | ||
|
|
7cddd345f8 |
3846
ChangeLog.md
3846
ChangeLog.md
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
|
||||
@@ -58,18 +59,23 @@ data class JvmBuildMetaInfo(
|
||||
}
|
||||
}
|
||||
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo =
|
||||
JvmBuildMetaInfo(isEAP = KotlinCompilerVersion.isPreRelease(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = args.languageVersion ?: LanguageVersion.LATEST_STABLE.versionString,
|
||||
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch)
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo {
|
||||
val languageVersion = args.languageVersion?.let((LanguageVersion)::fromVersionString) ?: LanguageVersion.LATEST_STABLE
|
||||
|
||||
return JvmBuildMetaInfo(
|
||||
isEAP = languageVersion.shouldWritePreReleaseFlag(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = languageVersion.versionString,
|
||||
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch
|
||||
)
|
||||
}
|
||||
|
||||
@@ -478,7 +478,9 @@ fun jdkPath(version: String): String = jdkPathIfFound(version)
|
||||
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.isFork = true
|
||||
options.forkOptions.javaHome = file(javaHome)
|
||||
options.compilerArgs.add("-proc:none")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
buildscript {
|
||||
val buildSrcKotlinVersion: String by extra(findProperty("buildSrc.kotlin.version")?.toString() ?: embeddedKotlinVersion)
|
||||
extra["buildSrcKotlinRepo"] = findProperty("buildSrc.kotlin.repo")
|
||||
extra["versions.shadow"] = "2.0.1"
|
||||
|
||||
repositories {
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
@@ -34,6 +35,7 @@ repositories {
|
||||
}
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-dev") // for dex-method-list
|
||||
// maven { setUrl("https://repo.gradle.org/gradle/libs-releases-local") }
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -42,6 +44,7 @@ dependencies {
|
||||
// compile("net.rubygrapefruit:native-platform:0.14")
|
||||
// TODO: adding the dep to the plugin breaks the build unexpectedly, resolve and uncomment
|
||||
// compile("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["bootstrap_kotlin_version"]}")
|
||||
compile("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||
}
|
||||
|
||||
samWithReceiver {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.ConfigurablePublishArtifact
|
||||
import org.gradle.api.artifacts.*
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ConfigurationContainer
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||
import org.gradle.api.plugins.BasePluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
@@ -61,18 +59,13 @@ fun<T> Project.runtimeJarArtifactBy(task: Task, artifactRef: T, body: Configurab
|
||||
addArtifact("runtimeJar", task, artifactRef, body)
|
||||
}
|
||||
|
||||
fun Project.buildVersion(): Dependency {
|
||||
val cfg = configurations.create("build-version")
|
||||
return dependencies.add(cfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
}
|
||||
|
||||
fun<T: Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
val buildVersionCfg = configurations.create("buildVersion")
|
||||
dependencies.add(buildVersionCfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
extra["runtimeJarTask"] = task
|
||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
||||
configurations.getOrCreate("archives").artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
|
||||
}
|
||||
return task.apply {
|
||||
setupPublicJar()
|
||||
from(buildVersionCfg) { into("META-INF") }
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
body()
|
||||
project.runtimeJarArtifactBy(this, this)
|
||||
@@ -139,7 +132,7 @@ fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit
|
||||
|
||||
task("idea-plugin") {
|
||||
dependsOn(pluginTask)
|
||||
}
|
||||
}
|
||||
|
||||
return pluginTask
|
||||
}
|
||||
|
||||
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
@@ -0,0 +1,130 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.task
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
|
||||
|
||||
val packagesToRelocate =
|
||||
listOf( "com.intellij",
|
||||
"com.google",
|
||||
"com.sampullara",
|
||||
"org.apache",
|
||||
"org.jdom",
|
||||
"org.picocontainer",
|
||||
"jline",
|
||||
"gnu",
|
||||
"org.fusesource")
|
||||
|
||||
// The shaded compiler "dummy" is used to rewrite dependencies in projects that are used with the embeddable compiler
|
||||
// on the runtime and use some shaded dependencies from the compiler
|
||||
// To speed-up rewriting process we want to have this dummy as small as possible.
|
||||
// But due to the shadow plugin bug (https://github.com/johnrengelman/shadow/issues/262) it is not possible to use
|
||||
// packagesToRelocate list to for the include list. Therefore the exclude list has to be created.
|
||||
val packagesToExcludeFromDummy =
|
||||
listOf("org/jetbrains/kotlin/**",
|
||||
"org/intellij/lang/annotations/**",
|
||||
"org/jetbrains/jps/**",
|
||||
"META-INF/**",
|
||||
"com/sun/jna/**",
|
||||
"com/thoughtworks/xstream/**",
|
||||
"javaslang/**",
|
||||
"*.proto",
|
||||
"messages/**",
|
||||
"net/sf/cglib/**",
|
||||
"one/util/streamex/**",
|
||||
"org/iq80/snappy/**",
|
||||
"org/jline/**",
|
||||
"org/json/**",
|
||||
"org/xmlpull/**",
|
||||
"*.txt")
|
||||
|
||||
private fun ShadowJar.configureEmbeddableCompilerRelocation(withJavaxInject: Boolean = true) {
|
||||
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
||||
packagesToRelocate.forEach {
|
||||
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
||||
}
|
||||
if (withJavaxInject) {
|
||||
relocate("javax.inject", "$kotlinEmbeddableRootPackage.javax.inject")
|
||||
}
|
||||
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
||||
// TODO: remove "it." after #KT-12848 get addressed
|
||||
exclude("org.fusesource.jansi.internal.CLibrary")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.compilerShadowJar(taskName: String, body: ShadowJar.() -> Unit): Jar {
|
||||
|
||||
val compilerJar = configurations.getOrCreate("compilerJar")
|
||||
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler", configuration = "runtimeJar"))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerJar)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.embeddableCompiler(taskName: String = "embeddable", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
configureEmbeddableCompilerRelocation()
|
||||
body()
|
||||
}
|
||||
|
||||
fun Project.compilerDummyForDependenciesRewriting(taskName: String = "compilerDummy", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
exclude(packagesToExcludeFromDummy)
|
||||
body()
|
||||
}
|
||||
|
||||
const val COMPILER_DUMMY_JAR_CONFIGURATION_NAME = "compilerDummyJar"
|
||||
|
||||
fun Project.compilerDummyJar(task: Jar, body: Jar.() -> Unit = {}) {
|
||||
task.body()
|
||||
addArtifact(COMPILER_DUMMY_JAR_CONFIGURATION_NAME, task, task)
|
||||
}
|
||||
|
||||
fun Project.embeddableCompilerDummyForDependenciesRewriting(taskName: String = "embeddable", body: Jar.() -> Unit = {}): Jar {
|
||||
val compilerDummyJar = configurations.getOrCreate("compilerDummyJar")
|
||||
dependencies.add(compilerDummyJar.name,
|
||||
dependencies.project(":kotlin-compiler-embeddable", configuration = COMPILER_DUMMY_JAR_CONFIGURATION_NAME))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerDummyJar)
|
||||
configureEmbeddableCompilerRelocation(withJavaxInject = false)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, body: Jar.() -> Unit = {}): Jar {
|
||||
val originalFiles by lazy {
|
||||
val jarContents = zipTree(originalJarTask.outputs.files.singleFile).files
|
||||
val basePath = jarContents.find { it.name == "MANIFEST.MF" }?.parentFile?.parentFile ?: throw GradleException("cannot determine the jar root dir")
|
||||
jarContents.map { it.relativeTo(basePath).path }.toSet()
|
||||
}
|
||||
return task<Jar>("rewrittenDepsJar") {
|
||||
originalJarTask.apply {
|
||||
classifier = "original"
|
||||
}
|
||||
shadowJarTask.apply {
|
||||
dependsOn(originalJarTask)
|
||||
from(originalJarTask)// { include("**") }
|
||||
classifier = "shadow"
|
||||
}
|
||||
dependsOn(shadowJarTask)
|
||||
from(project.zipTree(shadowJarTask.outputs.files.singleFile)) { include { originalFiles.any { originalFile -> it.file.canonicalPath.endsWith(originalFile) } } }
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedCompiler(originalJarTask: Jar, body: Jar.() -> Unit = {}): Jar =
|
||||
rewriteDepsToShadedJar(originalJarTask, embeddableCompilerDummyForDependenciesRewriting(), body)
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
@@ -37,7 +36,7 @@ fun writeKotlinMetadata(
|
||||
av.visit(JvmAnnotationNames.BYTECODE_VERSION_FIELD_NAME, JvmBytecodeBinaryVersion.INSTANCE.toArray())
|
||||
av.visit(JvmAnnotationNames.KIND_FIELD_NAME, kind.id)
|
||||
var flags = extraFlags
|
||||
if (KotlinCompilerVersion.isPreRelease() && state.languageVersionSettings.languageVersion == LanguageVersion.LATEST_STABLE) {
|
||||
if (state.languageVersionSettings.shouldWritePreReleaseFlag()) {
|
||||
flags = flags or JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG
|
||||
}
|
||||
if (flags != 0) {
|
||||
@@ -51,4 +50,4 @@ fun writeSyntheticClassMetadata(cb: ClassBuilder, state: GenerationState) {
|
||||
writeKotlinMetadata(cb, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0) { _ ->
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
description = "Compiler runner + daemon client"
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
@@ -13,6 +15,7 @@ dependencies {
|
||||
compileOnly(project(":compiler:daemon-common"))
|
||||
compile(project(":kotlin-daemon-client"))
|
||||
compileOnly(project(":compiler:util"))
|
||||
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -20,10 +23,13 @@ sourceSets {
|
||||
"test" {}
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
val jar: Jar by tasks
|
||||
jar.apply {
|
||||
from(getSourceSetsFrom(":kotlin-daemon-client")["main"].output.classesDirs)
|
||||
from(getSourceSetsFrom(":compiler:daemon-common")["main"].output.classesDirs)
|
||||
}
|
||||
|
||||
runtimeJar(rewriteDepsToShadedCompiler(jar))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
|
||||
class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVersionSettings) : DeserializationConfiguration {
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val skipMetadataVersionCheck = languageVersionSettings.getFlag(AnalysisFlag.skipMetadataVersionCheck)
|
||||
|
||||
override val skipPreReleaseCheck = skipMetadataVersionCheck || !languageVersionSettings.languageVersion.isStable
|
||||
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val isJvmPackageNameSupported = languageVersionSettings.supportsFeature(LanguageFeature.JvmPackageName)
|
||||
|
||||
override val returnsEffectAllowed: Boolean = languageVersionSettings.supportsFeature(LanguageFeature.ReturnsEffect)
|
||||
|
||||
@@ -180,12 +180,25 @@ class GenericCandidateResolver(
|
||||
|
||||
private fun getBinaryWithTypeParent(calleeExpression: KtExpression?): KtBinaryExpressionWithTypeRHS? {
|
||||
val callExpression = calleeExpression?.parent.safeAs<KtCallExpression>() ?: return null
|
||||
val parent = callExpression.parent
|
||||
return when (parent) {
|
||||
is KtBinaryExpressionWithTypeRHS -> parent
|
||||
is KtQualifiedExpression -> parent.parent.safeAs<KtBinaryExpressionWithTypeRHS>().takeIf { parent.selectorExpression == callExpression }
|
||||
else -> null
|
||||
val possibleQualifiedExpression = callExpression.parent
|
||||
|
||||
val targetExpression = if (possibleQualifiedExpression is KtQualifiedExpression) {
|
||||
if (possibleQualifiedExpression.selectorExpression != callExpression) return null
|
||||
possibleQualifiedExpression
|
||||
}
|
||||
else {
|
||||
callExpression
|
||||
}
|
||||
|
||||
return targetExpression.topParenthesizedParentOrMe().parent.safeAs<KtBinaryExpressionWithTypeRHS>()
|
||||
}
|
||||
|
||||
private fun KtExpression.topParenthesizedParentOrMe(): KtExpression {
|
||||
var result: KtExpression = this
|
||||
while (KtPsiUtil.deparenthesizeOnce(result.parent.safeAs()) == result) {
|
||||
result = result.parent.safeAs() ?: break
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addValidityConstraintsForConstituentTypes(builder: ConstraintSystem.Builder, type: KotlinType) {
|
||||
|
||||
@@ -96,9 +96,12 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
nullability: Nullability,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
typeInfo: SetMultimap<DataFlowValue, KotlinType>? = null,
|
||||
affectReceiver: Boolean = true
|
||||
affectReceiver: Boolean = true,
|
||||
recordUnstable: Boolean = true
|
||||
): Boolean {
|
||||
map.put(value, nullability)
|
||||
if (value.isStable || recordUnstable) {
|
||||
map.put(value, nullability)
|
||||
}
|
||||
|
||||
val identifierInfo = value.identifierInfo
|
||||
if (affectReceiver && !nullability.canBeNull() &&
|
||||
@@ -108,7 +111,8 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
val receiverType = identifierInfo.receiverType
|
||||
if (identifierInfo.safe && receiverType != null) {
|
||||
val receiverValue = DataFlowValue(identifierInfo.receiverInfo, receiverType)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.SafeCast -> {
|
||||
@@ -118,12 +122,16 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.SafeCastCheckBoundSmartCasts)) {
|
||||
|
||||
val subjectValue = DataFlowValue(identifierInfo.subjectInfo, subjectType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability, languageVersionSettings, typeInfo)
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = false)
|
||||
if (subjectValue.isStable) {
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
}
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.Variable -> identifierInfo.bound?.let {
|
||||
putNullabilityAndTypeInfo(map, it, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, it, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt
vendored
Normal file
21
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +ExpectedTypeFromCast
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
annotation class bar
|
||||
|
||||
fun <T> foo(): T = TODO()
|
||||
|
||||
fun <V> id(value: V) = value
|
||||
|
||||
val par1 = (foo()) as String
|
||||
val par2 = ((foo())) as String
|
||||
|
||||
val par3 = (dd@ (foo())) as String
|
||||
|
||||
val par4 = ( @bar() (foo())) as String
|
||||
|
||||
object X {
|
||||
fun <T> foo(): T = TODO()
|
||||
}
|
||||
|
||||
val par5 = ( @bar() X.foo()) as String
|
||||
24
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt
vendored
Normal file
24
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public val par1: kotlin.String
|
||||
public val par2: kotlin.String
|
||||
public val par3: kotlin.String
|
||||
public val par4: kotlin.String
|
||||
public val par5: kotlin.String
|
||||
public fun </*0*/ T> foo(): T
|
||||
public fun </*0*/ V> id(/*0*/ value: V): V
|
||||
|
||||
public object X {
|
||||
private constructor X()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T> foo(): T
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class bar : kotlin.Annotation {
|
||||
public constructor bar()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt
vendored
Normal file
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// FILE: MyAnnotation.java
|
||||
public @interface MyAnnotation {
|
||||
}
|
||||
// FILE: MyAnnoClass.java
|
||||
public class MyAnnoClass implements MyAnnotation {
|
||||
//...
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
val ann: MyAnnotation = MyAnnoClass()
|
||||
|
||||
fun foo(x: MyAnnoClass) {
|
||||
bar(x)
|
||||
}
|
||||
|
||||
fun bar(y: MyAnnotation) {
|
||||
y.hashCode()
|
||||
}
|
||||
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.txt
vendored
Normal file
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public val ann: MyAnnotation
|
||||
public fun bar(/*0*/ y: MyAnnotation): kotlin.Unit
|
||||
public fun foo(/*0*/ x: MyAnnoClass): kotlin.Unit
|
||||
|
||||
public open class MyAnnoClass : MyAnnotation {
|
||||
public constructor MyAnnoClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class MyAnnotation : kotlin.Annotation {
|
||||
public constructor MyAnnotation()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
25
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt
vendored
Normal file
25
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
// See KT-20752
|
||||
|
||||
class Unstable {
|
||||
val first: String? get() = null
|
||||
}
|
||||
|
||||
class StringList {
|
||||
fun remove(s: String) = s
|
||||
}
|
||||
|
||||
fun StringList.remove(s: String?) = s ?: ""
|
||||
|
||||
fun foo(list: StringList, arg: Unstable) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first <!USELESS_CAST!>as? String<!> != null) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(arg.first)
|
||||
}
|
||||
val s = arg.first <!USELESS_CAST!>as? String<!>
|
||||
if (s != null) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(arg.first)
|
||||
}
|
||||
}
|
||||
20
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.txt
vendored
Normal file
20
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ list: StringList, /*1*/ arg: Unstable): kotlin.Unit
|
||||
public fun StringList.remove(/*0*/ s: kotlin.String?): kotlin.String
|
||||
|
||||
public final class StringList {
|
||||
public constructor StringList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Unstable {
|
||||
public constructor Unstable()
|
||||
public final val first: kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
40
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt
vendored
Normal file
40
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +BooleanElvisBoundSmartCasts
|
||||
// See KT-20752
|
||||
|
||||
class Unstable {
|
||||
val first: String? get() = null
|
||||
}
|
||||
|
||||
class StringList {
|
||||
fun remove(s: String) = s
|
||||
}
|
||||
|
||||
fun StringList.remove(s: String?) = s ?: ""
|
||||
|
||||
fun String.isEmpty() = this == ""
|
||||
|
||||
fun foo(list: StringList, arg: Unstable) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first?.isEmpty() ?: false) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
|
||||
}
|
||||
}
|
||||
|
||||
class UnstableBoolean {
|
||||
val first: Boolean? get() = null
|
||||
}
|
||||
|
||||
class BooleanList {
|
||||
fun remove(b: Boolean) = b
|
||||
}
|
||||
|
||||
fun BooleanList.remove(b: Boolean?) = b ?: false
|
||||
|
||||
fun bar(list: BooleanList, arg: UnstableBoolean) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first ?: false) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
|
||||
}
|
||||
}
|
||||
39
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.txt
vendored
Normal file
39
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.txt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ list: BooleanList, /*1*/ arg: UnstableBoolean): kotlin.Unit
|
||||
public fun foo(/*0*/ list: StringList, /*1*/ arg: Unstable): kotlin.Unit
|
||||
public fun kotlin.String.isEmpty(): kotlin.Boolean
|
||||
public fun BooleanList.remove(/*0*/ b: kotlin.Boolean?): kotlin.Boolean
|
||||
public fun StringList.remove(/*0*/ s: kotlin.String?): kotlin.String
|
||||
|
||||
public final class BooleanList {
|
||||
public constructor BooleanList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ b: kotlin.Boolean): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class StringList {
|
||||
public constructor StringList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Unstable {
|
||||
public constructor Unstable()
|
||||
public final val first: kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class UnstableBoolean {
|
||||
public constructor UnstableBoolean()
|
||||
public final val first: kotlin.Boolean?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
25
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt
vendored
Normal file
25
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class A {
|
||||
fun get(index: Int): Char = '*'
|
||||
}
|
||||
|
||||
abstract class <!WRONG_MULTIPLE_INHERITANCE!>B<!> : A(), CharSequence
|
||||
|
||||
interface I {
|
||||
fun nextChar(): Char
|
||||
}
|
||||
|
||||
abstract class <!WRONG_MULTIPLE_INHERITANCE!>C<!> : CharIterator(), I {
|
||||
override fun nextChar(): Char = '*'
|
||||
}
|
||||
|
||||
class <!WRONG_MULTIPLE_INHERITANCE!>CC(val s: CharSequence)<!> : CharSequence by s, MyCharSequence {}
|
||||
|
||||
interface MyCharSequence {
|
||||
val length: Int
|
||||
|
||||
operator fun get(index: Int): Char
|
||||
|
||||
fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||
}
|
||||
56
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.txt
vendored
Normal file
56
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.txt
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
package
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class B : A, kotlin.CharSequence {
|
||||
public constructor B()
|
||||
public abstract override /*1*/ /*fake_override*/ val length: kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*2*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class C : kotlin.collections.CharIterator, I {
|
||||
public constructor C()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract override /*1*/ /*fake_override*/ fun hasNext(): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Char
|
||||
public open override /*2*/ fun nextChar(): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class CC : kotlin.CharSequence, MyCharSequence {
|
||||
public constructor CC(/*0*/ s: kotlin.CharSequence)
|
||||
public open override /*2*/ /*delegation*/ val length: kotlin.Int
|
||||
public final val s: kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*delegation*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*delegation*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun nextChar(): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface MyCharSequence {
|
||||
public abstract val length: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract operator fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -10240,6 +10240,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeFromCastParenthesized.kt")
|
||||
public void testExpectedTypeFromCastParenthesized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeWithGenerics.kt")
|
||||
public void testExpectedTypeWithGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeWithGenerics.kt");
|
||||
@@ -12256,6 +12262,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationsInheritance.kt")
|
||||
public void testAnnotationsInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayOfStarParametrized.kt")
|
||||
public void testArrayOfStarParametrized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/arrayOfStarParametrized.kt");
|
||||
@@ -20892,6 +20904,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideCall.kt")
|
||||
public void testInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/insideCall.kt");
|
||||
@@ -20924,6 +20942,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/basicOn.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/inference")
|
||||
|
||||
@@ -66,6 +66,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongMultipleInheritance.kt")
|
||||
public void testWrongMultipleInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -10240,6 +10240,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeFromCastParenthesized.kt")
|
||||
public void testExpectedTypeFromCastParenthesized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeWithGenerics.kt")
|
||||
public void testExpectedTypeWithGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeWithGenerics.kt");
|
||||
@@ -12256,6 +12262,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationsInheritance.kt")
|
||||
public void testAnnotationsInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayOfStarParametrized.kt")
|
||||
public void testArrayOfStarParametrized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/arrayOfStarParametrized.kt");
|
||||
@@ -20892,6 +20904,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideCall.kt")
|
||||
public void testInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/insideCall.kt");
|
||||
@@ -20924,6 +20942,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/basicOn.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/inference")
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
||||
@@ -78,7 +79,9 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
||||
imported = listOf(),
|
||||
data = analysisResult.moduleDescriptor
|
||||
)
|
||||
FileUtil.writeToFile(metaFile, KotlinJavascriptSerializationUtil.metadataAsString(analysisResult.bindingContext, description))
|
||||
FileUtil.writeToFile(metaFile, KotlinJavascriptSerializationUtil.metadataAsString(
|
||||
analysisResult.bindingContext, description, configuration.languageVersionSettings
|
||||
))
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(rootDisposable)
|
||||
|
||||
@@ -55,7 +55,6 @@ enum class LanguageFeature(
|
||||
DeprecatedFieldForInvisibleCompanionObject(KOTLIN_1_2),
|
||||
NullabilityAssertionOnExtensionReceiver(KOTLIN_1_2),
|
||||
SafeCastCheckBoundSmartCasts(KOTLIN_1_2),
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_2),
|
||||
CapturedInClosureSmartCasts(KOTLIN_1_2),
|
||||
LateinitTopLevelProperties(KOTLIN_1_2),
|
||||
LateinitLocalVariables(KOTLIN_1_2),
|
||||
@@ -66,6 +65,7 @@ enum class LanguageFeature(
|
||||
AssigningArraysToVarargsInNamedFormInAnnotations(KOTLIN_1_2),
|
||||
ExpectedTypeFromCast(KOTLIN_1_2),
|
||||
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_3),
|
||||
ReturnsEffect(KOTLIN_1_3),
|
||||
CallsInPlaceEffect(KOTLIN_1_3),
|
||||
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3),
|
||||
@@ -184,3 +184,12 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
||||
val DEFAULT = LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE)
|
||||
}
|
||||
}
|
||||
|
||||
fun LanguageVersionSettings.shouldWritePreReleaseFlag(): Boolean =
|
||||
languageVersion.shouldWritePreReleaseFlag()
|
||||
|
||||
fun LanguageVersion.shouldWritePreReleaseFlag(): Boolean {
|
||||
if (!isStable) return true
|
||||
|
||||
return KotlinCompilerVersion.isPreRelease() && this == LanguageVersion.LATEST_STABLE
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
private val KotlinJvmBinaryClass.isPreReleaseInvisible: Boolean
|
||||
get() = !skipMetadataVersionCheck &&
|
||||
get() = !components.configuration.skipPreReleaseCheck &&
|
||||
!KotlinCompilerVersion.isPreRelease() &&
|
||||
(classHeader.isPreRelease || classHeader.metadataVersion == KOTLIN_1_1_EAP_METADATA_VERSION)
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ object NewKotlinTypeChecker : KotlinTypeChecker {
|
||||
}
|
||||
|
||||
private val ClassDescriptor.isCommonFinalClass: Boolean
|
||||
get() = isFinalClass && kind != ClassKind.ENUM_ENTRY
|
||||
get() = isFinalClass && kind != ClassKind.ENUM_ENTRY && kind != ClassKind.ANNOTATION_CLASS
|
||||
|
||||
/**
|
||||
* If we have several paths to some interface, we should prefer pure kotlin path.
|
||||
|
||||
@@ -20,6 +20,9 @@ interface DeserializationConfiguration {
|
||||
val skipMetadataVersionCheck: Boolean
|
||||
get() = false
|
||||
|
||||
val skipPreReleaseCheck: Boolean
|
||||
get() = false
|
||||
|
||||
val typeAliasesAllowed: Boolean
|
||||
get() = true
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@ public class KotlinCompilerVersion {
|
||||
// DON'T MODIFY IT
|
||||
public static final String VERSION = "@snapshot@";
|
||||
|
||||
// True if this compiler is of a non-stable (EAP or Beta) version.
|
||||
// Binaries produced by this compiler can not be loaded by release versions of the compiler.
|
||||
// True if the latest stable language version supported by this compiler has not yet been released.
|
||||
// Binaries produced by this compiler with that language version (or any future language version) are going to be marked
|
||||
// as "pre-release" and will not be loaded by release versions of the compiler.
|
||||
// Change this value before and after every major release
|
||||
private static final boolean IS_PRE_RELEASE = false;
|
||||
private static final boolean IS_PRE_RELEASE = true;
|
||||
|
||||
public static final String TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY = "kotlin.test.is.pre.release";
|
||||
|
||||
@@ -38,6 +39,7 @@ public class KotlinCompilerVersion {
|
||||
}
|
||||
|
||||
static {
|
||||
//noinspection ConstantConditions
|
||||
if (!VERSION.equals("@snapshot@") && !VERSION.contains("-") && IS_PRE_RELEASE) {
|
||||
throw new IllegalStateException(
|
||||
"IS_PRE_RELEASE cannot be true for a compiler without '-' in its version.\n" +
|
||||
|
||||
@@ -19,9 +19,11 @@ package org.jetbrains.kotlin.idea.stubindex.resolve
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.stubs.StubIndex
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ModuleSourceInfo
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinExactPackagesIndex
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||
import org.jetbrains.kotlin.idea.stubindex.SubpackagesIndexService
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -70,11 +72,18 @@ class PluginDeclarationProviderFactory(
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile) {
|
||||
val packageFqName = file.packageFqName
|
||||
val subpackagesIndex = SubpackagesIndexService.getInstance(project)
|
||||
throw IllegalStateException("Cannot find package fragment for file ${file.name} with package $packageFqName, " +
|
||||
"vFile ${file.virtualFile}, nonIndexed ${file in nonIndexedFiles} " +
|
||||
"packageExists=${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)} in $indexedFilesScope," +
|
||||
"SPI.packageExists=${subpackagesIndex.packageExists(packageFqName)} SPI=$subpackagesIndex " +
|
||||
"OOCB count ${file.manager.modificationTracker.outOfCodeBlockModificationCount}}")
|
||||
val moduleSourceInfo = moduleInfo as? ModuleSourceInfo
|
||||
val virtualFile = file.virtualFile
|
||||
throw IllegalStateException("""
|
||||
Cannot find package fragment for file ${file.name} with package '$packageFqName':
|
||||
vFile: $virtualFile,
|
||||
nonIndexed files: $nonIndexedFiles, isNonIndexed: ${file in nonIndexedFiles},
|
||||
scope = $indexedFilesScope, isInScope = ${virtualFile in indexedFilesScope},
|
||||
packageExists = ${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)}, cachedPackageExists = ${moduleSourceInfo?.let { project.service<PerModulePackageCacheService>().packageExists(packageFqName, it) }},
|
||||
oldPackageExists = ${oldPackageExists(packageFqName) ?: "threw exception"},
|
||||
SPI.packageExists = ${subpackagesIndex.packageExists(packageFqName)}, SPI = $subpackagesIndex, OOCB count ${file.manager.modificationTracker.outOfCodeBlockModificationCount},
|
||||
ModuleModificationCount = ${moduleSourceInfo?.createModificationTracker()?.modificationCount},
|
||||
packageFqNameByTree = '${file.packageFqNameByTree}', packageDirectiveText = '${file.packageDirective?.text}'""")
|
||||
}
|
||||
|
||||
// trying to diagnose org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException in completion
|
||||
@@ -84,6 +93,20 @@ class PluginDeclarationProviderFactory(
|
||||
return "PluginDeclarationProviderFactory\nOn failure:\n${debugInfo()}On creation:\n$onCreationDebugInfo"
|
||||
}
|
||||
|
||||
private fun oldPackageExists(packageFqName: FqName): Boolean? = try {
|
||||
var result = false
|
||||
StubIndex.getInstance().processElements<String, KtFile>(
|
||||
KotlinExactPackagesIndex.getInstance().key, packageFqName.asString(), project, indexedFilesScope, KtFile::class.java
|
||||
) {
|
||||
result = true
|
||||
false
|
||||
}
|
||||
result
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
|
||||
private fun debugInfo(): String {
|
||||
if (nonIndexedFiles.isEmpty()) return "-no synthetic files-\n"
|
||||
|
||||
|
||||
@@ -24,16 +24,20 @@ import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.roots.DependencyScope
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.gradle.tooling.model.idea.IdeaModule
|
||||
import org.gradle.tooling.model.idea.IdeaModuleDependency
|
||||
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
|
||||
import org.jetbrains.kotlin.gradle.KotlinGradleModel
|
||||
import org.jetbrains.kotlin.gradle.KotlinGradleModelBuilder
|
||||
import org.jetbrains.kotlin.psi.NotNullableUserDataProperty
|
||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProject
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProjectDependency
|
||||
import org.jetbrains.plugins.gradle.model.FileCollectionDependency
|
||||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolverUtil.getModuleId
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolver
|
||||
import java.util.*
|
||||
|
||||
var DataNode<ModuleData>.isResolved
|
||||
by NotNullableUserDataProperty(Key.create<Boolean>("IS_RESOLVED"), false)
|
||||
@@ -60,10 +64,103 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
override fun populateModuleDependencies(gradleModule: IdeaModule,
|
||||
ideModule: DataNode<ModuleData>,
|
||||
ideProject: DataNode<ProjectData>) {
|
||||
val outputToSourceSet = ideProject.getUserData(GradleProjectResolver.MODULES_OUTPUTS)
|
||||
val sourceSetByName = ideProject.getUserData(GradleProjectResolver.RESOLVED_SOURCE_SETS)
|
||||
|
||||
val gradleModel = resolverCtx.getExtraProject(gradleModule, KotlinGradleModel::class.java)
|
||||
?: return super.populateModuleDependencies(gradleModule, ideModule, ideProject)
|
||||
|
||||
importTransitiveCommonDependencies(gradleModel, ideProject, gradleModule, ideModule)
|
||||
val gradleIdeaProject = gradleModule.project
|
||||
|
||||
fun DataNode<out ModuleData>.getGradleModule() =
|
||||
if (this != ideModule) gradleIdeaProject.modules.firstOrNull { it.gradleProject.path == data.id } else gradleModule
|
||||
|
||||
fun DataNode<out ModuleData>.getDependencies(): Set<DataNode<out ModuleData>> {
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
if (sourceSetByName == null) return emptySet()
|
||||
val externalSourceSet = sourceSetByName[data.id]?.second ?: return emptySet()
|
||||
return externalSourceSet.dependencies.mapNotNullTo(LinkedHashSet()) { dependency ->
|
||||
when (dependency) {
|
||||
is ExternalProjectDependency -> {
|
||||
val targetModuleNode = ExternalSystemApiUtil.findFirstRecursively(ideProject) {
|
||||
(it.data as? ModuleData)?.id == dependency.projectPath
|
||||
} as DataNode<ModuleData>? ?: return@mapNotNullTo null
|
||||
ExternalSystemApiUtil.findAll(targetModuleNode, GradleSourceSetData.KEY).firstOrNull { it.sourceSetName == "main" }
|
||||
}
|
||||
is FileCollectionDependency -> {
|
||||
dependency.files
|
||||
.mapTo(HashSet()) {
|
||||
val path = FileUtil.toSystemIndependentName(it.path)
|
||||
val targetSourceSetId = outputToSourceSet?.get(path)?.first ?: return@mapTo null
|
||||
sourceSetByName[targetSourceSetId]?.first
|
||||
}
|
||||
.singleOrNull()
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getGradleModule()?.dependencies?.mapNotNullTo(LinkedHashSet()) {
|
||||
val targetModuleName = (it as? IdeaModuleDependency)?.targetModuleName ?: return@mapNotNullTo null
|
||||
val targetGradleModule = gradleIdeaProject.modules.firstOrNull { it.name == targetModuleName } ?: return@mapNotNullTo null
|
||||
ExternalSystemApiUtil.findFirstRecursively(ideProject) {
|
||||
(it.data as? ModuleData)?.id == targetGradleModule.gradleProject.path
|
||||
} as DataNode<ModuleData>?
|
||||
} ?: emptySet()
|
||||
}
|
||||
|
||||
fun addTransitiveDependenciesOnImplementedModules() {
|
||||
val moduleNodesToProcess = if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
ExternalSystemApiUtil.findAll(ideModule, GradleSourceSetData.KEY)
|
||||
}
|
||||
else listOf(ideModule)
|
||||
|
||||
for (currentModuleNode in moduleNodesToProcess) {
|
||||
val toProcess = LinkedList<DataNode<out ModuleData>>()
|
||||
val processed = HashSet<DataNode<out ModuleData>>()
|
||||
toProcess.add(currentModuleNode)
|
||||
|
||||
while (toProcess.isNotEmpty()) {
|
||||
val moduleNode = toProcess.pollFirst()
|
||||
processed.add(moduleNode)
|
||||
|
||||
val moduleNodeForGradleModel = if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
ExternalSystemApiUtil.findParent(moduleNode, ProjectKeys.MODULE)
|
||||
}
|
||||
else moduleNode
|
||||
val ideaModule = if (moduleNodeForGradleModel != ideModule) {
|
||||
gradleIdeaProject.modules.firstOrNull { it.gradleProject.path == moduleNodeForGradleModel?.data?.id }
|
||||
}
|
||||
else gradleModule
|
||||
|
||||
val implementsInfo = resolverCtx.getExtraProject(ideaModule, KotlinGradleModel::class.java)?.implements
|
||||
val targetModule = implementsInfo?.let { findModule(ideProject, it) }
|
||||
if (targetModule != null) {
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
val targetSourceSetsByName = ExternalSystemApiUtil
|
||||
.findAll(targetModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.sourceSetName }
|
||||
val targetMainSourceSet = targetSourceSetsByName["main"] ?: targetModule
|
||||
val targetSourceSet = targetSourceSetsByName[currentModuleNode.sourceSetName]
|
||||
if (targetSourceSet != null) {
|
||||
addDependency(currentModuleNode, targetSourceSet)
|
||||
}
|
||||
if (currentModuleNode.sourceSetName == "test" && targetMainSourceSet != targetSourceSet) {
|
||||
addDependency(currentModuleNode, targetMainSourceSet)
|
||||
}
|
||||
}
|
||||
else {
|
||||
addDependency(currentModuleNode, targetModule)
|
||||
}
|
||||
}
|
||||
|
||||
moduleNode.getDependencies().filterTo(toProcess) { it !in processed }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addTransitiveDependenciesOnImplementedModules()
|
||||
|
||||
ideModule.isResolved = true
|
||||
ideModule.hasKotlinPlugin = gradleModel.hasKotlinPlugin
|
||||
@@ -75,17 +172,8 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
super.populateModuleDependencies(gradleModule, ideModule, ideProject)
|
||||
}
|
||||
|
||||
private fun importTransitiveCommonDependencies(gradleModel: KotlinGradleModel, ideProject: DataNode<ProjectData>, gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
|
||||
gradleModel.transitiveCommonDependencies.forEach { implementsModuleId ->
|
||||
val targetModule = findModule(ideProject, implementsModuleId) ?: return
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
populateSourceSetDependencies(gradleModule, ideModule, targetModule)
|
||||
}
|
||||
else {
|
||||
addDependency(ideModule, targetModule)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val DataNode<out ModuleData>.sourceSetName
|
||||
get() = (data as? GradleSourceSetData)?.id?.substringAfterLast(':')
|
||||
|
||||
private fun addDependency(ideModule: DataNode<out ModuleData>, targetModule: DataNode<out ModuleData>) {
|
||||
val moduleDependencyData = ModuleDependencyData(ideModule.data, targetModule.data)
|
||||
@@ -97,23 +185,4 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
private fun findModule(ideProject: DataNode<ProjectData>, moduleId: String): DataNode<ModuleData>? {
|
||||
return ideProject.children.find { (it.data as? ModuleData)?.id == moduleId } as DataNode<ModuleData>?
|
||||
}
|
||||
|
||||
private fun populateSourceSetDependencies(gradleModule: IdeaModule,
|
||||
fromModule: DataNode<ModuleData>,
|
||||
targetModule: DataNode<ModuleData>) {
|
||||
val fromSourceSets = ExternalSystemApiUtil.findAll(fromModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.data.id }
|
||||
val targetSourceSets = ExternalSystemApiUtil.findAll(targetModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.data.id.substringAfterLast(':') }
|
||||
|
||||
val externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject::class.java) ?: return
|
||||
for (sourceSet in externalProject.sourceSets.values) {
|
||||
if (sourceSet == null || sourceSet.sources.isEmpty()) continue
|
||||
|
||||
val moduleId = getModuleId(externalProject, sourceSet)
|
||||
val fromModuleDataNode = (if (fromSourceSets.isEmpty()) fromModule else fromSourceSets[moduleId]) ?: continue
|
||||
val targetModuleDataNode = (if (targetSourceSets.isEmpty()) targetModule else targetSourceSets[sourceSet.name]) ?: continue
|
||||
addDependency(fromModuleDataNode, targetModuleDataNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,52 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonExpectedByDependency() {
|
||||
createProjectSubFile("settings.gradle", "include ':common', ':jvm', ':js'")
|
||||
|
||||
val kotlinVersion = "1.2.0-beta-74"
|
||||
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-dev' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
project('common') {
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
}
|
||||
|
||||
project('jvm') {
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
|
||||
project('js') {
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
importProject()
|
||||
assertModuleModuleDepScope("jvm_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm_test", "common_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonDependencyRoot() {
|
||||
createProjectSubFile("settings.gradle", "rootProject.name = 'foo'\ninclude ':jvm', ':js'")
|
||||
@@ -250,4 +296,93 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("jvm-app_test", "common-lib1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm-app_test", "common-lib2_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTransitiveImplement() {
|
||||
createProjectSubFile(
|
||||
"settings.gradle",
|
||||
"include ':project1', ':project2', ':project3'"
|
||||
)
|
||||
|
||||
val kotlinVersion = "1.1.51"
|
||||
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
project('project1') {
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
}
|
||||
|
||||
project('project2') {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(':project1')
|
||||
}
|
||||
}
|
||||
|
||||
project('project3') {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':project2')
|
||||
customCompile project(':project2')
|
||||
testCompile(project(':project2').sourceSets.test.output)
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
importProject()
|
||||
|
||||
assertModuleModuleDepScope("project1_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_main", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_test", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project2_test", "project1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project2_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_custom", "project1_custom", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_main", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_main", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_test", "project3_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project2_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_custom", "project1_custom", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_custom", "project2_main", DependencyScope.COMPILE)
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,9 @@ package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService
|
||||
import java.io.File
|
||||
@@ -26,7 +28,6 @@ import java.io.Serializable
|
||||
import java.lang.Exception
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
interface ArgsInfo : Serializable {
|
||||
val currentArguments: List<String>
|
||||
@@ -48,7 +49,6 @@ interface KotlinGradleModel : Serializable {
|
||||
val coroutines: String?
|
||||
val platformPluginId: String?
|
||||
val implements: String?
|
||||
val transitiveCommonDependencies: Set<String>
|
||||
}
|
||||
|
||||
class KotlinGradleModelImpl(
|
||||
@@ -56,8 +56,7 @@ class KotlinGradleModelImpl(
|
||||
override val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet,
|
||||
override val coroutines: String?,
|
||||
override val platformPluginId: String?,
|
||||
override val implements: String?,
|
||||
override val transitiveCommonDependencies: Set<String>
|
||||
override val implements: String?
|
||||
) : KotlinGradleModel
|
||||
|
||||
abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
||||
@@ -70,7 +69,6 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
||||
"kotlin2js" to "kotlin-platform-js"
|
||||
)
|
||||
val kotlinPluginIds = listOf("kotlin", "kotlin2js", "kotlin-android")
|
||||
val kotlinPlatformCommonPluginId = "kotlin-platform-common"
|
||||
val ABSTRACT_KOTLIN_COMPILE_CLASS = "org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile"
|
||||
|
||||
fun Task.getSourceSetName(): String {
|
||||
@@ -91,50 +89,10 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
||||
override fun canBuild(modelName: String?): Boolean = modelName == KotlinGradleModel::class.java.name
|
||||
|
||||
private fun getImplements(project: Project): Project? {
|
||||
val implementsConfiguration = project.configurations.run { findByName("expectedBy") ?: findByName("implement") } ?: return null
|
||||
val implementsProjectDependency = implementsConfiguration.dependencies.filterIsInstance<ProjectDependency>().firstOrNull()
|
||||
return implementsProjectDependency?.dependencyProject
|
||||
}
|
||||
|
||||
private val Project.isCommon get() = plugins.hasPlugin(kotlinPlatformCommonPluginId)
|
||||
|
||||
private fun transitiveCommonDependencies(startingProject: Project): Set<String> {
|
||||
val toProcess = LinkedList<Pair<Project, Boolean>>()
|
||||
toProcess.add(startingProject to false)
|
||||
val processed = HashSet<String>()
|
||||
val result = HashSet<String>()
|
||||
|
||||
fun enqueueDependencies(project: Project, isReachableViaImpl: Boolean, collectImpls: Boolean) {
|
||||
val isCommonProject = project.isCommon
|
||||
if (isCommonProject && collectImpls) return
|
||||
|
||||
val configName = if (collectImpls) "implement" else "compile"
|
||||
val compileConfiguration = project.configurations.findByName(configName) ?: return
|
||||
val dependencies = compileConfiguration
|
||||
.dependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.map { it.dependencyProject }
|
||||
|
||||
for (dep in dependencies) {
|
||||
if (dep.path in processed) continue
|
||||
if (!dep.isCommon && (collectImpls || isCommonProject)) continue
|
||||
toProcess.add(dep to (isReachableViaImpl || collectImpls))
|
||||
}
|
||||
}
|
||||
|
||||
while (toProcess.isNotEmpty()) {
|
||||
val (project, isReachableViaImpl) = toProcess.pollFirst()
|
||||
processed.add(project.path)
|
||||
|
||||
if (isReachableViaImpl) {
|
||||
result.add(project.pathOrName())
|
||||
}
|
||||
|
||||
enqueueDependencies(project, isReachableViaImpl, false)
|
||||
enqueueDependencies(project, isReachableViaImpl, true)
|
||||
}
|
||||
|
||||
return result
|
||||
return listOf("expectedBy", "implement")
|
||||
.flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet<Dependency>() }
|
||||
.firstIsInstanceOrNull<ProjectDependency>()
|
||||
?.dependencyProject
|
||||
}
|
||||
|
||||
// see GradleProjectResolverUtil.getModuleId() in IDEA codebase
|
||||
@@ -206,15 +164,13 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
||||
|
||||
val platform = platformPluginId ?: pluginToPlatform.entries.singleOrNull { project.plugins.findPlugin(it.key) != null }?.value
|
||||
val implementedProject = getImplements(project)
|
||||
val transitiveCommon = transitiveCommonDependencies(project)
|
||||
|
||||
return KotlinGradleModelImpl(
|
||||
kotlinPluginId != null || platformPluginId != null,
|
||||
compilerArgumentsBySourceSet,
|
||||
getCoroutines(project),
|
||||
platform,
|
||||
implementedProject?.pathOrName(),
|
||||
transitiveCommon
|
||||
implementedProject?.pathOrName()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,14 @@ private fun Module.findImplementingModules(modelsProvider: IdeModifiableModelsPr
|
||||
}
|
||||
}
|
||||
|
||||
val Module.implementingModules: List<Module>
|
||||
get() = cached(CachedValueProvider {
|
||||
CachedValueProvider.Result(
|
||||
findImplementingModules(IdeModifiableModelsProviderImpl(project)),
|
||||
ProjectRootModificationTracker.getInstance(project)
|
||||
)
|
||||
})
|
||||
|
||||
private fun Module.getModuleInfo(baseModuleSourceInfo: ModuleSourceInfo): ModuleSourceInfo? =
|
||||
when (baseModuleSourceInfo) {
|
||||
is ModuleProductionSourceInfo -> productionSourceInfo()
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.execution.Location
|
||||
import com.intellij.execution.actions.ConfigurationContext
|
||||
import com.intellij.execution.actions.RunConfigurationProducer
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.psi.PsiElement
|
||||
@@ -32,6 +31,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.facet.implementingModules
|
||||
import org.jetbrains.kotlin.idea.project.TargetPlatformDetector
|
||||
import org.jetbrains.kotlin.idea.project.targetPlatform
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
@@ -129,6 +129,5 @@ class KotlinRunConfigurationProducer : RunConfigurationProducer<KotlinRunConfigu
|
||||
|
||||
fun Module.findJvmImplementationModule(): Module? {
|
||||
if (targetPlatform != TargetPlatformKind.Common) return null
|
||||
val allDependentModules = ModuleManager.getInstance(project).getModuleDependentModules(this)
|
||||
return allDependentModules.firstOrNull { it.targetPlatform is TargetPlatformKind.Jvm }
|
||||
return implementingModules.firstOrNull { it.targetPlatform is TargetPlatformKind.Jvm }
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ object JsPlatformConfigurator : PlatformConfigurator(
|
||||
additionalDeclarationCheckers = listOf(
|
||||
NativeInvokeChecker(), NativeGetterChecker(), NativeSetterChecker(),
|
||||
JsNameChecker, JsModuleChecker, JsExternalFileChecker,
|
||||
JsExternalChecker, JsInheritanceChecker,
|
||||
JsExternalChecker, JsInheritanceChecker, JsMultipleInheritanceChecker,
|
||||
JsRuntimeAnnotationChecker,
|
||||
JsDynamicDeclarationChecker,
|
||||
ExpectedActualDeclarationChecker
|
||||
|
||||
@@ -104,6 +104,10 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy {
|
||||
put(ErrorsJs.EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, "External class constructor cannot have a property parameter")
|
||||
put(ErrorsJs.CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION, "This property can only be used from external declarations")
|
||||
|
||||
put(ErrorsJs.WRONG_MULTIPLE_INHERITANCE,
|
||||
"Can't apply multiple inheritance here, since it's impossible to generate bridge for system function {0}",
|
||||
Renderers.DECLARATION_NAME_WITH_KIND)
|
||||
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.*;
|
||||
@@ -109,6 +110,9 @@ public interface ErrorsJs {
|
||||
DiagnosticFactory0<KtParameter> EXTERNAL_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, CallableMemberDescriptor> WRONG_MULTIPLE_INHERITANCE =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
Object _initializer = new Object() {
|
||||
{
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
|
||||
object JsMultipleInheritanceChecker : SimpleDeclarationChecker {
|
||||
private val fqNames = listOf(
|
||||
FqNameUnsafe("kotlin.CharSequence.get"),
|
||||
FqNameUnsafe("kotlin.collections.CharIterator.nextChar")
|
||||
)
|
||||
private val simpleNames = fqNames.mapTo(mutableSetOf()) { it.shortName() }
|
||||
|
||||
override fun check(
|
||||
declaration: KtDeclaration, descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink, bindingContext: BindingContext
|
||||
) {
|
||||
if (descriptor !is ClassDescriptor) return
|
||||
|
||||
for (callable in descriptor.unsubstitutedMemberScope.getContributedDescriptors { it in simpleNames }
|
||||
.filterIsInstance<CallableMemberDescriptor>()) {
|
||||
if (callable.overriddenDescriptors.size > 1 && callable.overriddenDescriptors.any { it.fqNameUnsafe in fqNames }) {
|
||||
diagnosticHolder.report(ErrorsJs.WRONG_MULTIPLE_INHERITANCE.on(declaration, callable))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class KotlinJavascriptPackageFragment(
|
||||
get() = null
|
||||
|
||||
override val isPreReleaseInvisible: Boolean =
|
||||
!configuration.skipMetadataVersionCheck && (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
|
||||
!configuration.skipPreReleaseCheck && (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
|
||||
|
||||
override val presentableString: String
|
||||
get() = "Package '$fqName'"
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.js
|
||||
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -116,10 +117,16 @@ object KotlinJavascriptSerializationUtil {
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun metadataAsString(bindingContext: BindingContext, jsDescriptor: JsModuleDescriptor<ModuleDescriptor>): String =
|
||||
KotlinJavascriptMetadataUtils.formatMetadataAsString(jsDescriptor.name, jsDescriptor.serializeToBinaryMetadata(bindingContext))
|
||||
fun metadataAsString(
|
||||
bindingContext: BindingContext,
|
||||
jsDescriptor: JsModuleDescriptor<ModuleDescriptor>,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): String = KotlinJavascriptMetadataUtils.formatMetadataAsString(
|
||||
jsDescriptor.name,
|
||||
jsDescriptor.serializeToBinaryMetadata(bindingContext, languageVersionSettings)
|
||||
)
|
||||
|
||||
fun serializePackageFragment(bindingContext: BindingContext, module: ModuleDescriptor, fqName: FqName): ProtoBuf.PackageFragment {
|
||||
private fun serializePackageFragment(bindingContext: BindingContext, module: ModuleDescriptor, fqName: FqName): ProtoBuf.PackageFragment {
|
||||
val packageView = module.getPackage(fqName)
|
||||
return serializeDescriptors(bindingContext, module, packageView.memberScope.getContributedDescriptors(), fqName)
|
||||
}
|
||||
@@ -200,7 +207,11 @@ object KotlinJavascriptSerializationUtil {
|
||||
return filesProto.build()
|
||||
}
|
||||
|
||||
fun toContentMap(bindingContext: BindingContext, module: ModuleDescriptor): Map<String, ByteArray> {
|
||||
fun toContentMap(
|
||||
bindingContext: BindingContext,
|
||||
module: ModuleDescriptor,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): Map<String, ByteArray> {
|
||||
val contentMap = hashMapOf<String, ByteArray>()
|
||||
|
||||
for (fqName in getPackagesFqNames(module)) {
|
||||
@@ -216,7 +227,7 @@ object KotlinJavascriptSerializationUtil {
|
||||
version.forEach(this::writeInt)
|
||||
}
|
||||
|
||||
serializeHeader(fqName).writeDelimitedTo(stream)
|
||||
serializeHeader(fqName, languageVersionSettings).writeDelimitedTo(stream)
|
||||
part.writeTo(stream)
|
||||
|
||||
contentMap[JsSerializerProtocol.getKjsmFilePath(fqName)] = stream.toByteArray()
|
||||
@@ -225,14 +236,14 @@ object KotlinJavascriptSerializationUtil {
|
||||
return contentMap
|
||||
}
|
||||
|
||||
fun serializeHeader(packageFqName: FqName?): JsProtoBuf.Header {
|
||||
fun serializeHeader(packageFqName: FqName?, languageVersionSettings: LanguageVersionSettings): JsProtoBuf.Header {
|
||||
val header = JsProtoBuf.Header.newBuilder()
|
||||
|
||||
if (packageFqName != null) {
|
||||
header.packageFqName = packageFqName.asString()
|
||||
}
|
||||
|
||||
if (KotlinCompilerVersion.isPreRelease()) {
|
||||
if (languageVersionSettings.shouldWritePreReleaseFlag()) {
|
||||
header.flags = 1
|
||||
}
|
||||
|
||||
@@ -261,10 +272,13 @@ object KotlinJavascriptSerializationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private fun JsModuleDescriptor<ModuleDescriptor>.serializeToBinaryMetadata(bindingContext: BindingContext): ByteArray {
|
||||
private fun JsModuleDescriptor<ModuleDescriptor>.serializeToBinaryMetadata(
|
||||
bindingContext: BindingContext,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): ByteArray {
|
||||
return ByteArrayOutputStream().apply {
|
||||
GZIPOutputStream(this).use { stream ->
|
||||
serializeHeader(null).writeDelimitedTo(stream)
|
||||
serializeHeader(null, languageVersionSettings).writeDelimitedTo(stream)
|
||||
serializeMetadata(bindingContext, data, kind, imported).writeTo(stream)
|
||||
}
|
||||
}.toByteArray()
|
||||
|
||||
@@ -445,6 +445,18 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/char/charUnaryOperations.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelCallables.kt")
|
||||
public void testTopLevelCallables() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/char/topLevelCallables.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("unboxedCharSpecials.kt")
|
||||
public void testUnboxedCharSpecials() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/char/unboxedCharSpecials.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/classObject")
|
||||
@@ -803,6 +815,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/coercion"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeChar.kt")
|
||||
public void testBridgeChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coercion/bridgeChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classProperty.kt")
|
||||
public void testClassProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coercion/classProperty.kt");
|
||||
@@ -857,6 +875,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyBridgeChar.kt")
|
||||
public void testPropertyBridgeChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coercion/propertyBridgeChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverSmartCast.kt")
|
||||
public void testReceiverSmartCast() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coercion/receiverSmartCast.kt");
|
||||
|
||||
@@ -19,8 +19,11 @@ package org.jetbrains.kotlin.js.facade;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeysKt;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer;
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS;
|
||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult;
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsImportedModule;
|
||||
@@ -29,7 +32,6 @@ import org.jetbrains.kotlin.js.config.JSConfigurationKeys;
|
||||
import org.jetbrains.kotlin.js.config.JsConfig;
|
||||
import org.jetbrains.kotlin.js.coroutine.CoroutineTransformer;
|
||||
import org.jetbrains.kotlin.js.facade.exceptions.TranslationException;
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer;
|
||||
import org.jetbrains.kotlin.js.inline.JsInliner;
|
||||
import org.jetbrains.kotlin.js.inline.clean.LabeledBlockToDoWhileTransformation;
|
||||
import org.jetbrains.kotlin.js.inline.clean.RemoveDuplicateImportsKt;
|
||||
@@ -52,7 +54,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.DiagnosticUtils.hasError;
|
||||
|
||||
@@ -182,7 +183,8 @@ public final class K2JSTranslator {
|
||||
incrementalResults.processPackagePart(ioFile, packagePart.toByteArray(), binaryAst);
|
||||
}
|
||||
|
||||
incrementalResults.processHeader(serializationUtil.serializeHeader(null).toByteArray());
|
||||
LanguageVersionSettings settings = CommonConfigurationKeysKt.getLanguageVersionSettings(config.getConfiguration());
|
||||
incrementalResults.processHeader(serializationUtil.serializeHeader(null, settings).toByteArray());
|
||||
}
|
||||
|
||||
RemoveDuplicateImportsKt.removeDuplicateImports(translationResult.getProgram());
|
||||
|
||||
@@ -19,16 +19,17 @@ package org.jetbrains.kotlin.js.facade
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import org.jetbrains.kotlin.backend.common.output.*
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor
|
||||
import org.jetbrains.kotlin.js.backend.NoOpSourceLocationConsumer
|
||||
import org.jetbrains.kotlin.js.backend.SourceLocationConsumer
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsProgram
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||
import org.jetbrains.kotlin.js.backend.SourceLocationConsumer
|
||||
import org.jetbrains.kotlin.js.util.TextOutput
|
||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -105,12 +106,13 @@ abstract class TranslationResult protected constructor(val diagnostics: Diagnost
|
||||
kind = config.moduleKind,
|
||||
imported = importedModules
|
||||
)
|
||||
val metaFileContent = KotlinJavascriptSerializationUtil.metadataAsString(bindingContext, moduleDescription)
|
||||
val settings = config.configuration.languageVersionSettings
|
||||
val metaFileContent = KotlinJavascriptSerializationUtil.metadataAsString(bindingContext, moduleDescription, settings)
|
||||
val sourceFilesForMetaFile = ArrayList(sourceFiles)
|
||||
val jsMetaFile = SimpleOutputFile(sourceFilesForMetaFile, metaFileName, metaFileContent)
|
||||
outputFiles.add(jsMetaFile)
|
||||
|
||||
KotlinJavascriptSerializationUtil.toContentMap(bindingContext, moduleDescriptor).forEach {
|
||||
KotlinJavascriptSerializationUtil.toContentMap(bindingContext, moduleDescriptor, settings).forEach {
|
||||
// TODO Add correct source files
|
||||
outputFiles.add(SimpleOutputBinaryFile(emptyList(), config.moduleId + VfsUtilCore.VFS_SEPARATOR_CHAR + it.key, it.value))
|
||||
}
|
||||
|
||||
@@ -65,7 +65,9 @@ object CallTranslator {
|
||||
value: JsExpression,
|
||||
extensionOrDispatchReceiver: JsExpression? = null
|
||||
): JsExpression {
|
||||
val variableAccessInfo = VariableAccessInfo(context.getCallInfo(resolvedCall, extensionOrDispatchReceiver), value)
|
||||
val type = TranslationUtils.getReturnTypeForCoercion(resolvedCall.resultingDescriptor)
|
||||
val coerceValue = TranslationUtils.coerce(context, value, type)
|
||||
val variableAccessInfo = VariableAccessInfo(context.getCallInfo(resolvedCall, extensionOrDispatchReceiver), coerceValue)
|
||||
val result = variableAccessInfo.translateVariableAccess().source(resolvedCall.call.callElement)
|
||||
result.type = context.currentModule.builtIns.unitType
|
||||
return result
|
||||
|
||||
@@ -51,6 +51,10 @@ public final class InitializerVisitor extends TranslatorVisitor<Void> {
|
||||
KtExpression delegate = property.getDelegateExpression();
|
||||
if (initializer != null) {
|
||||
assert value != null;
|
||||
KotlinType type = TranslationUtils.isReferenceToSyntheticBackingField(descriptor) ?
|
||||
descriptor.getType() :
|
||||
TranslationUtils.getReturnTypeForCoercion(descriptor);
|
||||
value = TranslationUtils.coerce(context, value, type);
|
||||
statement = generateInitializerForProperty(context, descriptor, value);
|
||||
}
|
||||
else if (delegate != null) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils;
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils;
|
||||
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils;
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.psi.KtQualifiedExpression;
|
||||
@@ -84,6 +85,10 @@ public final class ReferenceTranslator {
|
||||
if (parameter.getContainingDeclaration() instanceof AnonymousFunctionDescriptor) {
|
||||
return DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
}
|
||||
if (parameter.getContainingDeclaration() instanceof PropertySetterDescriptor) {
|
||||
PropertySetterDescriptor setter = (PropertySetterDescriptor) parameter.getContainingDeclaration();
|
||||
return TranslationUtils.getReturnTypeForCoercion(setter.getCorrespondingProperty(), false);
|
||||
}
|
||||
}
|
||||
return ((CallableDescriptor) descriptor).getReturnType();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.js.translate.general.Translation;
|
||||
import org.jetbrains.kotlin.js.translate.reference.ReferenceTranslator;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
@@ -58,6 +59,13 @@ import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getCallableDe
|
||||
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.*;
|
||||
|
||||
public final class TranslationUtils {
|
||||
private static final Set<FqNameUnsafe> CLASSES_WITH_NON_BOXED_CHARS = new HashSet<>(Arrays.asList(
|
||||
new FqNameUnsafe("kotlin.collections.CharIterator"),
|
||||
new FqNameUnsafe("kotlin.ranges.CharProgression"),
|
||||
new FqNameUnsafe("kotlin.js.internal.CharCompanionObject"),
|
||||
new FqNameUnsafe("kotlin.Char.Companion"),
|
||||
KotlinBuiltIns.FQ_NAMES.charSequence, KotlinBuiltIns.FQ_NAMES.number
|
||||
));
|
||||
|
||||
private TranslationUtils() {
|
||||
}
|
||||
@@ -172,17 +180,21 @@ public final class TranslationUtils {
|
||||
|
||||
@NotNull
|
||||
public static JsName getNameForBackingField(@NotNull TranslationContext context, @NotNull PropertyDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
|
||||
if (!JsDescriptorUtils.isSimpleFinalProperty(descriptor) && !(containingDescriptor instanceof PackageFragmentDescriptor)) {
|
||||
if (isReferenceToSyntheticBackingField(descriptor)) {
|
||||
return context.getNameForBackingField(descriptor);
|
||||
}
|
||||
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
return containingDescriptor instanceof PackageFragmentDescriptor ?
|
||||
context.getInnerNameForDescriptor(descriptor) :
|
||||
context.getNameForDescriptor(descriptor);
|
||||
}
|
||||
|
||||
public static boolean isReferenceToSyntheticBackingField(@NotNull PropertyDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
return !JsDescriptorUtils.isSimpleFinalProperty(descriptor) && !(containingDescriptor instanceof PackageFragmentDescriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsNameRef backingFieldReference(@NotNull TranslationContext context, @NotNull PropertyDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration();
|
||||
@@ -196,7 +208,7 @@ public final class TranslationUtils {
|
||||
}
|
||||
|
||||
JsNameRef result = new JsNameRef(getNameForBackingField(context, descriptor), receiver);
|
||||
MetadataProperties.setType(result, getReturnTypeForCoercion(descriptor));
|
||||
MetadataProperties.setType(result, getReturnTypeForCoercion(descriptor, true));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -396,25 +408,50 @@ public final class TranslationUtils {
|
||||
|
||||
@NotNull
|
||||
public static KotlinType getReturnTypeForCoercion(@NotNull CallableDescriptor descriptor) {
|
||||
return getReturnTypeForCoercion(descriptor, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KotlinType getReturnTypeForCoercion(@NotNull CallableDescriptor descriptor, boolean forcePrivate) {
|
||||
descriptor = descriptor.getOriginal();
|
||||
|
||||
if (FunctionTypesKt.getFunctionalClassKind(descriptor) != null || descriptor instanceof AnonymousFunctionDescriptor) {
|
||||
return DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
return getAnyTypeFromSameModule(descriptor);
|
||||
}
|
||||
|
||||
Collection<? extends CallableDescriptor> overridden = descriptor.getOverriddenDescriptors();
|
||||
if (overridden.isEmpty()) {
|
||||
return descriptor.getReturnType() != null ?
|
||||
descriptor.getReturnType() :
|
||||
DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
KotlinType returnType = descriptor.getReturnType();
|
||||
if (returnType == null) {
|
||||
return getAnyTypeFromSameModule(descriptor);
|
||||
}
|
||||
|
||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||
boolean isPublic = descriptor.getVisibility().effectiveVisibility(descriptor, true).getPublicApi() && !forcePrivate;
|
||||
if (KotlinBuiltIns.isCharOrNullableChar(returnType) && container instanceof ClassDescriptor && isPublic) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) container;
|
||||
FqNameUnsafe containingClassName = DescriptorUtilsKt.getFqNameUnsafe(containingClass);
|
||||
if (!CLASSES_WITH_NON_BOXED_CHARS.contains(containingClassName) &&
|
||||
!KotlinBuiltIns.isPrimitiveType(containingClass.getDefaultType()) &&
|
||||
!KotlinBuiltIns.isPrimitiveArray(containingClassName)
|
||||
) {
|
||||
return getAnyTypeFromSameModule(descriptor);
|
||||
}
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
|
||||
Set<KotlinType> typesFromOverriddenCallables = overridden.stream()
|
||||
.map(TranslationUtils::getReturnTypeForCoercion)
|
||||
.map(o -> getReturnTypeForCoercion(o, forcePrivate))
|
||||
.collect(Collectors.toSet());
|
||||
return typesFromOverriddenCallables.size() == 1
|
||||
? typesFromOverriddenCallables.iterator().next()
|
||||
: DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
: getAnyTypeFromSameModule(descriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static KotlinType getAnyTypeFromSameModule(@NotNull DeclarationDescriptor descriptor) {
|
||||
return DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -435,7 +472,7 @@ public final class TranslationUtils {
|
||||
.collect(Collectors.toSet());
|
||||
return typesFromOverriddenCallables.size() == 1
|
||||
? typesFromOverriddenCallables.iterator().next()
|
||||
: DescriptorUtils.getContainingModule(descriptor).getBuiltIns().getAnyType();
|
||||
: getAnyTypeFromSameModule(descriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
32
js/js.translator/testData/box/char/topLevelCallables.kt
vendored
Normal file
32
js/js.translator/testData/box/char/topLevelCallables.kt
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// SKIP_MINIFICATION
|
||||
fun foo(): Char = '1'
|
||||
|
||||
val p1: Char = '2'
|
||||
|
||||
var p2: Char = '3'
|
||||
|
||||
var p3: Char = '4'
|
||||
get() = field + 1
|
||||
set(value) {
|
||||
field = value + 1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var root = eval("_")
|
||||
|
||||
var r = typeOf(root.foo())
|
||||
if (r !== "number") return "fail1: $r"
|
||||
|
||||
r = typeOf(root.p1)
|
||||
if (r !== "number") return "fail2: $r"
|
||||
|
||||
r = typeOf(root.p2)
|
||||
if (r !== "number") return "fail3: $r"
|
||||
|
||||
r = typeOf(root.p3)
|
||||
if (r !== "number") return "fail4: $r"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun typeOf(x: dynamic): String = js("typeof x")
|
||||
24
js/js.translator/testData/box/char/unboxedCharSpecials.kt
vendored
Normal file
24
js/js.translator/testData/box/char/unboxedCharSpecials.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1099
|
||||
private inline fun typeOf(x: dynamic): String = js("typeof x").unsafeCast<String>()
|
||||
|
||||
fun box(): String {
|
||||
val arr = charArrayOf('A')
|
||||
|
||||
var r = typeOf(arr.iterator().asDynamic().nextChar())
|
||||
if (r != "number") return "fail1: $r"
|
||||
r = typeOf(arr.iterator().asDynamic().next())
|
||||
if (r != "object") return "fail1a: $r"
|
||||
|
||||
var progression = 'A'..'Z'
|
||||
r = typeOf(progression.asDynamic().first)
|
||||
if (r != "number") return "fail2: $r"
|
||||
r = typeOf(progression.asDynamic().last)
|
||||
if (r != "number") return "fail3: $r"
|
||||
|
||||
r = typeOf(Char.asDynamic().MIN_HIGH_SURROGATE)
|
||||
if (r != "number") return "fail4: $r"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun getInt() = 65
|
||||
41
js/js.translator/testData/box/coercion/bridgeChar.kt
vendored
Normal file
41
js/js.translator/testData/box/coercion/bridgeChar.kt
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1039
|
||||
open class A {
|
||||
fun foo(): Char = 'X'
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun foo(): Any
|
||||
}
|
||||
|
||||
class B : A(), I
|
||||
|
||||
fun typeOf(x: dynamic): String = js("typeof x")
|
||||
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
val i: I = B()
|
||||
val a: A = B()
|
||||
|
||||
val r1 = typeOf(b.asDynamic().foo())
|
||||
if (r1 != "object") return "fail1: $r1"
|
||||
|
||||
val r2 = typeOf(i.asDynamic().foo())
|
||||
if (r2 != "object") return "fail2: $r2"
|
||||
|
||||
val r3 = typeOf(a.asDynamic().foo())
|
||||
if (r3 != "object") return "fail3: $r3"
|
||||
|
||||
val x4 = b.foo()
|
||||
val r4 = typeOf(x4)
|
||||
if (r4 != "number") return "fail4: $r4"
|
||||
|
||||
val x5 = i.foo()
|
||||
val r5 = typeOf(x5)
|
||||
if (r5 != "object") return "fail5: $r5"
|
||||
|
||||
val x6 = a.foo()
|
||||
val r6 = typeOf(x6)
|
||||
if (r6 != "number") return "fail6: $r6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
70
js/js.translator/testData/box/coercion/propertyBridgeChar.kt
vendored
Normal file
70
js/js.translator/testData/box/coercion/propertyBridgeChar.kt
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1039
|
||||
open class A {
|
||||
val foo: Char
|
||||
get() = 'X'
|
||||
|
||||
var bar: Char = 'Y'
|
||||
|
||||
val baz: Char = 'Q'
|
||||
|
||||
var mutable: Char = 'W'
|
||||
get() {
|
||||
typeOfMutable += typeOf(field.asDynamic()) + ";"
|
||||
return field + 1
|
||||
}
|
||||
set(value) {
|
||||
typeOfMutable += typeOf(js("value")) + ";" + typeOf(value)
|
||||
field = value
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
val foo: Any
|
||||
|
||||
val bar: Any
|
||||
|
||||
val baz: Any
|
||||
|
||||
val mutable: Any
|
||||
}
|
||||
|
||||
class B : A(), I
|
||||
|
||||
fun typeOf(x: dynamic): String = js("typeof x")
|
||||
|
||||
var typeOfMutable = ""
|
||||
|
||||
fun box(): String {
|
||||
val a = B()
|
||||
val b: I = B()
|
||||
|
||||
val r1 = typeOf(a.foo)
|
||||
if (r1 != "number") return "fail1: $r1"
|
||||
|
||||
val r2 = typeOf(b.foo)
|
||||
if (r2 != "object") return "fail2: $r2"
|
||||
|
||||
val r3 = typeOf(a.asDynamic().foo)
|
||||
if (r3 != "object") return "fail3: $r3"
|
||||
|
||||
val r4 = typeOf(a.asDynamic().bar)
|
||||
if (r4 != "object") return "fail4: $r4"
|
||||
|
||||
val r5 = typeOf(a.asDynamic().baz)
|
||||
if (r5 != "object") return "fail5: $r5"
|
||||
|
||||
a.bar++
|
||||
val r6 = typeOf(a.asDynamic().bar)
|
||||
if (r6 != "object") return "fail6: $r6"
|
||||
|
||||
val r7 = typeOf(a.asDynamic().mutable)
|
||||
if (r7 != "object") return "fail7: $r7"
|
||||
|
||||
a.mutable = 'E'
|
||||
if (typeOfMutable != "number;object;number") return "fail8: $typeOfMutable"
|
||||
|
||||
val r9 = typeOf(a.mutable)
|
||||
if (r9 != "number") return "fail9: $r9"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -6,7 +6,8 @@ class CC(val s: CharSequence) : CharSequence by s, MyCharSequence {}
|
||||
interface MyCharSequence {
|
||||
val length: Int
|
||||
|
||||
operator fun get(index: Int): Char
|
||||
// TODO: uncomment when it's possible to implement bridges for get/charCodeAt
|
||||
//operator fun get(index: Int): Char
|
||||
|
||||
fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||
}
|
||||
@@ -25,17 +26,17 @@ fun box(): String {
|
||||
val cc: CharSequence = CC(kotlin)
|
||||
if (cc.length != 6) return "Fail 3: ${cc.length}"
|
||||
if (cc.subSequence(0, 3) != kot) return "Fail 4"
|
||||
if (cc[2] != 't') return "Fail 5: ${cc[2]}"
|
||||
//if (cc[2] != 't') return "Fail 5: ${cc[2]}"
|
||||
|
||||
val mcc: MyCharSequence = CC(kotlin)
|
||||
if (mcc.length != 6) return "Fail 6: ${mcc.length}"
|
||||
if (mcc.subSequence(0, 3) != kot) return "Fail 7"
|
||||
if (mcc[2] != 't') return "Fail 8: ${mcc[2]}"
|
||||
//if (mcc[2] != 't') return "Fail 8: ${mcc[2]}"
|
||||
|
||||
val ccc = CC(cc)
|
||||
if (ccc.length != 6) return "Fail 6: ${ccc.length}"
|
||||
if (ccc.subSequence(0, 3) != kot) return "Fail 7"
|
||||
if (ccc[2] != 't') return "Fail 8: ${ccc[2]}"
|
||||
//if (ccc[2] != 't') return "Fail 8: ${ccc[2]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-jsr223-daemon-local-eval-example</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Sample Kotlin JSR 223 scripting jar with daemon (out-of-process) compilation and local (in-process) evaluation</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>test-compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-jsr223-local-example</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Sample Kotlin JSR 223 scripting jar with local (in-process) compilation and evaluation</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>test-compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -121,7 +121,7 @@ compileBuiltinsKotlin {
|
||||
freeCompilerArgs = [
|
||||
"-version",
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xdump-declarations-to", "${buildDir}/runtime-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/runtime-declarations.json",
|
||||
"-cp", "${rootDir}/dist/builtins",
|
||||
"-module-name", "kotlin-runtime"
|
||||
]
|
||||
@@ -134,7 +134,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/stdlib-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/stdlib-declarations.json",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jdk7-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/stdlib-jdk7-declarations.json",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jdk8-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/stdlib-jdk8-declarations.json",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jre7-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/stdlib-jre7-declarations.json",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xmultifile-parts-inherit",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jre8-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/stdlib-jre8-declarations.json",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ ext.pluginMarkerProject = { String pluginProjectId ->
|
||||
apply plugin: 'java'
|
||||
|
||||
dependencies {
|
||||
compile pluginProject
|
||||
compile project(path: pluginProject.path, configuration: 'runtimeJar')
|
||||
}
|
||||
|
||||
// Remove the default JAR artifact added by the Java plugin
|
||||
|
||||
@@ -19,28 +19,16 @@ dependencies {
|
||||
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
|
||||
}
|
||||
|
||||
def originalSrc = "$kotlin_root/plugins/allopen/allopen-cli/src"
|
||||
//def targetSrc = file("$buildDir/allopen-target-src")
|
||||
//
|
||||
//task preprocessSources(type: Copy) {
|
||||
// from originalSrc
|
||||
// into targetSrc
|
||||
// filter { it.replaceAll('(?<!\\.)com\\.intellij', 'org.jetbrains.kotlin.com.intellij') }
|
||||
//}
|
||||
|
||||
//sourceSets.main.java.srcDirs += originalSrc
|
||||
|
||||
//compileKotlin.dependsOn preprocessSources
|
||||
|
||||
evaluationDependsOn(":kotlin-allopen-compiler-plugin")
|
||||
|
||||
jar {
|
||||
// from(originalSrc) { include("META-INF/**") }
|
||||
from(project(":kotlin-allopen-compiler-plugin").sourceSets.main.output.classesDirs)
|
||||
from(project(":kotlin-allopen-compiler-plugin").sourceSets.main.output.resourcesDir)
|
||||
manifestAttributes(manifest, project)
|
||||
}
|
||||
|
||||
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-android-extensions-runtime</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>A runtime library for Kotlin Android Extensions plugin</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/../../../plugins/android-extensions/android-extensions-runtime/src</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,135 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
<android-extensions.src>${basedir}/../../../plugins/android-extensions/android-extensions-compiler/src</android-extensions.src>
|
||||
<android-extensions-runtime.src>${basedir}/../../../plugins/android-extensions/android-extensions-runtime/src</android-extensions-runtime.src>
|
||||
<android-extensions.target-src>${basedir}/target/src</android-extensions.target-src>
|
||||
<android-extensions.target-resource>${basedir}/target/resource</android-extensions.target-resource>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-android-extensions</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Android compiler plugin for Kotlin</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${android-extensions.target-src}</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${android-extensions.target-resource}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${android-extensions.target-src}</outputDirectory>
|
||||
<resources>
|
||||
<resource><directory>${android-extensions.src}</directory></resource>
|
||||
<resource><directory>${android-extensions-runtime.src}</directory></resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${android-extensions.target-resource}/META-INF</outputDirectory>
|
||||
<resources>
|
||||
<resource><directory>${android-extensions.src}/META-INF</directory></resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${android-extensions.target-src}/**</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>(?<!\.)com\.intellij</token>
|
||||
<value>org.jetbrains.kotlin.com.intellij</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${android-extensions.target-src}</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-utils</id>
|
||||
<url>http://repository.jetbrains.com/utils</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@@ -1,17 +1,9 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
description = "Annotation Processor wrapper for Kotlin"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||
}
|
||||
}
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
val packedJars by configurations.creating
|
||||
@@ -25,16 +17,27 @@ dependencies {
|
||||
testCompile("com.android.tools.build:gradle:1.1.0")
|
||||
testCompile(commonDep("junit:junit"))
|
||||
packedJars(project(":kotlin-annotation-processing")) { isTransitive = false }
|
||||
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
}
|
||||
|
||||
projectTest {
|
||||
workingDir = projectDir
|
||||
}
|
||||
|
||||
runtimeJar(task<ShadowJar>("shadowJar")) {
|
||||
from(packedJars)
|
||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||
}
|
||||
//noDefaultJar()
|
||||
//tasks.remove(tasks.findByName("jar"))
|
||||
//
|
||||
//runtimeJar(task<ShadowJar>("jar")) {
|
||||
// from(packedJars)
|
||||
// from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||
// configureRelocation()
|
||||
//}
|
||||
runtimeJar(rewriteDepsToShadedCompiler(
|
||||
task<ShadowJar>("shadowJar") {
|
||||
from(packedJars)
|
||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||
}
|
||||
))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
The presence of this file enables the "tools_jar_profile" profile in kotlin-annotation-processing,
|
||||
which adds "tools.jar" to the compile dependencies.
|
||||
|
||||
When Gradle loads this artifact, the "tools_jar_profile" profile should not be activated
|
||||
(cause it adds an extra dependency from the path based on the environment variable).
|
||||
|
||||
It wouldn't in fact because:
|
||||
1. This file is normally absent when Gradle build with kapt is launched;
|
||||
2. Gradle poorly supports Maven profiles.
|
||||
@@ -1,204 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
<old-kapt.src>${basedir}/src/main/kotlin</old-kapt.src>
|
||||
<annotation-processing.src>${basedir}/../../../plugins/kapt3/src</annotation-processing.src>
|
||||
<annotation-processing.target-src>${basedir}/target/src/main/kotlin</annotation-processing.target-src>
|
||||
<annotation-processing.target-src-test>${basedir}/target/src/test/kotlin</annotation-processing.target-src-test>
|
||||
<annotation-processing.target-resource>${basedir}/target/resource</annotation-processing.target-resource>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-annotation-processing</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Annotation Processor wrapper for Kotlin</description>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-utils</id>
|
||||
<url>http://repository.jetbrains.com/utils</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>gradle-api</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.android.tools.build</groupId>
|
||||
<artifactId>gradle</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${annotation-processing.target-src}</sourceDirectory>
|
||||
<testSourceDirectory>${annotation-processing.target-src-test}</testSourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${annotation-processing.target-resource}</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${annotation-processing.target-src}</outputDirectory>
|
||||
<resources>
|
||||
<resource><directory>${annotation-processing.src}</directory></resource>
|
||||
<resource><directory>${old-kapt.src}</directory></resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${annotation-processing.target-resource}/META-INF</outputDirectory>
|
||||
<resources>
|
||||
<resource><directory>${annotation-processing.src}/META-INF</directory></resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${annotation-processing.target-src}/**</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>(?<!\.)com\.intellij</token>
|
||||
<value>org.jetbrains.kotlin.com.intellij</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<jdkHome>${env.JDK_18}</jdkHome>
|
||||
<annotationPaths>
|
||||
<annotationPath>${basedir}/kotlinAnnotation</annotationPath>
|
||||
</annotationPaths>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${annotation-processing.target-src}</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>test-compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>tools_jar_profile</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
<file>
|
||||
<exists>kotlin-annotation-processing-maven-build.txt</exists>
|
||||
</file>
|
||||
</activation>
|
||||
<properties>
|
||||
<toolsjar>${env.JDK_18}/lib/tools.jar</toolsjar>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${toolsjar}</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -22,3 +22,5 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
dist()
|
||||
|
||||
publish()
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-build-common-test</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Testing utils (for incremental compilation mostly)</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>empty-sources-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skipIfEmpty>false</skipIfEmpty>
|
||||
<classifier>sources</classifier>
|
||||
<classesDirectory>${basedir}/sources</classesDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jar</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${kotlin-dist}/kotlinc/lib/kotlin-build-common-test.jar"
|
||||
tofile="${basedir}/target/${project.artifactId}-${project.version}.jar"
|
||||
overwrite="true" verbose="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-compiler-client-embeddable-test</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>the Kotlin compiler client embeddable tests</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-runtime</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-client-embeddable</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>properties</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>test-compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<workingDirectory>${project.build.directory}</workingDirectory>
|
||||
<systemPropertyVariables>
|
||||
<jvm>${env.JDK_17}/bin/java</jvm>
|
||||
<compilerJar>${org.jetbrains.kotlin:kotlin-compiler:jar}</compilerJar>
|
||||
<stdlibJar>${org.jetbrains.kotlin:kotlin-stdlib:jar}</stdlibJar>
|
||||
<scriptRuntimeJar>${org.jetbrains.kotlin:kotlin-script-runtime:jar}</scriptRuntimeJar>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-compiler-client-embeddable</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>the Kotlin compiler client embeddable</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-sources</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${basedir}/../../../compiler/cli/cli-common/src</source>
|
||||
<source>${basedir}/../../../compiler/daemon/daemon-common/src</source>
|
||||
<source>${basedir}/../../../compiler/daemon/daemon-client/src</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>attach-empty-javadoc</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jar</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${kotlin-dist}/kotlinc/lib/kotlin-compiler-client-embeddable.jar"
|
||||
tofile="${basedir}/target/${project.artifactId}-${project.version}.jar"
|
||||
overwrite="true" verbose="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,176 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
<surefire-version>2.16</surefire-version>
|
||||
<kotlin.relocated.package>org.jetbrains.kotlin</kotlin.relocated.package>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>the Kotlin compiler embeddable</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>native-platform</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testSourceDirectory>test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-sources-for-shade-plugin</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<createSourcesJar>true</createSourcesJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:kotlin-compiler</artifact>
|
||||
<excludes>
|
||||
<exclude>com/sun/jna/**</exclude>
|
||||
<exclude>net/rubygrapefruit/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.intellij</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.com.intellij</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.com.google</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.org.apache</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jdom</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.org.jdom</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.fusesource</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.org.fusesource</shadedPattern>
|
||||
<excludes>
|
||||
<exclude>org.fusesource.jansi.internal.CLibrary</exclude>
|
||||
</excludes>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.picocontainer</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.org.picocontainer</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jline</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.org.jline</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>gnu</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.gnu</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.inject</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.javax.inject</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>kotlinx.coroutines</pattern>
|
||||
<shadedPattern>${kotlin.relocated.package}.kotlinx.coroutines</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire-version}</version>
|
||||
<configuration>
|
||||
<workingDirectory>${project.build.directory}</workingDirectory>
|
||||
<systemPropertyVariables>
|
||||
<compilerJar>${project.artifactId}-${project.parent.version}.jar</compilerJar>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration-test</id>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<phase>integration-test</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,102 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
<daemon-client.target-src>${basedir}/target/src/main/kotlin</daemon-client.target-src>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-compiler-runner</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Compiler runner + daemon client</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${daemon-client.target-src}</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${daemon-client.target-src}</outputDirectory>
|
||||
<resources>
|
||||
<resource><directory>${project-root}/compiler/daemon/daemon-client/src</directory></resource>
|
||||
<resource><directory>${project-root}/compiler/compiler-runner/src</directory></resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${daemon-client.target-src}/**</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>(?<!\.)com\.intellij</token>
|
||||
<value>org.jetbrains.kotlin.com.intellij</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${daemon-client.target-src}</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>the Kotlin compiler</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-artifacts</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifacts>
|
||||
<artifact>
|
||||
<file>${kotlin-dist}/kotlin-compiler-sources.jar</file>
|
||||
<type>jar</type>
|
||||
<classifier>sources</classifier>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jar</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${kotlin-dist}/kotlin-compiler-for-maven.jar"
|
||||
tofile="${basedir}/target/${project.artifactId}-${project.version}.jar"
|
||||
overwrite="true" verbose="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-daemon-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>the Kotlin compile daemon client</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-sources</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${basedir}/../../../compiler/daemon/daemon-common/src</source>
|
||||
<source>${basedir}/../../../compiler/daemon/daemon-client/src</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>attach-empty-javadoc</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jar</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${kotlin-dist}/kotlinc/lib/kotlin-daemon-client.jar"
|
||||
tofile="${basedir}/target/${project.artifactId}-${project.version}.jar"
|
||||
overwrite="true" verbose="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -24,6 +24,8 @@ dependencies {
|
||||
testCompile project(path: ':compiler:incremental-compilation-impl', configuration: 'tests-jar')
|
||||
|
||||
testCompile 'org.jetbrains.kotlin:gradle-api:2.2'
|
||||
|
||||
testRuntime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar')
|
||||
}
|
||||
|
||||
test.dependsOn(":kotlin-allopen:install",
|
||||
|
||||
@@ -32,9 +32,9 @@ dependencies {
|
||||
compileOnly project(':compiler:incremental-compilation-impl')
|
||||
|
||||
compile project(':kotlin-stdlib')
|
||||
compile project(':kotlin-android-extensions')
|
||||
compile project(':kotlin-build-common')
|
||||
compile project(':kotlin-compiler-runner')
|
||||
compileOnly project(':kotlin-android-extensions')
|
||||
compileOnly project(':kotlin-build-common')
|
||||
compileOnly project(':kotlin-compiler-runner')
|
||||
compileOnly project(':kotlin-annotation-processing')
|
||||
compileOnly project(':kotlin-annotation-processing-gradle')
|
||||
|
||||
@@ -44,6 +44,8 @@ dependencies {
|
||||
|
||||
runtime project(path: ':kotlin-compiler-embeddable', configuration: "runtimeJar")
|
||||
runtime project(path: ':kotlin-annotation-processing-gradle', configuration: "runtimeJar")
|
||||
runtime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar')
|
||||
runtime project(path: ':kotlin-compiler-runner', configuration: 'runtimeJar')
|
||||
|
||||
agp25CompileOnly 'com.android.tools.build:gradle:3.0.0-alpha1'
|
||||
agp25CompileOnly 'org.codehaus.groovy:groovy-all:2.3.9'
|
||||
@@ -53,6 +55,8 @@ dependencies {
|
||||
|
||||
testCompileOnly project(':compiler')
|
||||
testCompile project (path: ':kotlin-build-common', configuration: 'tests-jar')
|
||||
testCompile project(':kotlin-android-extensions')
|
||||
testCompile project(':kotlin-compiler-runner')
|
||||
testCompile project(':kotlin-test::kotlin-test-junit')
|
||||
testCompile "junit:junit:4.12"
|
||||
testCompileOnly project(':kotlin-annotation-processing')
|
||||
@@ -93,6 +97,8 @@ jar {
|
||||
manifestAttributes(manifest, project)
|
||||
}
|
||||
|
||||
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.android.build.gradle.BasePlugin
|
||||
import com.android.build.gradle.api.AndroidSourceSet
|
||||
import com.android.builder.model.SourceProvider
|
||||
import groovy.lang.Closure
|
||||
import org.apache.tools.ant.util.ReflectUtil.newInstance
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
@@ -456,12 +455,16 @@ internal open class KotlinAndroidPlugin(
|
||||
|
||||
val legacyVersionThreshold = "2.5.0"
|
||||
|
||||
val variantProcessor = if (compareVersionNumbers(version, legacyVersionThreshold) < 0)
|
||||
val variantProcessor = if (compareVersionNumbers(version, legacyVersionThreshold) < 0) {
|
||||
LegacyAndroidAndroidProjectHandler(kotlinTools)
|
||||
else
|
||||
newInstance(
|
||||
Class.forName("org.jetbrains.kotlin.gradle.plugin.Android25ProjectHandler"),
|
||||
arrayOf(kotlinTools.javaClass), arrayOf(kotlinTools)) as AbstractAndroidProjectHandler<*>
|
||||
}
|
||||
else {
|
||||
val android25ProjectHandlerClass = Class.forName("org.jetbrains.kotlin.gradle.plugin.Android25ProjectHandler")
|
||||
val ctor = android25ProjectHandlerClass.constructors.single {
|
||||
it.parameterTypes.contentEquals(arrayOf(kotlinTools.javaClass))
|
||||
}
|
||||
ctor.newInstance(kotlinTools) as AbstractAndroidProjectHandler<*>
|
||||
}
|
||||
|
||||
variantProcessor.handleProject(project)
|
||||
}
|
||||
|
||||
@@ -25,28 +25,16 @@ dependencies {
|
||||
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
|
||||
}
|
||||
|
||||
def originalSrc = "$kotlin_root/plugins/noarg/noarg-cli/src"
|
||||
//def targetSrc = file("$buildDir/noarg-target-src")
|
||||
//
|
||||
//task preprocessSources(type: Copy) {
|
||||
// from originalSrc
|
||||
// into targetSrc
|
||||
// filter { it.replaceAll('(?<!\\.)com\\.intellij', 'org.jetbrains.kotlin.com.intellij') }
|
||||
//}
|
||||
|
||||
//sourceSets.main.java.srcDirs += originalSrc
|
||||
|
||||
//compileKotlin.dependsOn preprocessSources
|
||||
|
||||
evaluationDependsOn(":kotlin-noarg-compiler-plugin")
|
||||
|
||||
jar {
|
||||
// from(originalSrc) { include("META-INF/**") }
|
||||
from(project(":kotlin-noarg-compiler-plugin").sourceSets.main.output.classesDirs)
|
||||
from(project(":kotlin-noarg-compiler-plugin").sourceSets.main.output.resourcesDir)
|
||||
manifestAttributes(manifest, project)
|
||||
}
|
||||
|
||||
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
|
||||
@@ -74,7 +74,7 @@ compileKotlin {
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-module-name", "kotlin-reflection",
|
||||
"-Xdump-declarations-to", "${buildDir}/reflect-declarations.json"]
|
||||
"-Xdump-declarations-to=${buildDir}/reflect-declarations.json"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-sam-with-receiver-compiler-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Kotlin compiler plugin adding SamWithReceiver functionality</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/../../../plugins/sam-with-receiver/sam-with-receiver-cli/src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../../../plugins/sam-with-receiver/sam-with-receiver-cli/src</directory>
|
||||
<includes>
|
||||
<include>META-INF/**</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -25,28 +25,16 @@ dependencies {
|
||||
compileOnly 'org.jetbrains.kotlin:gradle-api:1.6'
|
||||
}
|
||||
|
||||
def originalSrc = "$kotlin_root/plugins/sam-with-receiver/sam-with-receiver-cli/src"
|
||||
//def targetSrc = file("$buildDir/sam-with-receiver-target-src")
|
||||
//
|
||||
//task preprocessSources(type: Copy) {
|
||||
// from originalSrc
|
||||
// into targetSrc
|
||||
// filter { it.replaceAll('(?<!\\.)com\\.intellij', 'org.jetbrains.kotlin.com.intellij') }
|
||||
//}
|
||||
|
||||
//sourceSets.main.java.srcDirs += originalSrc
|
||||
|
||||
//compileKotlin.dependsOn preprocessSources
|
||||
|
||||
evaluationDependsOn(":kotlin-sam-with-receiver-compiler-plugin")
|
||||
|
||||
jar {
|
||||
// from(originalSrc) { include("META-INF/**") }
|
||||
from(project(":kotlin-sam-with-receiver-compiler-plugin").sourceSets.main.output.classesDirs)
|
||||
from(project(":kotlin-sam-with-receiver-compiler-plugin").sourceSets.main.output.resourcesDir)
|
||||
manifestAttributes(manifest, project)
|
||||
}
|
||||
|
||||
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Kotlin scripting support utilities</description>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-utils</id>
|
||||
<url>http://repository.jetbrains.com/utils</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-runtime</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-daemon-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jcabi</groupId>
|
||||
<artifactId>jcabi-aether</artifactId>
|
||||
<version>0.10.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sonatype.aether</groupId>
|
||||
<artifactId>aether-api</artifactId>
|
||||
<version>1.13.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>properties</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>test-compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jvm>${env.JDK_17}/bin/java</jvm>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kotlin-source-sections-compiler-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>Kotlin compiler plugin adding source sections filtering functionality</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/../../../plugins/source-sections/source-sections-compiler/src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../../../plugins/source-sections/source-sections-compiler/src</directory>
|
||||
<includes>
|
||||
<include>META-INF/**</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals> <goal>compile</goal> </goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>native-platform</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>A dependency for daemon client</description>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project-root}/compiler/compiler-runner/src</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>empty-sources-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skipIfEmpty>false</skipIfEmpty>
|
||||
<classifier>sources</classifier>
|
||||
<classesDirectory>${basedir}/sources</classesDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-jar</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${project-root}/dependencies/native-platform-uberjar.jar"
|
||||
tofile="${basedir}/target/${project.artifactId}-${project.version}.jar"
|
||||
overwrite="true" verbose="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -46,7 +46,7 @@ compileKotlin {
|
||||
freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xdump-declarations-to", "${buildDir}/runtime-declarations.json",
|
||||
"-Xdump-declarations-to=${buildDir}/runtime-declarations.json",
|
||||
"-cp", "${rootDir}/dist/builtins",
|
||||
"-module-name", project.name
|
||||
]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
description = "Kotlin Android Extensions Runtime"
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
jvmTarget = "1.6"
|
||||
|
||||
dependencies {
|
||||
compile(project(":kotlin-stdlib"))
|
||||
compile(ideaPluginDeps("layoutlib", plugin = "android"))
|
||||
runtime(commonDep("com.google.android", "android"))
|
||||
compileOnly(commonDep("com.google.android", "android"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
description = "Kotlin Android Extensions Compiler"
|
||||
|
||||
@@ -30,42 +14,26 @@ dependencies {
|
||||
compileOnly(project(":compiler:backend"))
|
||||
compileOnly(project(":kotlin-android-extensions-runtime"))
|
||||
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
runtime(commonDep("com.google.android", "android"))
|
||||
compileOnly(commonDep("com.google.android", "android"))
|
||||
}
|
||||
|
||||
//val originalSrc = "$projectDir/src"
|
||||
//val targetSrc = file("$buildDir/embeddable-target-src")
|
||||
//
|
||||
//if (System.getProperty("idea.active") == null) {
|
||||
//
|
||||
// val prepareEmbeddableSources by task<Copy> {
|
||||
// from(originalSrc)
|
||||
// into(targetSrc)
|
||||
// filter { it.replace(Regex("(?<!\\.)com\\.intellij"), "org.jetbrains.kotlin.com.intellij") }
|
||||
// }
|
||||
//
|
||||
// tasks.withType<KotlinCompile> { dependsOn(prepareEmbeddableSources) }
|
||||
// tasks.withType<JavaCompile> { dependsOn(prepareEmbeddableSources) }
|
||||
//}
|
||||
|
||||
|
||||
sourceSets {
|
||||
"main" {
|
||||
// if (System.getProperty("idea.active") == null) {
|
||||
// java.srcDir(targetSrc)
|
||||
// resources.srcDir("src").apply { include("META-INF/**", "**/*.properties") }
|
||||
// }
|
||||
// else {
|
||||
projectDefault()
|
||||
// }
|
||||
}
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
from(getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs)
|
||||
// fixes a deadlock in projects evaluation order for :plugins:android-extensions-compiler
|
||||
evaluationDependsOn(":plugins")
|
||||
|
||||
val jar: Jar by tasks
|
||||
jar.apply {
|
||||
from(getSourceSetsFrom(":plugins:android-extensions-compiler")["main"].output)
|
||||
from(getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output)
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
}
|
||||
|
||||
runtimeJar(rewriteDepsToShadedCompiler(jar))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
@@ -29,6 +29,6 @@ artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
|
||||
val distKotlinHomeDir: String by rootProject.extra
|
||||
|
||||
val dist by task<Copy> {
|
||||
from(prepare)
|
||||
into(File(distKotlinHomeDir))
|
||||
from(buildVersionFilePath)
|
||||
}
|
||||
|
||||
@@ -1,65 +1,24 @@
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
description = "Kotlin Compiler (embeddable)"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
`java`
|
||||
}
|
||||
|
||||
val compilerJar by configurations.creating
|
||||
|
||||
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
|
||||
|
||||
val packagesToRelocate =
|
||||
listOf(
|
||||
// "com.intellij",
|
||||
"com.google",
|
||||
"com.sampullara",
|
||||
"org.apache",
|
||||
"org.jdom",
|
||||
"org.picocontainer",
|
||||
"jline",
|
||||
"gnu",
|
||||
"javax.inject",
|
||||
"org.fusesource")
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
|
||||
compilerJar(projectRuntimeJar(":kotlin-compiler"))
|
||||
|
||||
compile(project(":kotlin-stdlib"))
|
||||
compile(project(":kotlin-script-runtime"))
|
||||
compile(project(":kotlin-reflect"))
|
||||
runtime(project(":kotlin-stdlib"))
|
||||
runtime(project(":kotlin-script-runtime"))
|
||||
runtime(project(":kotlin-reflect"))
|
||||
}
|
||||
|
||||
noDefaultJar()
|
||||
|
||||
runtimeJar(task<ShadowJar>("embeddable")) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
// dependsOn(":kotlin-compiler:proguard")
|
||||
from(compilerJar)
|
||||
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
||||
packagesToRelocate.forEach {
|
||||
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
||||
}
|
||||
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
||||
// TODO: remove "it." after #KT-12848 get addressed
|
||||
exclude("org.fusesource.jansi.internal.CLibrary")
|
||||
}
|
||||
}
|
||||
// dummy is used for rewriting dependencies to the shaded packages in the embeddable compiler
|
||||
compilerDummyJar(compilerDummyForDependenciesRewriting("compilerDummy") {
|
||||
classifier = "dummy"
|
||||
})
|
||||
|
||||
runtimeJar(embeddableCompiler())
|
||||
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
Reference in New Issue
Block a user