Compare commits

...

41 Commits

Author SHA1 Message Date
Alexey Tsvetkov
99217acc28 ~ refactor gradle version usage 2019-10-30 19:39:28 +03:00
Alexey Tsvetkov
814153bb85 ~ more heap for native 2019-10-30 16:03:58 +03:00
Alexey Tsvetkov
f0fdd84a5b ~ try bigger max heap size 2019-10-29 23:20:04 +03:00
Alexey Tsvetkov
225690811d ~ fixup 2019-10-29 23:18:53 +03:00
Alexey Tsvetkov
b7d65b7a71 ~ try cache redirector 2019-10-28 11:40:34 +03:00
Alexey Tsvetkov
c7119bf427 ~ use allopen 2019-10-28 11:34:30 +03:00
Alexey Tsvetkov
f477586fb4 Revert "~ use same android sdk in tests"
This reverts commit ffdd1809899eff9258a7a7883677567b5daebb3d.
2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
24df07b6e3 ~ use same android sdk in tests 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
11b4c47186 ~ delete unused project 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
e12887f2e2 ~ add timeout for test daemons 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
1391ff830e ~ fix shutting down daemons in tests 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
8da461928e ~ increase xmx for gradle 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
2a183f4287 Limit memory for Kotlin Native in Gradle integration tests 2019-10-17 01:46:43 +03:00
Alexey Tsvetkov
e589e06828 Add example properties for TC build reproduction to gradle.properties 2019-10-17 01:46:42 +03:00
Alexey Tsvetkov
17981f6055 Set max heap and metaspace sizes for Gradle process 2019-10-17 01:46:42 +03:00
Alexey Tsvetkov
43f9f6688b ~ unzip build tools for gradle sdk 2019-10-17 01:46:42 +03:00
Alexey Tsvetkov
249d731390 ~ remove optional buildToolsVersion from test projects scripts 2019-10-17 01:46:42 +03:00
Alexey Tsvetkov
72eab1812e ~ try full stacktraces 2019-10-17 01:46:42 +03:00
Alexey Tsvetkov
6739e81b27 ~ fix execution strategy test 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
6d5a3a0d71 ~ adjust testMultiplatformAndroidCompile 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
bb3607d946 ~ drop unneeded requirement 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
7b3e8e46a8 ~ fix settings 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
9324a72a45 ~ remove unneeded dep 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
45699a070f ~ make class open 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
c86c90f7fd ~ use asm for tests generation 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
a94befde4b ~ use gradle 5.1 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
131dd3e61b ~ don't waste time rerunning all tasks 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
99136407ac ~ measure time of running gradle in tests 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
1542a3498c ~ revert removing restarting daemon 2019-10-17 01:46:41 +03:00
Alexey Tsvetkov
7a1e4332f3 ~ increase metaspace 2 2019-10-17 01:46:40 +03:00
Alexey Tsvetkov
82b0cb733d ~ increase metaspace 2019-10-17 01:46:40 +03:00
Alexey Tsvetkov
f65aa1d7a9 ~ TEMPORARY ENABLE PARALLEL BUILD PROJECT WIDE 2019-10-17 01:46:40 +03:00
Alexey Tsvetkov
2436f9fe96 ~ timeout fixup 2019-10-17 01:46:40 +03:00
Alexey Tsvetkov
b66a1070ce ~ do not restart new gradle versions in tests 2019-10-17 01:46:39 +03:00
Alexey Tsvetkov
3cf745cb5e ~ fixup 2019-10-17 01:46:39 +03:00
Alexey Tsvetkov
fd686cec3d ~ don't shutdown daemon after each test
use timeouts instead
also always use temporary gradle home
2019-10-17 01:46:39 +03:00
Alexey Tsvetkov
334e07dbc5 ~ add dep on gen tests 2019-10-17 01:46:39 +03:00
Alexey Tsvetkov
943648b56c ~ use tmp gradle home 2019-10-17 01:46:39 +03:00
Alexey Tsvetkov
6a969c3271 ~ run generated tests on teamcity 2019-10-17 01:46:38 +03:00
Alexey Tsvetkov
0b831e3d3f ~ generate tests 2019-10-17 01:46:38 +03:00
Alexey Tsvetkov
910203d17a Use same JVM args for all Gradle tests 2019-10-17 01:46:38 +03:00
217 changed files with 744 additions and 1282 deletions

View File

