Merge branch 'master' into KT-18765
This commit is contained in:
@@ -216,7 +216,6 @@ ext.createScriptTask = { Project project, def name, Closure<JavaExec> configureC
|
||||
return project.configure(task) {
|
||||
// dependsOn(rootProject.prepareBootstrap)
|
||||
classpath = rootProject.configurations.scriptCompile
|
||||
println(rootProject.configurations.scriptCompile.files)
|
||||
main = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
||||
args = [
|
||||
"-script",
|
||||
|
||||
@@ -70,6 +70,6 @@ public class KotlinVersion(val major: Int, val minor: Int, val patch: Int) : Com
|
||||
*/
|
||||
// TODO: get from metadata or hardcode automatically during build
|
||||
@kotlin.jvm.JvmField
|
||||
public val CURRENT: KotlinVersion = KotlinVersion(1, 1, 50)
|
||||
public val CURRENT: KotlinVersion = KotlinVersion(1, 1, 60)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? = if (!predica
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
||||
for (index in 0..times - 1) {
|
||||
for (index in 0 until times) {
|
||||
action(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ apply { plugin("kotlin") }
|
||||
val packedJars by configurations.creating
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":kotlin-annotation-processing"))
|
||||
compile("org.jetbrains.kotlin:gradle-api:1.6")
|
||||
compile("com.android.tools.build:gradle:1.1.0")
|
||||
compile(projectDist(":kotlin-stdlib"))
|
||||
compileOnly(project(":kotlin-annotation-processing"))
|
||||
compileOnly("org.jetbrains.kotlin:gradle-api:1.6")
|
||||
testCompile("org.jetbrains.kotlin:gradle-api:1.6")
|
||||
compileOnly("com.android.tools.build:gradle:1.1.0")
|
||||
testCompile("com.android.tools.build:gradle:1.1.0")
|
||||
testCompile(commonDep("junit:junit"))
|
||||
packedJars(project(":kotlin-annotation-processing")) { isTransitive = false }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
description = 'Kotlin annotations for JVM'
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
configureJvm6Project(project)
|
||||
configurePublishing(project)
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin {
|
||||
srcDir 'src'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
}
|
||||
|
||||
dist {
|
||||
from (jar, sourcesJar)
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
kotlinOptions.jdkHome = JDK_16
|
||||
kotlinOptions.jvmTarget = 1.6
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.freeCompilerArgs = [
|
||||
"-Xallow-kotlin-package",
|
||||
"-module-name", project.name
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 kotlin.annotations.jvm
|
||||
|
||||
/**
|
||||
* Contains the list of possible migration statuses.
|
||||
*/
|
||||
public enum class MigrationStatus {
|
||||
IGNORE,
|
||||
WARN,
|
||||
@Deprecated("experimental feature")
|
||||
STRICT
|
||||
}
|
||||
|
||||
/**
|
||||
* This meta-annotation is intended for user nullability annotations with JSR-305 type qualifiers. Behaviour of meta-annotated
|
||||
* nullability annotations can be controlled via compilation flag.
|
||||
*/
|
||||
@Target(AnnotationTarget.ANNOTATION_CLASS)
|
||||
public annotation class UnderMigration(val status: MigrationStatus)
|
||||
@@ -26,6 +26,37 @@ dependencies {
|
||||
testCompile 'org.jetbrains.kotlin:gradle-api:2.2'
|
||||
}
|
||||
|
||||
test.dependsOn(":kotlin-allopen:install",
|
||||
":kotlin-android-extensions:install",
|
||||
":kotlin-build-common:install",
|
||||
":kotlin-compiler-embeddable:install",
|
||||
":kotlin-gradle-plugin:install",
|
||||
":kotlin-reflect:install",
|
||||
":kotlin-test:kotlin-test-jvm:install",
|
||||
":kotlin-gradle-subplugin-example:install",
|
||||
":kotlin-stdlib-jre8:install")
|
||||
|
||||
// Validate that all dependencies 'install' tasks are added to 'test' dependencies
|
||||
// Test dependencies are specified as paths to avoid forcing dependency resolution
|
||||
// and also to avoid specifying evaluationDependsOn for each testCompile dependency.
|
||||
gradle.taskGraph.whenReady {
|
||||
def notAddedTestTasks = []
|
||||
def testDependencies = test.dependsOn
|
||||
|
||||
for (dependency in configurations.getByName("testCompile").allDependencies) {
|
||||
if (!(dependency instanceof ProjectDependency)) continue
|
||||
|
||||
def task = dependency.dependencyProject.tasks.findByName("install")
|
||||
if (task != null && !testDependencies.contains(task.path)) {
|
||||
notAddedTestTasks.add("\"${task.path}\"")
|
||||
}
|
||||
}
|
||||
|
||||
if (!notAddedTestTasks.isEmpty()) {
|
||||
throw new GradleException("Add the following tasks to ${test.path} dependencies:\n ${notAddedTestTasks.join(",\n ")}")
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
expand(project.properties)
|
||||
}
|
||||
|
||||
+5
-1
@@ -145,7 +145,8 @@ abstract class BaseGradleIT {
|
||||
val forceOutputToStdout: Boolean = false,
|
||||
val debug: Boolean = false,
|
||||
val freeCommandLineArgs: List<String> = emptyList(),
|
||||
val kotlinVersion: String = KOTLIN_VERSION)
|
||||
val kotlinVersion: String = KOTLIN_VERSION,
|
||||
val kotlinDaemonDebugPort: Int? = null)
|
||||
|
||||
open inner class Project(
|
||||
val projectName: String,
|
||||
@@ -438,6 +439,9 @@ abstract class BaseGradleIT {
|
||||
if (options.debug) {
|
||||
add("-Dorg.gradle.debug=true")
|
||||
}
|
||||
options.kotlinDaemonDebugPort?.let { port ->
|
||||
add("-Dkotlin.daemon.jvm.options=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=$port")
|
||||
}
|
||||
addAll(options.freeCommandLineArgs)
|
||||
}
|
||||
|
||||
|
||||
+22
-4
@@ -20,10 +20,7 @@ import org.gradle.api.logging.LogLevel
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.getFilesByNames
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.util.zip.ZipFile
|
||||
@@ -503,6 +500,27 @@ class KotlinGradleIT: BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementalTestCompile() {
|
||||
val project = Project("kotlinProject", GRADLE_VERSION)
|
||||
val options = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
val joinerKt = project.projectDir.getFileByName("KotlinGreetingJoiner.kt")
|
||||
joinerKt.modify {
|
||||
it.replace("class KotlinGreetingJoiner", "internal class KotlinGreetingJoiner")
|
||||
}
|
||||
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
val testJoinerKt = project.projectDir.getFileByName("TestKotlinGreetingJoiner.kt")
|
||||
assertCompiledKotlinSources(project.relativize(joinerKt, testJoinerKt))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLanguageVersionApiVersionExplicit() {
|
||||
val project = Project("kotlinProject", "3.3")
|
||||
|
||||
+6
-21
@@ -1,15 +1,13 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.allKotlinFiles
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class TestRootAffectedIT : BaseGradleIT() {
|
||||
@Test
|
||||
fun testSourceRootClassIsModifiedIC() {
|
||||
val project = Project("kotlinProject", "2.10")
|
||||
val project = Project("kotlinProject", "4.1")
|
||||
val buildOptions = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
@@ -26,8 +24,8 @@ class TestRootAffectedIT : BaseGradleIT() {
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
val expectedToCompile = project.relativize(listOf(kotlinGreetingJoinerFile) + project.allTestKotlinFiles())
|
||||
assertCompiledKotlinSources(expectedToCompile)
|
||||
val testKotlinGreetingJoinerFile = project.projectDir.getFileByName("TestKotlinGreetingJoiner.kt")
|
||||
assertCompiledKotlinSources(project.relativize(kotlinGreetingJoinerFile, testKotlinGreetingJoinerFile))
|
||||
}
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
@@ -38,7 +36,8 @@ class TestRootAffectedIT : BaseGradleIT() {
|
||||
|
||||
@Test
|
||||
fun testSourceRootClassIsRemovedIC() {
|
||||
val project = Project("kotlinProject", "2.10")
|
||||
// todo: update Gradle after https://github.com/gradle/gradle/issues/3051 is resolved
|
||||
val project = Project("kotlinProject", "3.0")
|
||||
val buildOptions = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
@@ -48,12 +47,6 @@ class TestRootAffectedIT : BaseGradleIT() {
|
||||
val dummyFile = project.projectDir.getFileByName("Dummy.kt")
|
||||
dummyFile.delete()
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
val expectedToCompile = project.relativize(project.allTestKotlinFiles())
|
||||
assertCompiledKotlinSources(expectedToCompile)
|
||||
}
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(emptyList())
|
||||
@@ -62,7 +55,7 @@ class TestRootAffectedIT : BaseGradleIT() {
|
||||
|
||||
@Test
|
||||
fun testTestRootClassIsRemovedIC() {
|
||||
val project = Project("kotlinProject", "2.10")
|
||||
val project = Project("kotlinProject", "4.1")
|
||||
val buildOptions = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
@@ -76,13 +69,5 @@ class TestRootAffectedIT : BaseGradleIT() {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(emptyList())
|
||||
}
|
||||
|
||||
project.build("build", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.allTestKotlinFiles(): Iterable<File> =
|
||||
File(projectDir, "src/test").allKotlinFiles()
|
||||
}
|
||||
@@ -80,7 +80,7 @@ jar.dependsOn agp25Classes
|
||||
|
||||
jar {
|
||||
from compileGroovy.destinationDir
|
||||
from sourceSets.agp25.output.classesDir
|
||||
from sourceSets.agp25.output.classesDirs
|
||||
manifestAttributes(manifest, project)
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -36,5 +36,7 @@ internal class GradleIncrementalCompilerEnvironment(
|
||||
compilerArgs: CommonCompilerArguments,
|
||||
val kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null,
|
||||
val artifactDifferenceRegistryProvider: ArtifactDifferenceRegistryProvider? = null,
|
||||
val artifactFile: File? = null
|
||||
val artifactFile: File? = null,
|
||||
val buildHistoryFile: File? = null,
|
||||
val friendBuildHistoryFile: File? = null
|
||||
) : GradleCompilerEnvironment(compilerClasspath, messageCollector, outputItemsCollector, compilerArgs)
|
||||
+3
-1
@@ -255,7 +255,9 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
||||
reportSeverity = reportSeverity(verbose),
|
||||
requestedCompilationResults = arrayOf(CompilationResultCategory.IC_COMPILE_ITERATION.code),
|
||||
compilerMode = CompilerMode.INCREMENTAL_COMPILER,
|
||||
targetPlatform = targetPlatform
|
||||
targetPlatform = targetPlatform,
|
||||
resultDifferenceFile = environment.buildHistoryFile,
|
||||
friendDifferenceFile = environment.friendBuildHistoryFile
|
||||
)
|
||||
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(project, environment)
|
||||
val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray()
|
||||
|
||||
+6
-2
@@ -243,6 +243,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
internal open val sourceRootsContainer = FilteringSourceRootsContainer()
|
||||
|
||||
private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null
|
||||
val buildHistoryFile: File = File(taskBuildDirectory, "build-history.bin")
|
||||
|
||||
val kaptOptions = KaptOptions()
|
||||
|
||||
@@ -316,10 +317,13 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
!incremental -> GradleCompilerEnvironment(computedCompilerClasspath, messageCollector, outputItemCollector, args)
|
||||
else -> {
|
||||
logger.info(USING_INCREMENTAL_COMPILATION_MESSAGE)
|
||||
val friendTask = friendTaskName?.let { project.tasks.findByName(it) as? KotlinCompile }
|
||||
GradleIncrementalCompilerEnvironment(computedCompilerClasspath, changedFiles, reporter, taskBuildDirectory,
|
||||
messageCollector, outputItemCollector, args, kaptAnnotationsFileUpdater,
|
||||
artifactDifferenceRegistryProvider,
|
||||
artifactFile)
|
||||
artifactFile = artifactFile,
|
||||
buildHistoryFile = buildHistoryFile,
|
||||
friendBuildHistoryFile = friendTask?.buildHistoryFile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +457,7 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
|
||||
|
||||
args.friendModules = friendDependency
|
||||
|
||||
args.sourceMapSourceRoots = source.orEmpty()
|
||||
args.sourceMapBaseDirs = source.orEmpty()
|
||||
.asSequence()
|
||||
.filterIsInstance<SourceDirectorySet>()
|
||||
.flatMap { it.srcDirs.asSequence() }
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
[INFO] Kotlin version @snapshot@ (JRE <jre-version>)
|
||||
[INFO] Compiling Kotlin sources from [/test-extension/src/main/kotlin]
|
||||
[INFO] Module name is test-extension
|
||||
[WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath or use '-Xskip-runtime-version-check' to suppress this warning
|
||||
[WARNING] /local-repo/org/jetbrains/kotlin/kotlin-compiler/@snapshot@/kotlin-compiler-@snapshot@.jar: (-1, -1) Library has Kotlin runtime bundled into it
|
||||
[INFO] Kotlin version @snapshot@ (JRE <jre-version>)
|
||||
[WARNING] No sources found skipping Kotlin compile
|
||||
[INFO] Kotlin version @snapshot@ (JRE <jre-version>)
|
||||
[INFO] Compiling Kotlin sources from [/use-test-extension/src/main/kotlin]
|
||||
[INFO] Module name is use-test-extension
|
||||
[INFO] Applicability test for project use-test-extension
|
||||
[INFO] Applied plugin: 'test-me'
|
||||
[INFO] Configuring test plugin with arguments
|
||||
[INFO] Plugin applied
|
||||
[INFO] Option value: my-special-value
|
||||
[INFO] Kotlin version @snapshot@ (JRE <jre-version>)
|
||||
[WARNING] No sources found skipping Kotlin compile
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[INFO] Kotlin version @snapshot@ (JRE <jre-version>)
|
||||
[INFO] Compiling Kotlin sources from [/src/main/kotlin]
|
||||
[INFO] Module name is test-project
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
}
|
||||
}
|
||||
|
||||
arguments.setSourceMapSourceRoots(sourceMapSourceRoots.toString());
|
||||
arguments.setSourceMapBaseDirs(sourceMapSourceRoots.toString());
|
||||
}
|
||||
|
||||
protected List<String> getClassPathElements() throws DependencyResolutionRequiredException {
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
arguments.setDestination(output);
|
||||
|
||||
arguments.setModuleName(moduleName);
|
||||
getLog().info("Module name is " + moduleName);
|
||||
getLog().debug("Module name is " + moduleName);
|
||||
|
||||
if (arguments.getNoOptimize()) {
|
||||
getLog().info("Optimization is turned off");
|
||||
|
||||
+2
-2
@@ -197,7 +197,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
getLog().info("Kotlin version " + KotlinCompilerVersion.VERSION +
|
||||
getLog().debug("Kotlin version " + KotlinCompilerVersion.VERSION +
|
||||
" (JRE " + System.getProperty("java.runtime.version") + ")");
|
||||
|
||||
if (!hasKotlinFilesInSources()) {
|
||||
@@ -433,7 +433,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
if (sourceRoots.isEmpty()) {
|
||||
throw new MojoExecutionException("No source roots to compile");
|
||||
}
|
||||
getLog().info("Compiling Kotlin sources from " + sourceRoots);
|
||||
getLog().debug("Compiling Kotlin sources from " + sourceRoots);
|
||||
return sourceRoots;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user