@@ -30,6 +30,7 @@ buildscript {
classpath("com.gradle.publish:plugin-publish-plugin:0.9.7")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath(kotlin("allopen", bootstrapKotlinVersion))
classpath("net.sf.proguard:proguard-gradle:6.1.0")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
}
@@ -486,7 +487,12 @@ tasks {
}
register("gradlePluginIntegrationTest") {
dependsOn(":kotlin-gradle-plugin-integration-tests:check")
if (isTeamcityBuild) {
dependsOn(":kotlin-gradle-plugin-integration-tests:generated:min-gradle:check")
dependsOn(":kotlin-gradle-plugin-integration-tests:generated:max-gradle:check")
} else {
dependsOn(":kotlin-gradle-plugin-integration-tests:check")
}
}
register("jvmCompilerTest") {

View File

@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
public class KotlinCompilerVersion {
// The value of this constant is generated by the build script
// DON'T MODIFY IT
public static final String VERSION = "@snapshot@";
public static final String VERSION = "1.3.70-dev-177";
// 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

View File

@@ -87,6 +87,8 @@ unzipSdkTask("tools", "r24.3.4", "", toolsOs)
unzipSdkTask("build-tools", "r23.0.1", "build-tools/23.0.1", toolsOs, buildTools, 1)
unzipSdkTask("build-tools", "r28.0.2", "build-tools/28.0.2", toolsOs, buildTools, 1)
// for gradle plugin tests
unzipSdkTask("build-tools", "r26.0.2", "build-tools/26.0.2", toolsOs, buildTools, 1)
val clean by task<Delete> {
delete(buildDir)

View File

@@ -1,4 +1,6 @@
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx1600m -Dfile.encoding=UTF-8 -Xmx2g -XX:MaxMetaspaceSize=512m
org.gradle.parallel=true
cacheRedirectorEnabled=true
@@ -9,6 +11,11 @@ kotlin.compiler.newInferenceEnabled=true
#bootstrap.kotlin.version=1.1.50-dev-1451
#signingRequired=true
## The following properties can be useful for reproducing TeamCity builds.
## Do not commit in uncommented state!
#build.number=1.3.70-dev-177
#teamcity=true
## The following properties can be added to your local.properties file to customize the build:
#jpsBuild=true

View File

@@ -1,9 +1,9 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.pill.PillExtension
plugins {
kotlin("jvm")
kotlin("plugin.allopen")
id("jps-compatible")
}
@@ -42,21 +42,9 @@ dependencies {
// Workaround for missing transitive import of the common(project `kotlin-test-common`
// for `kotlin-test-jvm` into the IDE:
testCompileOnly(project(":kotlin-test:kotlin-test-common")) { isTransitive = false }
}
// Aapt2 from Android Gradle Plugin 3.2 and below does not handle long paths on Windows.
val shortenTempRootName = System.getProperty("os.name")!!.contains("Windows")
// additional configuration in tasks.withType<Test> below
projectTest("test", shortenTempRootName = shortenTempRootName) {}
projectTest("testAdvanceGradleVersion", shortenTempRootName = shortenTempRootName) {
val gradleVersionForTests = "5.3-rc-2"
systemProperty("kotlin.gradle.version.for.tests", gradleVersionForTests)
}
tasks.named<Task>("check") {
dependsOn("testAdvanceGradleVersion")
// only for test generator
testImplementation(intellijDep()) { includeJars("asm-all", rootProject = rootProject) }
}
gradle.taskGraph.whenReady {
@@ -82,86 +70,141 @@ gradle.taskGraph.whenReady {
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
kotlinOptions.jvmTarget = "1.8"
configureCommonTasks(gradle.gradleUserHomeDir)
testsJar {}
allOpen {
annotation("org.jetbrains.kotlin.gradle.generators.GradleTestsRootClass")
}
val generateTests by generator("org.jetbrains.kotlin.gradle.generators.GenerateTestsWithDifferentGradleVersionsKt")
generateTests.setArgsString(project.file("build/classes").canonicalPath)
configureGeneratedTestsSubProject("generated:max-gradle", "max-ver")
configureGeneratedTestsSubProject("generated:min-gradle", "min-ver")
fun configureGeneratedTestsSubProject(relativePath: String, gradleHomeDirName: String) {
project(relativePath) {
plugins.apply("kotlin")
plugins.apply("jps-compatible")
pill {
variant = PillExtension.Variant.FULL
}
sourceSets {
"test" { projectDefault() }
}
dependencies {
testCompile(projectTests(":kotlin-gradle-plugin-integration-tests"))
testRuntime(project(":kotlin-gradle-plugin-integration-tests", configuration = "testRuntime"))
}
val gradleHome = rootProject.buildDir.resolve("test-gradle-home/${gradleHomeDirName}")
configureCommonTasks(gradleHome)
tasks.named("compileTestKotlin").configure {
dependsOn(generateTests)
}
}
}
tasks.withType<Test> {
onlyIf { !project.hasProperty("noTest") }
fun Project.configureCommonTasks(gradleHome: File) {
// Aapt2 from Android Gradle Plugin 3.2 and below does not handle long paths on Windows.
val shortenTempRootName = System.getProperty("os.name")!!.contains("Windows")
dependsOn(":kotlin-gradle-plugin:validateTaskProperties")
dependsOn(
":kotlin-allopen:install",
":kotlin-allopen:plugin-marker:install",
":kotlin-noarg:install",
":kotlin-allopen:plugin-marker:install",
":kotlin-sam-with-receiver:install",
":kotlin-android-extensions:install",
":kotlin-build-common:install",
":kotlin-compiler-embeddable:install",
":kotlin-gradle-plugin:install",
":kotlin-gradle-plugin:plugin-marker:install",
":kotlin-reflect:install",
":kotlin-annotation-processing-gradle:install",
":kotlin-test:kotlin-test-jvm:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-jdk8:install",
":examples:annotation-processor-example:install",
":kotlin-scripting-common:install",
":kotlin-scripting-jvm:install",
":kotlin-scripting-compiler-embeddable:install",
":kotlin-test-js-runner:install",
":kotlin-source-map-loader:install"
)
executable = "${rootProject.extra["JDK_18"]!!}/bin/java"
systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String)
systemProperty("runnerGradleVersion", gradle.gradleVersion)
systemProperty("jdk9Home", rootProject.extra["JDK_9"] as String)
systemProperty("jdk10Home", rootProject.extra["JDK_10"] as String)
systemProperty("jdk11Home", rootProject.extra["JDK_11"] as String)
val mavenLocalRepo = System.getProperty("maven.repo.local")
if (mavenLocalRepo != null) {
systemProperty("maven.repo.local", mavenLocalRepo)
projectTest("test", shortenTempRootName = shortenTempRootName) {
workingDir = rootDir
}
useAndroidSdk()
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
kotlinOptions.jvmTarget = "1.8"
}
maxHeapSize = "512m"
tasks.withType<Test> {
onlyIf { !project.hasProperty("noTest") }
testLogging {
// set options for log level LIFECYCLE
events("passed", "skipped", "failed", "standardOut")
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showStackTraces = true
dependsOn(":kotlin-gradle-plugin:validateTaskProperties")
dependsOn(
":kotlin-allopen:install",
":kotlin-allopen:plugin-marker:install",
":kotlin-noarg:install",
":kotlin-allopen:plugin-marker:install",
":kotlin-sam-with-receiver:install",
":kotlin-android-extensions:install",
":kotlin-build-common:install",
":kotlin-compiler-embeddable:install",
":kotlin-gradle-plugin:install",
":kotlin-gradle-plugin:plugin-marker:install",
":kotlin-reflect:install",
":kotlin-annotation-processing-gradle:install",
":kotlin-test:kotlin-test-jvm:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-jdk8:install",
":examples:annotation-processor-example:install",
":kotlin-scripting-common:install",
":kotlin-scripting-jvm:install",
":kotlin-scripting-compiler-embeddable:install",
":kotlin-test-js-runner:install",
":kotlin-source-map-loader:install"
)
// set options for log level DEBUG and INFO
debug {
events("started", "passed", "skipped", "failed", "standardOut", "standardError")
exceptionFormat = TestExceptionFormat.FULL
executable = "${rootProject.extra["JDK_18"]!!}/bin/java"
systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String)
systemProperty("runnerGradleVersion", gradle.gradleVersion)
systemProperty("runnerGradleUserHome", gradle.gradleUserHomeDir)
systemProperty("runnerGradleJavaHome", System.getProperties().getProperty("java.home"))
systemProperty("jdk9Home", rootProject.extra["JDK_9"] as String)
systemProperty("jdk10Home", rootProject.extra["JDK_10"] as String)
systemProperty("jdk11Home", rootProject.extra["JDK_11"] as String)
gradleHome?.let {
systemProperty("gradle.for.tests.user.home", it.canonicalPath)
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
addTestListener(object : TestListener {
override fun afterSuite(desc: TestDescriptor, result: TestResult) {
if (desc.parent == null) { // will match the outermost suite
val output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
val startItem = "| "
val endItem = " |"
val repeatLength = startItem.length + output.length + endItem.length
println("\n" + ("-".repeat(repeatLength)) + "\n" + startItem + output + endItem + "\n" + ("-".repeat(repeatLength)))
}
val mavenLocalRepo = System.getProperty("maven.repo.local")
if (mavenLocalRepo != null) {
systemProperty("maven.repo.local", mavenLocalRepo)
}
useAndroidSdk()
maxHeapSize = "512m"
testLogging {
// set options for log level LIFECYCLE
events("passed", "skipped", "failed", "standardOut")
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showStackTraces = true
// set options for log level DEBUG and INFO
debug {
events("started", "passed", "skipped", "failed", "standardOut", "standardError")
exceptionFormat = TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
override fun beforeSuite(suite: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
})
addTestListener(object : TestListener {
override fun afterSuite(desc: TestDescriptor, result: TestResult) {
if (desc.parent == null) { // will match the outermost suite
val output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
val startItem = "| "
val endItem = " |"
val repeatLength = startItem.length + output.length + endItem.length
println("\n" + ("-".repeat(repeatLength)) + "\n" + startItem + output + endItem + "\n" + ("-".repeat(repeatLength)))
}
}
override fun beforeSuite(suite: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
})
}
}
}
}

View File

@@ -0,0 +1 @@
*/test/tests.kt

View File

@@ -0,0 +1 @@
// actual configuration in parent project

View File

@@ -0,0 +1 @@
// actual configuration in parent project

View File

@@ -12,8 +12,8 @@ open class KotlinAndroid33GradleIT : KotlinAndroid32GradleIT() {
override val androidGradlePluginVersion: AGPVersion
get() = AGPVersion.v3_3_2
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.AtLeast("5.0")
override val defaultGradleRequirement: TestGradleRequirement
get() = TestGradleRequirement(minVer = TestGradle.v5_0)
}
open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
@@ -21,7 +21,7 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
get() = AGPVersion.v3_2_0
@Test
fun testAndroidWithNewMppApp() = with(Project("new-mpp-android", GradleVersionRequired.AtLeast("5.0"))) {
fun testAndroidWithNewMppApp() = with(Project("new-mpp-android", TestGradleRequirement(minVer = TestGradle.v5_0))) {
build("assemble", "compileDebugUnitTestJavaWithJavac", "printCompilerPluginOptions") {
assertSuccessful()
@@ -206,7 +206,7 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
}
@Test
fun testAndroidMppProductionDependenciesInTests() = with(Project("new-mpp-android", GradleVersionRequired.AtLeast("5.0"))) {
fun testAndroidMppProductionDependenciesInTests() = with(Project("new-mpp-android", TestGradleRequirement(minVer = TestGradle.v5_0))) {
// Test the fix for KT-29343
setupWorkingDir()
@@ -260,7 +260,7 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
}
@Test
fun testCustomAttributesInAndroidTargets() = with(Project("new-mpp-android", GradleVersionRequired.AtLeast("5.0"))) {
fun testCustomAttributesInAndroidTargets() = with(Project("new-mpp-android", TestGradleRequirement(minVer = TestGradle.v5_0))) {
// Test the fix for KT-27714
setupWorkingDir()
@@ -401,12 +401,12 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
}
}
class KotlinAndroid30GradleIT : KotlinAndroid3GradleIT() {
open class KotlinAndroid30GradleIT : KotlinAndroid3GradleIT() {
override val androidGradlePluginVersion: AGPVersion
get() = AGPVersion.v3_0_0
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.Until("4.10.2")
override val defaultGradleRequirement: TestGradleRequirement
get() = TestGradleRequirement(maxVer = TestGradle.v4_10_2)
@Test
fun testOmittedStdlibVersion() = Project("AndroidProject").run {
@@ -760,7 +760,7 @@ fun getSomething() = 10
""".trimIndent()
)
build("build") {
build("assembleDebug", "assembleAndroidTest", "testClasses", "compileDebugUnitTestJavaWithJavac") {
assertSuccessful()
assertTasksExecuted(
":lib:compileKotlinCommon",
@@ -768,9 +768,7 @@ fun getSomething() = 10
":libJvm:compileKotlin",
":libJvm:compileTestKotlin",
":libAndroid:compileDebugKotlin",
":libAndroid:compileReleaseKotlin",
":libAndroid:compileDebugUnitTestKotlin",
":libAndroid:compileReleaseUnitTestKotlin"
":libAndroid:compileDebugUnitTestKotlin"
)
assertFileExists("lib/build/classes/kotlin/main/foo/PlatformClass.kotlin_metadata")
@@ -779,7 +777,6 @@ fun getSomething() = 10
assertFileExists("libJvm/build/classes/kotlin/test/foo/PlatformTest.class")
assertFileExists("libAndroid/build/tmp/kotlin-classes/debug/foo/PlatformClass.class")
assertFileExists("libAndroid/build/tmp/kotlin-classes/release/foo/PlatformClass.class")
assertFileExists("libAndroid/build/tmp/kotlin-classes/debugUnitTest/foo/PlatformTest.class")
assertFileExists("libAndroid/build/tmp/kotlin-classes/debugUnitTest/foo/PlatformTest.class")
}

View File

@@ -9,28 +9,35 @@ import org.jdom.Element
import org.jdom.input.SAXBuilder
import org.jdom.output.Format
import org.jdom.output.XMLOutputter
import org.jetbrains.kotlin.gradle.generators.GradleTestsRootClass
import org.jetbrains.kotlin.gradle.model.ModelContainer
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
import org.jetbrains.kotlin.gradle.plugin.internal.KOTLIN_NATIVE_JVM_ARGS_PROPERTY
import org.jetbrains.kotlin.gradle.util.*
import org.jetbrains.kotlin.kapt3.base.util.measureTimeMillisWithResult
import org.jetbrains.kotlin.test.util.trimTrailingWhitespaces
import org.junit.After
import org.junit.AfterClass
import org.junit.Assert
import org.junit.Before
import org.junit.*
import java.io.File
import java.util.regex.Pattern
import kotlin.collections.HashSet
import kotlin.test.*
val SYSTEM_LINE_SEPARATOR: String = System.getProperty("line.separator")
const val TEST_GRADLE_JVM_ARGS = "-Xmx2048m -XX:MaxMetaspaceSize=512m"
const val TEST_GRADLE_IDLE_TIMEOUT_MS = 60_000 // 1 minute
const val TEST_KOTLIN_NATIVE_JVM_ARGS = "-Xmx2500m -XX:MaxMetaspaceSize=512m"
@GradleTestsRootClass
abstract class BaseGradleIT {
protected var workingDir = File(".")
protected open fun defaultBuildOptions(): BuildOptions = BuildOptions(withDaemon = true)
open val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.None
open val defaultMinGradle: TestGradle = TestGradle.OLDEST
open val defaultMaxGradle: TestGradle = TestGradle.NEWEST
open val useMinVersion: Boolean = true
@Before
fun setUp() {
@@ -68,88 +75,95 @@ abstract class BaseGradleIT {
}
companion object {
data class GradleDaemon(
val testGradle: TestGradle,
val gradleUserHome: File,
val javaHome: File
)
class DaemonStatus(val wrapperDir: File, val environmentVariables: EnvironmentVariables) {
var runCount = 0
}
private object DaemonRegistry {
// wrapper version to the number of daemon runs performed
private val daemonRunCount = hashMapOf<String, Int>()
private val runnerGradleVersion = System.getProperty("runnerGradleVersion")
val activeDaemons: List<String>
get() = daemonRunCount.keys.toList()
fun register(version: String) {
if (version == runnerGradleVersion) return
daemonRunCount[version] = (daemonRunCount[version] ?: 0) + 1
private val daemons = hashMapOf<GradleDaemon, DaemonStatus>()
// daemon of gradle process that starts tests
val parentDaemon = System.getProperty("runnerGradleVersion")?.let { version ->
val gradleUserHome = notNullSystemProperty("runnerGradleUserHome")
val javaHome = notNullSystemProperty("runnerGradleJavaHome")
GradleDaemon(testGradle = TestGradle.fromString(version), gradleUserHome = File(gradleUserHome), javaHome = File(javaHome))
}
fun unregister(version: String) {
daemonRunCount.remove(version)
val activeDaemons: Set<GradleDaemon>
get() = daemons.keys
fun register(daemon: GradleDaemon, env: EnvironmentVariables): DaemonStatus {
fun newStatus() = DaemonStatus(createNewWrapperDir(daemon.testGradle), env)
// prevents shutting down parent Gradle process
if (daemon == parentDaemon) return newStatus()
return when (val status = daemons[daemon]) {
null -> newStatus().also { daemons[daemon] = it }
else -> status.apply { runCount++ }
}
}
fun runCountForDaemon(version: String): Int =
daemonRunCount[version] ?: 0
fun unregister(daemon: GradleDaemon) {
daemons.remove(daemon)?.apply {
wrapperDir.deleteRecursively()
}
}
fun status(daemon: GradleDaemon): DaemonStatus? = daemons[daemon]
}
// gradle wrapper version to wrapper directory
private val gradleWrappers = hashMapOf<String, File>()
private const val MAX_DAEMON_RUNS = 30
private const val MAX_ACTIVE_GRADLE_PROCESSES = 1
private fun getEnvJDK_18() = System.getenv()["JDK_18"]
private val JDK_18_HOME = File(System.getenv()["JDK_18"]!!)
val resourcesRootFile = File("src/test/resources")
val resourcesRootFile = File("libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources")
@AfterClass
@JvmStatic
@Synchronized
@Suppress("unused")
fun tearDownAll() {
// Latest gradle requires Java > 7
val environmentVariables = hashMapOf<String, String>()
getEnvJDK_18()?.let { environmentVariables["JAVA_HOME"] = it }
stopAllDaemons(environmentVariables)
gradleWrappers.values.forEach { wrapperDir ->
wrapperDir.deleteRecursively()
}
gradleWrappers.clear()
stopAllDaemons()
}
@Synchronized
fun prepareWrapper(
version: String,
environmentVariables: Map<String, String> = mapOf(),
testGradle: TestGradle,
env: EnvironmentVariables,
withDaemon: Boolean = true
): File {
val wrapper = gradleWrappers.getOrPut(version) { createNewWrapperDir(version) }
if (!withDaemon) return createNewWrapperDir(testGradle)
if (withDaemon) {
DaemonRegistry.register(version)
if (DaemonRegistry.activeDaemons.size > MAX_ACTIVE_GRADLE_PROCESSES) {
println("Too many Gradle active processes (max is $MAX_ACTIVE_GRADLE_PROCESSES). Stopping all daemons")
stopAllDaemons(environmentVariables)
}
if (DaemonRegistry.runCountForDaemon(version) >= MAX_DAEMON_RUNS) {
stopDaemon(version, environmentVariables)
}
// we could've stopped daemon
if (DaemonRegistry.runCountForDaemon(version) <= 0) {
DaemonRegistry.register(version)
}
val daemon = GradleDaemon(testGradle = testGradle, gradleUserHome = env.gradleUserHome, javaHome = env.javaHome)
if ((DaemonRegistry.activeDaemons + daemon).size > MAX_ACTIVE_GRADLE_PROCESSES) {
println("Too many Gradle active processes (max is $MAX_ACTIVE_GRADLE_PROCESSES). Stopping all daemons")
stopAllDaemons()
}
return wrapper
val existingDaemon = DaemonRegistry.register(daemon, env)
return when {
existingDaemon.runCount >= MAX_DAEMON_RUNS -> {
stopDaemon(daemon)
DaemonRegistry.register(daemon, env).wrapperDir
}
else -> existingDaemon.wrapperDir
}
}
private fun createNewWrapperDir(version: String): File =
createTempDir("GradleWrapper-$version-")
private fun createNewWrapperDir(testGradle: TestGradle): File {
val version = testGradle.toString()
return createTempDir("GradleWrapper-$version-")
.apply {
File(BaseGradleIT.resourcesRootFile, "GradleWrapper").copyRecursively(this)
File(resourcesRootFile, "GradleWrapper").copyRecursively(this)
val wrapperProperties = File(this, "gradle/wrapper/gradle-wrapper.properties")
val isGradleVerisonSnapshot = version.endsWith("+0000")
if (!isGradleVerisonSnapshot) {
@@ -160,31 +174,23 @@ abstract class BaseGradleIT {
}
}
}
private val runnerGradleVersion = System.getProperty("runnerGradleVersion")
private fun stopDaemon(version: String, environmentVariables: Map<String, String>) {
assert(version != runnerGradleVersion) { "Not stopping Gradle daemon v$version as it matches the runner version" }
println("Stopping gradle daemon v$version")
val envVariables = if (GradleVersion.version(version) < GradleVersion.version("5.0")) {
// Gradle versions below 5.0 do not support running on JDK11, and some of the tests
// set JAVA_HOME to JDK11. This makes sure we are using JDK8 when stopping those daemons.
environmentVariables + mapOf("JAVA_HOME" to System.getenv()["JDK_18"]!!)
} else {
environmentVariables
}
val wrapperDir = gradleWrappers[version] ?: error("Was asked to stop unknown daemon $version")
val cmd = createGradleCommand(wrapperDir, arrayListOf("-stop"))
val result = runProcess(cmd, wrapperDir, envVariables)
assert(result.isSuccessful) { "Could not stop daemon: $result" }
DaemonRegistry.unregister(version)
}
private fun stopAllDaemons(environmentVariables: Map<String, String>) {
for (version in DaemonRegistry.activeDaemons) {
stopDaemon(version, environmentVariables)
private fun stopDaemon(daemon: GradleDaemon) {
assert(daemon != DaemonRegistry.parentDaemon) { "Not stopping Gradle daemon matching the runner Gradle process" }
println("Stopping $daemon")
val status = DaemonRegistry.status(daemon) ?: return
val wrapperDir = status.wrapperDir
val cmd = createGradleCommand(wrapperDir, arrayListOf("-stop"))
val result = runProcess(cmd, status.wrapperDir, status.environmentVariables.asMap())
assert(result.isSuccessful) { "Could not stop daemon: $result" }
DaemonRegistry.unregister(daemon)
}
private fun stopAllDaemons() {
for (daemon in DaemonRegistry.activeDaemons) {
stopDaemon(daemon)
}
assert(DaemonRegistry.activeDaemons.isEmpty()) {
"Could not stop some daemons ${(DaemonRegistry.activeDaemons).joinToString()}"
@@ -199,7 +205,7 @@ abstract class BaseGradleIT {
val incremental: Boolean? = null,
val incrementalJs: Boolean? = null,
val androidHome: File? = null,
val javaHome: File? = null,
val javaHome: File = JDK_18_HOME,
val androidGradlePluginVersion: AGPVersion? = null,
val forceOutputToStdout: Boolean = false,
val debug: Boolean = false,
@@ -210,14 +216,32 @@ abstract class BaseGradleIT {
val withBuildCache: Boolean = false,
val kaptOptions: KaptOptions? = null,
val parallelTasksInProject: Boolean? = null
)
) {
fun environmentVariables() = EnvironmentVariables(
gradleUserHome = GRADLE_HOME_FOR_TESTS,
javaHome = javaHome,
androidHome = androidHome
)
}
class EnvironmentVariables(val gradleUserHome: File, val javaHome: File, val androidHome: File?) {
fun asMap(): Map<String, String> = HashMap<String, String>().apply {
androidHome?.let { sdkDir ->
put("ANDROID_HOME", sdkDir.canonicalPath)
}
put("JAVA_HOME", javaHome.canonicalPath)
put("GRADLE_USER_HOME", gradleUserHome.canonicalPath)
}
}
data class KaptOptions(val verbose: Boolean, val useWorkers: Boolean, val incrementalKapt: Boolean = false, val includeCompileClasspath: Boolean = true)
open inner class Project(
val projectName: String,
val gradleVersionRequirement: GradleVersionRequired = defaultGradleVersion,
directoryPrefix: String? = null,
minGradle: TestGradle = defaultMinGradle,
maxGradle: TestGradle = defaultMaxGradle,
val minLogLevel: LogLevel = LogLevel.DEBUG
) {
internal val testCase = this@BaseGradleIT
@@ -225,10 +249,19 @@ abstract class BaseGradleIT {
val resourceDirName = if (directoryPrefix != null) "$directoryPrefix/$projectName" else projectName
open val resourcesRoot = File(resourcesRootFile, "testProject/$resourceDirName")
val projectDir = File(workingDir.canonicalFile, projectName)
val testGradle: TestGradle =
// we don't want to test with the same version twice
if (useMinVersion) minGradle else maxGradle.also { Assume.assumeTrue(minGradle != maxGradle) }
open fun setupWorkingDir() {
if (!projectDir.isDirectory || projectDir.listFiles().isEmpty())
copyRecursively(this.resourcesRoot, workingDir)
if (projectDir.isDirectory && projectDir.listFiles().isNotEmpty()) return
copyRecursively(this.resourcesRoot, workingDir)
withProperties(projectDir.resolve("gradle.properties")) { gradleProperties ->
gradleProperties["org.gradle.jvmargs"] = TEST_GRADLE_JVM_ARGS
gradleProperties["org.gradle.daemon.idletimeout"] = TEST_GRADLE_IDLE_TIMEOUT_MS.toString()
gradleProperties[KOTLIN_NATIVE_JVM_ARGS_PROPERTY] = TEST_KOTLIN_NATIVE_JVM_ARGS
}
}
fun relativize(files: Iterable<File>): List<String> =
@@ -302,10 +335,8 @@ abstract class BaseGradleIT {
projectDir: File = File(workingDir, projectName),
check: CompiledProject.() -> Unit
) {
val wrapperVersion = chooseWrapperVersionOrFinishTest()
val env = createEnvironmentVariablesMap(options)
val wrapperDir = prepareWrapper(wrapperVersion, env)
val env = options.environmentVariables()
val wrapperDir = prepareWrapper(testGradle, env)
val cmd = createBuildCommand(wrapperDir, params, options)
println("<=== Test build: ${this.projectName} $cmd ===>")
@@ -314,7 +345,11 @@ abstract class BaseGradleIT {
setupWorkingDir()
}
val result = runProcess(cmd, projectDir, env, options)
val (timeMs, result) = measureTimeMillisWithResult {
runProcess(cmd, projectDir, env.asMap(), options)
}
println("<=== Finished in ${timeMs / 1000} s ===>")
try {
CompiledProject(this, result.output, result.exitCode).check()
} catch (t: Throwable) {
@@ -334,16 +369,20 @@ abstract class BaseGradleIT {
val options = defaultBuildOptions()
val arguments = mutableListOf("-Pkotlin_version=${options.kotlinVersion}")
options.androidGradlePluginVersion?.let { arguments.add("-Pandroid_tools_version=$it") }
val env = createEnvironmentVariablesMap(options)
val wrapperVersion = chooseWrapperVersionOrFinishTest()
prepareWrapper(wrapperVersion, env)
val env = options.environmentVariables()
prepareWrapper(testGradle, env)
val connection = GradleConnector
.newConnector()
.useGradleVersion(wrapperVersion)
.useGradleVersion(testGradle.toString())
.forProjectDirectory(projectDir)
.useGradleUserHomeDir(GRADLE_HOME_FOR_TESTS)
.connect()
val model = connection.action(ModelFetcherBuildAction(modelType)).withArguments(arguments).setEnvironmentVariables(env).run()
val model = connection
.action(ModelFetcherBuildAction(modelType))
.withArguments(arguments)
.setEnvironmentVariables(env.asMap())
.run()
connection.close()
return model
}
@@ -600,11 +639,6 @@ Finished executing task ':$taskName'|
fun Project.classesDir(subproject: String? = null, sourceSet: String = "main", language: String = "kotlin"): String =
(subproject?.plus("/") ?: "") + "build/classes/$language/$sourceSet/"
fun Project.testGradleVersionAtLeast(version: String): Boolean =
GradleVersion.version(chooseWrapperVersionOrFinishTest()) >= GradleVersion.version(version)
fun Project.testGradleVersionBelow(version: String): Boolean = !testGradleVersionAtLeast(version)
fun CompiledProject.kotlinClassesDir(subproject: String? = null, sourceSet: String = "main"): String =
project.classesDir(subproject, sourceSet, language = "kotlin")
@@ -699,7 +733,7 @@ Finished executing task ':$taskName'|
private fun Project.createGradleTailParameters(options: BuildOptions, params: Array<out String> = arrayOf()): List<String> =
params.toMutableList().apply {
add("--stacktrace")
add("--full-stacktrace")
when (minLogLevel) {
// Do not allow to configure Gradle project with `ERROR` log level (error logs visible on all log levels)
LogLevel.ERROR -> error("Log level ERROR is not supported by Gradle command-line")
@@ -754,18 +788,6 @@ Finished executing task ':$taskName'|
addAll(options.freeCommandLineArgs)
}
private fun createEnvironmentVariablesMap(options: BuildOptions): Map<String, String> =
hashMapOf<String, String>().apply {
options.androidHome?.let { sdkDir ->
sdkDir.parentFile.mkdirs()
put("ANDROID_HOME", sdkDir.canonicalPath)
}
options.javaHome?.let {
put("JAVA_HOME", it.canonicalPath)
}
}
private fun String.normalize() = this.lineSequence().joinToString(SYSTEM_LINE_SEPARATOR)
fun copyRecursively(source: File, target: File) {

View File

@@ -20,12 +20,12 @@ import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import java.io.File
class BuildCacheIT : BaseGradleIT() {
open class BuildCacheIT : BaseGradleIT() {
override fun defaultBuildOptions(): BuildOptions =
super.defaultBuildOptions().copy(withBuildCache = true)
companion object {
private val GRADLE_VERSION = GradleVersionRequired.None
private val GRADLE_VERSION = TestGradleRequirement.None
}
@Test

View File

@@ -26,7 +26,7 @@ import java.io.File
import kotlin.test.assertEquals
@RunWith(Parameterized::class)
class BuildCacheRelocationIT : BaseGradleIT() {
open class BuildCacheRelocationIT : BaseGradleIT() {
override fun defaultBuildOptions(): BuildOptions =
super.defaultBuildOptions().copy(

View File

@@ -8,7 +8,7 @@ import java.io.File
import kotlin.test.assertNull
import kotlin.test.assertTrue
class ClassFileIsRemovedIT : BaseGradleIT() {
open class ClassFileIsRemovedIT : BaseGradleIT() {
@Test
fun testClassIsRemovedNonIC() {
doTestClassIsRemoved(defaultBuildOptions())

View File

@@ -14,17 +14,13 @@ import java.util.concurrent.TimeUnit
import kotlin.test.assertEquals
import kotlin.test.fail
class CocoaPodsIT : BaseGradleIT() {
// We use Kotlin DSL. Earlier Gradle versions fail at accessors codegen.
val gradleVersion = GradleVersionRequired.None
open class CocoaPodsIT : BaseGradleIT() {
val PODFILE_IMPORT_DIRECTIVE_PLACEHOLDER = "<import_mode_directive>"
@Test
fun testPodspec() {
assumeTrue(HostManager.hostIsMac)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods")
// Check that the podspec task fails if there is no Gradle wrapper in the project.
gradleProject.build(":kotlin-library:podspec") {
@@ -93,7 +89,7 @@ class CocoaPodsIT : BaseGradleIT() {
@Test
fun testInterop() {
assumeTrue(HostManager.hostIsMac)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods")
with(gradleProject) {
// Check that a project with CocoaPods interop fails to be built from command line.
build(":kotlin-library:build") {
@@ -155,7 +151,7 @@ class CocoaPodsIT : BaseGradleIT() {
private fun doTestXcode(mode: ImportMode) {
assumeTrue(HostManager.hostIsMac)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion)
val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods")
with(gradleProject) {
// Generate podspec.

View File

@@ -7,10 +7,10 @@ package org.jetbrains.kotlin.gradle
import org.junit.Test
class ConfigurationAvoidanceIT : BaseGradleIT() {
open class ConfigurationAvoidanceIT : BaseGradleIT() {
@Test
fun testUnrelatedTaskNotConfigured() = with(Project("simpleProject", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testUnrelatedTaskNotConfigured() = with(Project("simpleProject", TestGradleRequirement.AtLeast("4.10.2"))) {
setupWorkingDir()
val expensivelyConfiguredTaskName = "expensivelyConfiguredTask"

View File

@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.gradle
import org.junit.Test
import java.io.File
class CoroutinesIT : BaseGradleIT() {
open class CoroutinesIT : BaseGradleIT() {
@Test
fun testCoroutinesJvmDefault() {
jvmProject.doTest("default", null)

View File

@@ -7,7 +7,7 @@ import org.junit.Assert
import org.junit.Test
import java.io.File
class ExecutionStrategyJsIT : ExecutionStrategyIT() {
open class ExecutionStrategyJsIT : ExecutionStrategyIT() {
override fun setupProject(project: Project) {
super.setupProject(project)
val buildGradle = File(project.projectDir, "app/build.gradle")
@@ -26,7 +26,7 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() {
}
}
class ExecutionStrategyJvmIT : ExecutionStrategyIT() {
open class ExecutionStrategyJvmIT : ExecutionStrategyIT() {
override fun CompiledProject.checkOutput() {
val classesDir = kotlinClassesDir(subproject = "app") + "foo/"
assertFileExists("${classesDir}MainKt.class")
@@ -103,8 +103,8 @@ abstract class ExecutionStrategyIT : BaseGradleIT() {
}
if (isGradleAtLeast50) {
// 256m is the default value for Gradle 5.0+
assertDaemonArgsContain("-XX:MaxMetaspaceSize=256m")
/** see [TEST_GRADLE_JVM_ARGS] */
assertDaemonArgsContain("-XX:MaxMetaspaceSize=512m")
}
assertDaemonArgsContain("-ea")

View File

@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle
import org.junit.Test
import kotlin.test.assertTrue
class GradleDaemonMemoryIT : BaseGradleIT() {
open class GradleDaemonMemoryIT : BaseGradleIT() {
// For corresponding documentation, see https://docs.gradle.org/current/userguide/gradle_daemon.html
// Setting user.variant to different value implies a new daemon process will be created.
// In order to stop daemon process, special exit task is used ( System.exit(0) ).

View File

@@ -1,53 +0,0 @@
/*
* 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.gradle
import org.gradle.util.GradleVersion
import org.junit.Assume
sealed class GradleVersionRequired(val minVersion: String, val maxVersion: String?) {
companion object {
const val OLDEST_SUPPORTED = "4.9"
}
class Exact(version: String) : GradleVersionRequired(version, version)
class AtLeast(version: String) : GradleVersionRequired(version, null)
class InRange(minVersion: String, maxVersion: String) : GradleVersionRequired(minVersion, maxVersion)
class Until(maxVersion: String) : GradleVersionRequired(OLDEST_SUPPORTED, maxVersion)
object None : GradleVersionRequired(GradleVersionRequired.OLDEST_SUPPORTED, null)
}
fun BaseGradleIT.Project.chooseWrapperVersionOrFinishTest(): String {
val gradleVersionForTests = System.getProperty("kotlin.gradle.version.for.tests")?.toGradleVersion()
val minVersion = gradleVersionRequirement.minVersion.toGradleVersion()
val maxVersion = gradleVersionRequirement.maxVersion?.toGradleVersion()
if (gradleVersionForTests == null) {
return minVersion.version
}
Assume.assumeTrue(minVersion <= gradleVersionForTests && (maxVersion == null || gradleVersionForTests <= maxVersion))
return gradleVersionForTests.version
}
private fun String.toGradleVersion() = GradleVersion.version(this)

View File

@@ -19,9 +19,9 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class HierarchicalMppIT : BaseGradleIT() {
open class HierarchicalMppIT : BaseGradleIT() {
companion object {
private val gradleVersion = GradleVersionRequired.AtLeast("5.0")
private val gradleVersion = TestGradleRequirement.AtLeast("5.0")
}
@Test

View File

@@ -5,7 +5,7 @@ import org.junit.Assert
import org.junit.Test
import java.io.File
class IncrementalCompilationJsMultiProjectIT : BaseIncrementalCompilationMultiProjectIT() {
open class IncrementalCompilationJsMultiProjectIT : BaseIncrementalCompilationMultiProjectIT() {
override fun defaultProject(): Project {
val project = Project("incrementalMultiproject")
project.setupWorkingDir()
@@ -29,7 +29,7 @@ class IncrementalCompilationJsMultiProjectIT : BaseIncrementalCompilationMultiPr
get() = "compileKotlin2Js"
}
class IncrementalCompilationJvmMultiProjectIT : BaseIncrementalCompilationMultiProjectIT() {
open class IncrementalCompilationJvmMultiProjectIT : BaseIncrementalCompilationMultiProjectIT() {
override val additionalLibDependencies: String =
"implementation \"org.jetbrains.kotlin:kotlin-test:${'$'}kotlin_version\""

View File

@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.gradle.util.getFilesByNames
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
class IncrementalJavaChangeDefaultIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = null) {
open class IncrementalJavaChangeDefaultIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = null) {
@Test
override fun testModifySignatureTrackedJavaInLib() {
doTest(trackedJavaClass, changeSignature, expectedAffectedSources = listOf("TrackedJavaClassChild.kt", "useTrackedJavaClass.kt"))
@@ -22,7 +22,7 @@ class IncrementalJavaChangeDefaultIT : IncrementalCompilationJavaChangesBase(use
}
}
class IncrementalJavaChangePreciseIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = true) {
open class IncrementalJavaChangePreciseIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = true) {
@Test
override fun testModifySignatureTrackedJavaInLib() {
doTest(trackedJavaClass, changeSignature, expectedAffectedSources = listOf("TrackedJavaClassChild.kt", "useTrackedJavaClass.kt"))
@@ -34,7 +34,7 @@ class IncrementalJavaChangePreciseIT : IncrementalCompilationJavaChangesBase(use
}
}
class IncrementalJavaChangeDisablePreciseIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = false) {
open class IncrementalJavaChangeDisablePreciseIT : IncrementalCompilationJavaChangesBase(usePreciseJavaTracking = false) {
@Test
override fun testModifySignatureTrackedJavaInLib() {
doTest(

View File

@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
class JavaUpToDateIT : BaseGradleIT() {
open class JavaUpToDateIT : BaseGradleIT() {
@Test
fun testKotlinMethodBodyIsChanged() {
val project = Project("javaUpToDate")

View File

@@ -6,7 +6,7 @@ import org.junit.Assert
import org.junit.Test
import java.io.File
class Kapt3WorkersAndroid32IT : Kapt3Android32IT() {
open class Kapt3WorkersAndroid32IT : Kapt3Android32IT() {
override fun kaptOptions(): KaptOptions =
super.kaptOptions().copy(useWorkers = true)
}
@@ -20,8 +20,8 @@ open class Kapt3Android33IT : Kapt3AndroidIT() {
override val androidGradlePluginVersion: AGPVersion
get() = AGPVersion.v3_3_2
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.AtLeast("5.2")
override val defaultGradleRequirement: TestGradleRequirement
get() = TestGradleRequirement.AtLeast(TestGradle.v4_10_2)
@Test
fun testAndroidxNavigationSafeArgs() = with(Project("androidx-navigation-safe-args", directoryPrefix = "kapt2")) {
@@ -72,21 +72,21 @@ open class Kapt3Android33IT : Kapt3AndroidIT() {
}
}
class Kapt3Android31IT : Kapt3AndroidIT() {
open class Kapt3Android31IT : Kapt3AndroidIT() {
override val androidGradlePluginVersion: AGPVersion
get() = AGPVersion.v3_1_0
// there is a weird validation exception in testICWithAnonymousClasses with 5.0 todo: fix it
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.Until("4.10.2")
override val defaultGradleRequirement: TestGradleRequirement
get() = TestGradleRequirement.Until(TestGradle.v4_10_2)
}
open class Kapt3AndroidIT : Kapt3BaseIT() {
protected open val androidGradlePluginVersion: AGPVersion
get() = AGPVersion.v3_0_0
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.Until("4.10.2")
override val defaultGradleRequirement: TestGradleRequirement
get() = TestGradleRequirement.Until(TestGradle.v4_10_2)
override fun defaultBuildOptions() =
super.defaultBuildOptions().copy(

View File

@@ -40,7 +40,7 @@ abstract class Kapt3BaseIT : BaseGradleIT() {
}
}
class Kapt3WorkersIT : Kapt3IT() {
open class Kapt3WorkersIT : Kapt3IT() {
override fun kaptOptions(): KaptOptions =
super.kaptOptions().copy(useWorkers = true)
@@ -69,7 +69,7 @@ class Kapt3WorkersIT : Kapt3IT() {
Assume.assumeTrue("JDK 10 isn't available", javaHome.isDirectory)
val options = defaultBuildOptions().copy(javaHome = javaHome)
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("4.7"))
val project = Project("simple", directoryPrefix = "kapt2")
project.build("build", options = options) {
assertSuccessful()
assertKaptSuccessful()
@@ -84,7 +84,7 @@ class Kapt3WorkersIT : Kapt3IT() {
Assume.assumeTrue("JDK 11 isn't available", javaHome.isDirectory)
val options = defaultBuildOptions().copy(javaHome = javaHome)
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("5.0"))
val project = Project("simple", directoryPrefix = "kapt2", minGradle = TestGradle.v5_0)
project.build("build", options = options) {
assertSuccessful()
assertKaptSuccessful()
@@ -646,7 +646,7 @@ open class Kapt3IT : Kapt3BaseIT() {
Assume.assumeTrue("JDK 11 isn't available", javaHome.isDirectory)
val options = defaultBuildOptions().copy(javaHome = javaHome)
val project = Project("simple", directoryPrefix = "kapt2", gradleVersionRequirement = GradleVersionRequired.AtLeast("5.0")).also {
val project = Project("simple", directoryPrefix = "kapt2", minGradle = TestGradle.v5_0).also {
it.setupWorkingDir()
it.gradleBuildScript().appendText("\nsourceCompatibility = '8'")
}

View File

@@ -14,7 +14,7 @@ open class KaptIncrementalIT : BaseGradleIT() {
open fun getProject() =
Project(
"kaptIncrementalCompilationProject",
GradleVersionRequired.None
TestGradleRequirement.None
).apply { setupWorkingDir() }
private val annotatedElements =

View File

@@ -13,12 +13,12 @@ import org.junit.Test
import java.io.File
import kotlin.test.assertFalse
class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
open class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
override fun getProject() =
Project(
"kaptIncrementalCompilationProject",
GradleVersionRequired.None
TestGradleRequirement.None
).apply {
setupIncrementalAptProject("AGGREGATING")
}
@@ -105,7 +105,7 @@ class KaptIncrementalWithAggregatingApt : KaptIncrementalIT() {
fun testClasspathChanges() {
val project = Project(
"incrementalMultiproject",
GradleVersionRequired.None
TestGradleRequirement.None
).apply {
setupWorkingDir()
val processorPath = generateProcessor("AGGREGATING")

View File

@@ -15,12 +15,12 @@ import java.io.File
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
open class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
override fun getProject() =
Project(
"kaptIncrementalCompilationProject",
GradleVersionRequired.None
TestGradleRequirement.None
).apply {
setupIncrementalAptProject("ISOLATING")
}

View File

@@ -11,7 +11,7 @@ import java.util.zip.ZipFile
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class Kotlin2JsGradlePluginIT : BaseGradleIT() {
open class Kotlin2JsGradlePluginIT : BaseGradleIT() {
@Test
fun testBuildAndClean() {
val project = Project("kotlin2JsProject")
@@ -351,7 +351,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
}
@Test
fun testNewKotlinJsPlugin() = with(Project("kotlin-js-plugin-project", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testNewKotlinJsPlugin() = with(Project("kotlin-js-plugin-project", TestGradleRequirement.AtLeast("4.10.2"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -398,7 +398,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
}
@Test
fun testKotlinJsKarmaDownloadChrome() = with(Project("kotlin-js-karma-download-chrome", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testKotlinJsKarmaDownloadChrome() = with(Project("kotlin-js-karma-download-chrome", TestGradleRequirement.AtLeast("4.10.2"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -415,7 +415,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
}
@Test
fun testYarnSetup() = with(Project("yarn-setup", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testYarnSetup() = with(Project("yarn-setup", TestGradleRequirement.AtLeast("4.10.2"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)

View File

@@ -24,7 +24,7 @@ import java.io.File
// todo: test client file creation/deletion
// todo: test daemon start (does not start every build)
// todo: test daemon shutdown when gradle daemon dies
class KotlinDaemonIT : BaseGradleIT() {
open class KotlinDaemonIT : BaseGradleIT() {
@Test
fun testDaemonMultiproject() {

View File

@@ -30,7 +30,7 @@ import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
class KotlinGradleIT : BaseGradleIT() {
open class KotlinGradleIT : BaseGradleIT() {
@Test
fun testCrossCompile() {
@@ -587,14 +587,11 @@ class KotlinGradleIT : BaseGradleIT() {
@Test
fun testNoUnnamedInputsOutputs() {
// Use a new Gradle version to enable the usage of the input/output builders, which are new API:
val gradleVersionRequirement = GradleVersionRequired.AtLeast("4.4")
val projects = listOf(
Project("simpleProject", gradleVersionRequirement),
Project("kotlin2JsProject", gradleVersionRequirement),
Project("multiplatformProject", gradleVersionRequirement),
Project("simple", gradleVersionRequirement, "kapt2")
Project("simpleProject"),
Project("kotlin2JsProject"),
Project("multiplatformProject"),
Project("simple", directoryPrefix = "kapt2")
)
projects.forEach {
@@ -819,7 +816,7 @@ class KotlinGradleIT : BaseGradleIT() {
}
@Test
fun testKt29971() = with(Project("kt-29971", GradleVersionRequired.AtLeast("5.0"))) {
fun testKt29971() = with(Project("kt-29971", minGradle = TestGradle.v5_0)) {
build("jvm-app:build") {
assertSuccessful()
assertTasksExecuted(":jvm-app:compileKotlin")
@@ -827,7 +824,7 @@ class KotlinGradleIT : BaseGradleIT() {
}
@Test
fun testDetectingDifferentClassLoaders() = with(Project("kt-27059-pom-rewriting", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testDetectingDifferentClassLoaders() = with(Project("kt-27059-pom-rewriting", minGradle = TestGradle.v4_10_2)) {
setupWorkingDir()
val originalRootBuildScript = gradleBuildScript().readText()
@@ -893,7 +890,7 @@ class KotlinGradleIT : BaseGradleIT() {
}
@Test
fun testNewModelInOldJvmPlugin() = with(Project("new-model-in-old-plugin", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testNewModelInOldJvmPlugin() = with(Project("new-model-in-old-plugin", minGradle = TestGradle.v4_10_2)) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)

View File

@@ -27,7 +27,7 @@ import java.io.File
import kotlin.test.assertTrue
@TestDataPath("\$CONTENT_ROOT/resources")
class MultiplatformGradleIT : BaseGradleIT() {
open class MultiplatformGradleIT : BaseGradleIT() {
@Test
fun testMultiplatformCompile() {

View File

@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.gradle.util.*
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
import org.jetbrains.kotlin.konan.target.HostManager
import org.junit.Assert
import org.junit.Assume
import org.junit.Ignore
import org.junit.Test
import java.util.jar.JarFile
@@ -53,8 +52,8 @@ fun configure(): NativeTargets {
return NativeTargets(current, supported, unsupported)
}
class NewMultiplatformIT : BaseGradleIT() {
val gradleVersion = GradleVersionRequired.None
open class NewMultiplatformIT : BaseGradleIT() {
val gradleVersion = TestGradleRequirement.None
val nativeHostTargetName = configure().current
val supportedNativeTargets = configure().supported
@@ -205,10 +204,6 @@ class NewMultiplatformIT : BaseGradleIT() {
gradleBuildScript(libProjectName).takeIf { it.extension == "kts" }?.modify {
it.replace(Regex("""\.version\(.*\)"""), "")
}
build("clean", "assemble", "--rerun-tasks") {
checkAppBuild()
}
}
with(oldStyleAppProject) {
@@ -232,7 +227,7 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test
fun testMavenPublishAppliedBeforeMultiplatformPlugin() =
with(Project("sample-lib", GradleVersionRequired.AtLeast("5.0"), "new-mpp-lib-and-app")) {
with(Project("sample-lib", TestGradleRequirement.AtLeast("5.0"), "new-mpp-lib-and-app")) {
setupWorkingDir()
gradleBuildScript().modify { "apply plugin: 'maven-publish'\n$it" }
@@ -284,7 +279,7 @@ class NewMultiplatformIT : BaseGradleIT() {
fun testJavaSupportInJvmTargets() = doTestJvmWithJava(testJavaSupportInJvmTargets = true)
private fun doTestJvmWithJava(testJavaSupportInJvmTargets: Boolean) =
with(Project("sample-lib", GradleVersionRequired.AtLeast("5.0"), "new-mpp-lib-and-app")) {
with(Project("sample-lib", TestGradleRequirement.AtLeast("5.0"), "new-mpp-lib-and-app")) {
embedProject(Project("sample-lib-gradle-kotlin-dsl", directoryPrefix = "new-mpp-lib-and-app"))
lateinit var classesWithoutJava: Set<String>
@@ -1001,8 +996,8 @@ class NewMultiplatformIT : BaseGradleIT() {
private fun doTestNativeBinaryDSL(
projectName: String,
gradleVersionRequired: GradleVersionRequired = gradleVersion
) = with(transformProjectWithPluginsDsl(projectName, gradleVersionRequired, "new-mpp-native-binaries")) {
gradleRequirement: TestGradleRequirement = gradleVersion
) = with(transformProjectWithPluginsDsl(projectName, gradleRequirement, "new-mpp-native-binaries")) {
val hostSuffix = nativeHostTargetName.capitalize()
val binaries = mutableListOf(
@@ -1512,7 +1507,7 @@ class NewMultiplatformIT : BaseGradleIT() {
// Gradle 5.0 introduced a new API for Ivy repository layouts.
// MPP plugin uses this API to download K/N if Gradle version is >= 5.0.
// Check this too (see KT-30258).
with(Project("new-mpp-native-libraries", GradleVersionRequired.AtLeast("5.0"))) {
with(Project("new-mpp-native-libraries", TestGradleRequirement.AtLeast("5.0"))) {
build("tasks", "-Pkotlin.native.version=1.3.50-eap-11606") {
assertSuccessful()
assertTrue(output.contains("Kotlin/Native distribution: "))
@@ -1851,7 +1846,7 @@ class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testDependenciesDsl() = with(transformProjectWithPluginsDsl("newMppDependenciesDsl", GradleVersionRequired.AtLeast("4.10"))) {
fun testDependenciesDsl() = with(transformProjectWithPluginsDsl("newMppDependenciesDsl", TestGradleRequirement.AtLeast("4.10"))) {
val originalBuildscriptContent = gradleBuildScript("app").readText()
fun testDependencies() = testResolveAllConfigurations("app") {
@@ -1929,7 +1924,7 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test
fun testKt29725() {
with(Project("new-mpp-native-libraries", GradleVersionRequired.Exact("5.2"))) {
with(Project("new-mpp-native-libraries", TestGradleRequirement(minVer = TestGradle.v5_0))) {
// Assert that a project with a native target can be configured with Gradle 5.2
build("tasks") {
assertSuccessful()
@@ -1976,7 +1971,7 @@ class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testPomRewritingInSinglePlatformProject() = with(Project("kt-27059-pom-rewriting", GradleVersionRequired.AtLeast("4.10.2"))) {
fun testPomRewritingInSinglePlatformProject() = with(Project("kt-27059-pom-rewriting", TestGradleRequirement.AtLeast("4.10.2"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -2081,7 +2076,7 @@ class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testAssociateCompilations() = with(Project("new-mpp-associate-compilations", GradleVersionRequired.AtLeast("5.0"))) {
fun testAssociateCompilations() = with(Project("new-mpp-associate-compilations", TestGradleRequirement.AtLeast("5.0"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -2116,7 +2111,7 @@ class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testTestRunsApi() = with(Project("new-mpp-associate-compilations", GradleVersionRequired.AtLeast("5.0"))) {
fun testTestRunsApi() = with(Project("new-mpp-associate-compilations", TestGradleRequirement.AtLeast("5.0"))) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)

View File

@@ -7,7 +7,7 @@ import org.junit.Test
import java.io.File
import javax.xml.parsers.DocumentBuilderFactory
class PluginsDslIT : BaseGradleIT() {
open class PluginsDslIT : BaseGradleIT() {
@Test
fun testAllopenWithPluginsDsl() {
@@ -54,10 +54,9 @@ class PluginsDslIT : BaseGradleIT() {
private fun BaseGradleIT.projectWithMavenLocalPlugins(
projectName: String,
wrapperVersion: GradleVersionRequired = GradleVersionRequired.None,
directoryPrefix: String? = DIRECTORY_PREFIX,
minLogLevel: LogLevel = LogLevel.DEBUG
): Project = transformProjectWithPluginsDsl(projectName, wrapperVersion, directoryPrefix, minLogLevel)
): Project = transformProjectWithPluginsDsl(projectName, directoryPrefix, minLogLevel)
}
}
@@ -66,12 +65,11 @@ internal const val PLUGIN_MARKER_VERSION_PLACEHOLDER = "<pluginMarkerVersion>"
internal fun BaseGradleIT.transformProjectWithPluginsDsl(
projectName: String,
wrapperVersion: GradleVersionRequired = defaultGradleVersion,
directoryPrefix: String? = null,
minLogLevel: LogLevel = LogLevel.DEBUG
): BaseGradleIT.Project {
val result = Project(projectName, wrapperVersion, directoryPrefix, minLogLevel)
val result = Project(projectName, directoryPrefix, minLogLevel = minLogLevel)
result.setupWorkingDir()
val settingsGradle = File(result.projectDir, "settings.gradle").takeIf(File::exists)

View File

@@ -5,7 +5,7 @@ import org.junit.Test
import java.io.File
import kotlin.test.assertTrue
class SimpleKotlinGradleIT : BaseGradleIT() {
open class SimpleKotlinGradleIT : BaseGradleIT() {
@Test
fun testSimpleCompile() {

View File

@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.gradle
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
@@ -13,7 +12,7 @@ import java.io.File
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class SubpluginsIT : BaseGradleIT() {
open class SubpluginsIT : BaseGradleIT() {
@Test
fun testGradleSubplugin() {
val project = Project("kotlinGradleSubplugin")
@@ -149,7 +148,7 @@ class SubpluginsIT : BaseGradleIT() {
var isFailed = false
project.build("build", options = options) {
val classesDir = kotlinClassesDir("app", "main")
if (project.testGradleVersionAtLeast("5.0")) {
if (project.testGradle >= TestGradle.v5_0) {
assertSuccessful()
assertFileExists("${classesDir}World.class")
assertFileExists("${classesDir}Alice.class")
@@ -160,12 +159,10 @@ class SubpluginsIT : BaseGradleIT() {
assertCompiledKotlinSources(project.relativize(bobGreet, aliceGreet, worldGreet, greetScriptTemplateKt))
}
} else {
val usedGradleVersion =
GradleVersion.version(
System.getProperty("kotlin.gradle.version.for.tests")
?: project.gradleVersionRequirement.minVersion
)
assertEquals(true, usedGradleVersion.version.substringBefore('.').toIntOrNull()?.let { it < 5 }, "Expected gradle version < 5, got ${usedGradleVersion.version}")
assertEquals(
true, project.testGradle < TestGradle.v5_0,
"Expected gradle version < 5, got ${project.testGradle}"
)
assertContains("kotlin scripting plugin: incompatible Gradle version")
isFailed = true
}

View File

@@ -16,15 +16,27 @@
package org.jetbrains.kotlin.gradle
import android.app.Application
import android.test.ApplicationTestCase
import org.junit.Assume
class InternalDummyApplicationTest : ApplicationTestCase<Application>(Application::class.java) {
init {
val dummy = InternalDummy("World")
assert("Hello World!" == dummy.greeting) { "Expected: 'Hello World!'. Actual value: ${dummy.greeting}" }
enum class TestGradle(private val customVersionString: String? = null) {
// Values must be sorted!
v4_9,
v4_10_2,
v5_0,
v5_1,
v5_2,
v5_3_RC_1("5.3-rc-1"),
v5_3_RC_2("5.3-rc-2");
// Check that the Java sources from the tested variant are available
val bar = foo.FooJavaClass()
override fun toString() =
customVersionString
?: name.removePrefix("v").replace("_", ".")
companion object {
fun fromString(version: String): TestGradle =
values().firstOrNull { version == it.toString() } ?: error("Version $version not found")
val OLDEST = values().min()!!
val NEWEST = values().max()!!
}
}

View File

@@ -6,7 +6,7 @@ import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import java.io.File
class TestRootAffectedIT : BaseGradleIT() {
open class TestRootAffectedIT : BaseGradleIT() {
@Test
fun testSourceRootClassIsModifiedIC() {
val project = Project("kotlinProject")

View File

@@ -6,7 +6,7 @@ import org.junit.Assume
import org.junit.Test
import java.io.File
class UpToDateIT : BaseGradleIT() {
open class UpToDateIT : BaseGradleIT() {
@Test
fun testLanguageVersionChange() {
testMutations(

View File

@@ -9,12 +9,10 @@ import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
import org.junit.Test
class VariantAwareDependenciesIT : BaseGradleIT() {
private val gradleVersion = GradleVersionRequired.None
open class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testJvmKtAppResolvesMppLib() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("simpleProject")
with(outerProject) {
@@ -29,7 +27,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testJsKtAppResolvesMppLib() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("kotlin2JsInternalTest")
with(outerProject) {
@@ -44,7 +42,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testMppLibResolvesJvmKtApp() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("simpleProject")
with(outerProject) {
@@ -57,7 +55,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testMppLibResolvesJsKtApp() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("kotlin2JsInternalTest")
with(outerProject) {
@@ -70,7 +68,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testNonKotlinJvmAppResolvesMppLib() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("simpleProject").apply {
setupWorkingDir()
gradleBuildScript().modify {
@@ -78,7 +76,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
.replace("\"org.jetbrains.kotlin:kotlin-stdlib\"", "\"org.jetbrains.kotlin:kotlin-stdlib:\$kotlin_version\"")
}
if (testGradleVersionAtLeast("5.3-rc-1")) {
if (testGradle >= TestGradle.v5_3_RC_2) {
gradleBuildScript().appendText(
// In Gradle 5.3, the variants of a Kotlin MPP can't be disambiguated in a pure Java project's deprecated
// configurations that don't have a proper 'org.gradle.usage' attribute value, see KT-30378
@@ -103,7 +101,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testJvmKtAppResolvesJvmKtApp() {
val outerProject = Project("simpleProject", gradleVersion)
val outerProject = Project("simpleProject")
val innerProject = Project("jvmTarget") // cannot use simpleApp again, should be another project
with(outerProject) {
@@ -116,7 +114,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testJsKtAppResolvesJsKtApp() {
val outerProject = Project("kotlin2JsInternalTest", gradleVersion)
val outerProject = Project("kotlin2JsInternalTest")
val innerProject = Project("kotlin2JsNoOutputFileProject")
with(outerProject) {
@@ -129,7 +127,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testMppResolvesJvmAndJsKtLibs() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerJvmProject = Project("simpleProject")
val innerJsProject = Project("kotlin2JsInternalTest")
@@ -152,7 +150,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testJvmKtAppDependsOnMppTestRuntime() {
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
val outerProject = Project("sample-lib", "new-mpp-lib-and-app")
val innerProject = Project("simpleProject")
with(outerProject) {
@@ -198,7 +196,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
}
@Test
fun testResolvesOldKotlinArtifactsPublishedWithMetadata() = with(Project("multiplatformProject", gradleVersion)) {
fun testResolvesOldKotlinArtifactsPublishedWithMetadata() = with(Project("multiplatformProject")) {
setupWorkingDir()
projectDir.resolve("settings.gradle").appendText("\nenableFeaturePreview 'GRADLE_METADATA'")
gradleBuildScript().appendText(
@@ -254,7 +252,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
// Starting with Gradle 5.0, plain Maven dependencies are represented as two variants, and resolving them to the API one leads
// to transitive dependencies left out of the resolution results. We need to ensure that our attributes schema does not lead to the API
// variants chosen over the runtime ones when resolving a configuration with no required Usage:
with(Project("simpleProject", GradleVersionRequired.AtLeast("5.0-milestone-1"))) {
with(Project("simpleProject", minGradle = TestGradle.v5_0)) {
setupWorkingDir()
gradleBuildScript().appendText("\ndependencies { compile 'org.jetbrains.kotlin:kotlin-compiler-embeddable' }")
@@ -268,8 +266,8 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
@Test
fun testCompileAndRuntimeResolutionOfElementsConfigurations() =
with(Project("sample-app", gradleVersion, "new-mpp-lib-and-app")) {
val libProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
with(Project("sample-app", "new-mpp-lib-and-app")) {
val libProject = Project("sample-lib", "new-mpp-lib-and-app")
embedProject(libProject)
gradleBuildScript().modify {
it.replace("'com.example:sample-lib:1.0'", "project('${libProject.projectName}')")

View File

@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.gradle
import org.junit.Test
class WorkersIT : BaseGradleIT() {
open class WorkersIT : BaseGradleIT() {
@Test
fun testParallelTasks() {
parallelTasksImpl(isParallel = true)

View File

@@ -0,0 +1,143 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.generators
import org.jetbrains.kotlin.incremental.isClassFile
import org.jetbrains.org.objectweb.asm.*
import java.io.File
import java.util.*
import kotlin.collections.HashSet
import kotlin.collections.LinkedHashSet
annotation class GradleTestsRootClass
fun main(args: Array<String>) {
val classesDir = File(args.single())
val classFiles = classesDir.walk().filter { it.isClassFile() }
val subtypes = HashMap<String, MutableSet<String>>()
val supertype = HashMap<String, String>()
val classInfos = HashMap<String, ClassInfo>()
val rootClasses = HashSet<ClassInfo>()
for (classFile in classFiles) {
val reader = ClassReader(classFile.readBytes())
val classInfoCollector = ClassInfoCollector()
reader.accept(classInfoCollector, 0)
classInfoCollector.classInfo.let { ci ->
ci.superName?.let { superName ->
supertype[ci.name] = superName
subtypes.getOrPut(superName) { HashSet() }.add(ci.name)
}
if (GradleTestsRootClass::class.java.canonicalName in ci.annotations) {
rootClasses.add(ci)
}
classInfos[ci.name] = ci
}
}
val visited = HashSet<String>()
val queue = ArrayDeque<ClassInfo>()
queue.addAll(rootClasses)
val concreteTestClasses = HashSet<ClassInfo>()
while (queue.isNotEmpty()) {
val classInfo = queue.pollFirst()
if (visited.add(classInfo.name)) {
if (!classInfo.isAbstract) concreteTestClasses.add(classInfo)
for (typeName in (subtypes[classInfo.name] ?: emptySet<String>())) {
if (typeName !in visited) {
queue.add(classInfos[typeName]!!)
}
}
}
}
generateTests {
for (testClass in concreteTestClasses) {
addTestClass(testClass.name)
}
}
}
private data class ClassInfo(
val name: String,
val superName: String?,
private val access: Int,
val annotations: Set<String>
) {
val isAbstract: Boolean
get() = (access and Opcodes.ACC_ABSTRACT) == Opcodes.ACC_ABSTRACT
}
private class ClassInfoCollector : ClassVisitor(Opcodes.API_VERSION) {
private var name: String? = null
private var superName: String? = null
private var access: Int? = null
private val annotations = HashSet<String>()
val classInfo: ClassInfo by lazy {
ClassInfo(name = name!!, superName = superName, access = access!!, annotations = annotations)
}
override fun visit(version: Int, access: Int, name: String, signature: String?, superName: String?, interfaces: Array<out String>?) {
this.name = name.nameToFqName()
this.superName = superName?.nameToFqName()
this.access = access
}
override fun visitAnnotation(descriptor: String, visible: Boolean): AnnotationVisitor? {
annotations.add(descriptor.descriptorToFqName())
return super.visitAnnotation(descriptor, visible)
}
private fun String.nameToFqName() = Type.getObjectType(this).className
private fun String.descriptorToFqName() = Type.getType(this).className
}
private fun generateTests(configureTestGen: TestsGenerator.() -> Unit) {
TestsGenerator().apply {
configureTestGen()
generateTestsImpl(true)
generateTestsImpl(false)
}
}
private class TestsGenerator {
private val sourceTestClasses = LinkedHashSet<String>()
fun addTestClass(fqName: String) {
sourceTestClasses.add(fqName)
}
fun generateTestsImpl(useMinVersion: Boolean) {
val testType = if (useMinVersion) "min" else "max"
val targetModule = integrationTestsModule.resolve("generated/$testType-gradle")
val targetFile = targetModule.resolve("test/tests.kt")
targetFile.delete()
targetFile.parentFile.mkdirs()
targetFile.bufferedWriter().use { writer ->
writer.apply {
appendln("// DO NOT EDIT MANUALLY! GENERATED BY generateTestsWithAdvancedVersion.kt")
appendln("package ${testType}VersionGradleTests")
for (sourceTestClass in sourceTestClasses) {
val targetTestName = "${sourceTestClass.substringAfterLast(".")}With${testType.capitalize()}Gradle"
appendln()
appendln("class $targetTestName : ${sourceTestClass}() {")
appendln(" override val useMinVersion = $useMinVersion")
appendln("}")
}
}
}
}
companion object {
private val integrationTestsModule = File("libraries/tools/kotlin-gradle-plugin-integration-tests")
}
}

View File

@@ -11,7 +11,7 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
import kotlin.test.assertTrue
class AllOpenModelIT : BaseGradleIT() {
open class AllOpenModelIT : BaseGradleIT() {
@Test
fun testAllOpenSimple() {
val project = Project("allOpenSimple")

View File

@@ -10,7 +10,7 @@ import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull
class KaptModelIT : BaseGradleIT() {
open class KaptModelIT : BaseGradleIT() {
@Test
fun testKaptSimple() {
val project = Project("simple", directoryPrefix = "kapt2")

View File

@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.GradleVersionRequired
import org.jetbrains.kotlin.gradle.util.AGPVersion
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
@@ -15,7 +14,7 @@ import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
class KotlinAndroidExtensionIT : BaseGradleIT() {
open class KotlinAndroidExtensionIT : BaseGradleIT() {
override fun defaultBuildOptions(): BuildOptions {
return super.defaultBuildOptions().copy(
androidGradlePluginVersion = AGPVersion.v3_1_0,

View File

@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.GradleVersionRequired
import org.jetbrains.kotlin.gradle.util.AGPVersion
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
@@ -15,7 +14,7 @@ import kotlin.test.assertFalse
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
class KotlinProjectIT : BaseGradleIT() {
open class KotlinProjectIT : BaseGradleIT() {
override fun defaultBuildOptions(): BuildOptions {
return super.defaultBuildOptions().copy(
androidGradlePluginVersion = AGPVersion.v3_1_0,

View File

@@ -6,14 +6,13 @@
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.GradleVersionRequired
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
class NoArgModelIT : BaseGradleIT() {
open class NoArgModelIT : BaseGradleIT() {
@Test
fun testNoArgKt18668() {
val project = Project("noArgKt18668")

View File

@@ -11,7 +11,7 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
import kotlin.test.assertTrue
class SamWithReceiverModelIT : BaseGradleIT() {
open class SamWithReceiverModelIT : BaseGradleIT() {
@Test
fun testSamWithReceiverSimple() {
val project = Project("samWithReceiverSimple")

View File

@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.gradle.util
import java.io.File
import java.nio.file.Files
import java.util.*
fun File.getFileByName(name: String): File =
findFileByName(name) ?: throw AssertionError("Could not find file with name '$name' in $this")
@@ -69,6 +70,15 @@ fun normalizePath(path: String): String {
return path
}
fun withProperties(file: File, fn: (Properties) -> Unit) {
val p = Properties()
if (file.exists()) {
file.bufferedReader().use { p.load(it) }
}
fn(p)
file.bufferedWriter().use { p.store(it, null) }
}
private fun normalizeTail(prefixEnd: Int, path: String, separator: Boolean): String {
var separator = separator
val result = StringBuilder(path.length)

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.util
import java.io.File
val GRADLE_HOME_FOR_TESTS = File(notNullSystemProperty("gradle.for.tests.user.home"))
fun notNullSystemProperty(prop: String): String =
System.getProperty(prop) ?: error("System property '$prop' is not set")

View File

@@ -18,7 +18,6 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.dagger.kotlin"

View File

@@ -1,2 +1 @@
org.gradle.jvmargs=-ea -XX:MaxPermSize=512m
kapt.info.as.warnings=true

View File

@@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "org.example.manyvariants"
minSdkVersion 15

View File

@@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.dagger.kotlin"

View File

@@ -4,7 +4,6 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.dagger.kotlin"

View File

@@ -14,7 +14,6 @@ dependencies {
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.icepick.kotlin"
@@ -35,6 +34,6 @@ android {
repositories {
mavenLocal()
maven { url 'https://maven.google.com' }
mavenCentral()
maven { url 'https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/' }
maven { url "https://clojars.org/repo/" }
}

View File

@@ -2,7 +2,7 @@ buildscript {
repositories {
mavenLocal()
maven { url 'https://maven.google.com' }
mavenCentral()
maven { url 'https://cache-redirector.jetbrains.com/repo1.maven.org/maven2/' }
jcenter()
}
dependencies {

View File

@@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example"

View File

@@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 14

View File

@@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 14

View File

@@ -17,7 +17,6 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example"
@@ -44,6 +43,5 @@ repositories {
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

View File

@@ -1,52 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
dependencies {
compile project(':Lib')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile 'junit:junit:4.12'
}
android {
compileSdkVersion 22
buildToolsVersion "25.0.1"
sourceSets {
main.java.srcDirs += 'src/main/java2'
main.kotlin.srcDirs += 'root/kotlin'
test.kotlin.srcDirs += 'src/test/kotlin'
}
defaultConfig {
minSdkVersion 7
targetSdkVersion 22
jackOptions { enabled true }
}
buildTypes {
jnidebug.initWith(buildTypes.debug)
jnidebug {
applicationIdSuffix ".jnidebug"
jniDebuggable true
}
}
productFlavors {
flavor1 {
applicationId "com.example.flavor1"
versionCode 20
}
flavor2 {
applicationId "com.example.flavor2"
minSdkVersion 14
}
}
publishNonDefault true
kotlinOptions {
noJdk = true
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.gradle.test.androidalfa
import android.content.Intent
import android.os.Bundle
import android.app.Activity
import android.view.Menu
import android.view.View
import android.widget.Button
import org.jetbrains.kotlin.gradle.test.androidalfa.R
import lib.*
open class MainActivity2: Activity() {
protected override fun onCreate(savedInstanceState: Bundle?): Unit {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
libUtil()
var next: Button = findViewById(R.id.Button02) as Button
next.setOnClickListener(object: View.OnClickListener {
public override fun onClick(view: View): Unit {
val intent: Intent = Intent()
setResult(Activity.RESULT_OK, intent)
finish()
}
})
}
public override fun onCreateOptionsMenu(menu: Menu?): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_activity2, menu);
return true
}
}
fun foo() {
bar()
}
fun bar() {
}

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jetbrains.kotlin.gradle.test.androidalfa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="org.jetbrains.kotlin.gradle.test.androidalfa.MainActivity"
android:label="@string/title_activity_main_activity1" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="org.jetbrains.kotlin.gradle.test.androidalfa.MainActivity2"
android:label="@string/title_activity_main_activity2" >
</activity>
</application>
</manifest>

View File

@@ -1,27 +0,0 @@
/*
* 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 foo;
import bar.*;
public class FooJavaClass {
void f() {
new FooKotlinClass();
new BarJavaClass();
new BarKotlinClass();
}
}

View File

@@ -1,27 +0,0 @@
/*
* 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 foo
import bar.*
class FooKotlinClass {
fun f() {
FooJavaClass()
BarJavaClass()
BarKotlinClass()
}
}

View File

@@ -1,22 +0,0 @@
/*
* 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.gradle
internal class InternalDummy(private val name: String) {
internal val greeting: String
get() = "Hello $name!"
}

View File

@@ -1,52 +0,0 @@
/*
* 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.gradle.test.androidalfa;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import org.jetbrains.kotlin.gradle.test.androidalfa.R;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), MainActivity2.class);
startActivityForResult(myIntent, 0);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

View File

@@ -1,27 +0,0 @@
/*
* 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 bar;
import foo.*;
public class BarJavaClass {
void f() {
new BarKotlinClass();
new FooJavaClass();
new FooKotlinClass();
}
}

View File

@@ -1,27 +0,0 @@
/*
* 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 bar
import foo.*
class BarKotlinClass {
fun f() {
BarJavaClass()
FooJavaClass()
FooKotlinClass()
}
}

View File

@@ -1,24 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Activity 1" />
<Button android:text="Next"
android:id="@+id/Button01"
android:layout_width="250px"
android:textSize="18px"
android:layout_height="55px">
</Button>
</LinearLayout>

View File

@@ -1,24 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Activity 2" />
<Button android:text="Next"
android:id="@+id/Button02"
android:layout_width="250px"
android:textSize="18px"
android:layout_height="55px">
</Button>
</LinearLayout>

View File

@@ -1,6 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
</menu>

View File

@@ -1,6 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
</menu>

View File

@@ -1,5 +0,0 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AndroidAlfa</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_main_activity1">MainActivity1</string>
<string name="title_activity_main_activity2">MainActivity2</string>
</resources>

View File

@@ -1,20 +0,0 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View File

@@ -1,28 +0,0 @@
/*
* 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.gradle
import org.junit.Assert
import org.junit.Test
class InternalDummyTest {
@Test
fun testInternalDummy() {
val dummy = InternalDummy("World")
Assert.assertEquals("Hello World!", dummy.greeting)
}
}

View File

@@ -1,19 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
dependencies {
compile files('libs/android-support-v4.jar')
// unused but needed for IncrementalCompilationMultiProjectIT.testAndroid to check if non-local dependency affects IC
compile 'io.reactivex:rxjava:1.1.9'
compile 'com.loopj.android:android-async-http:1.4.9'
}
android {
compileSdkVersion 22
buildToolsVersion "25.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 22
}
}

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jetbrains.kotlin.gradle.test.android.libalfa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="org.jetbrains.kotlin.gradle.test.android.libalfa.LibMainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -1,39 +0,0 @@
/*
* 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.gradle.test.android.libalfa;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class LibMainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lib_activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.lib_main, menu);
return true;
}
}

View File

@@ -1,19 +0,0 @@
/*
* 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 lib
fun libUtil(): String = "libUtil"

View File

@@ -1,16 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".LibMainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>

View File

@@ -1,6 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
</menu>

View File

@@ -1,4 +0,0 @@
<resources>
<!-- Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here. -->
</resources>

View File

@@ -1,5 +0,0 @@
<resources>
<!-- Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. -->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View File

@@ -1,11 +0,0 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@@ -1,12 +0,0 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View File

@@ -1,5 +0,0 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

Some files were not shown because too many files have changed in this diff Show More