diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-10-31 18:51:45 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-11-02 17:59:50 +0300 |
commit | 05d613daf13d7a0866b65ed555544b62e8197547 (patch) | |
tree | 54064c7aba62e2d09eb78c86beaced12ded4ffb5 /runners/gradle-integration-tests/src | |
parent | e9ab5d88150323067672661d37f8d7f8b146311d (diff) | |
download | dokka-05d613daf13d7a0866b65ed555544b62e8197547.tar.gz dokka-05d613daf13d7a0866b65ed555544b62e8197547.tar.bz2 dokka-05d613daf13d7a0866b65ed555544b62e8197547.zip |
Fix android-sdk license accepting on TeamCity
Diffstat (limited to 'runners/gradle-integration-tests/src')
3 files changed, 45 insertions, 3 deletions
diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt new file mode 100644 index 00000000..52aa4f15 --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaAndroidGradleTest.kt @@ -0,0 +1,43 @@ +package org.jetbrains.dokka.gradle + +import org.junit.BeforeClass +import java.io.File + +abstract class AbstractDokkaAndroidGradleTest : AbstractDokkaGradleTest() { + + companion object { + + @JvmStatic + @BeforeClass + fun acceptAndroidSdkLicenses() { + val sdkDir = androidLocalProperties?.toFile()?.let { + val lines = it.readLines().map { it.trim() } + val sdkDirLine = lines.firstOrNull { "sdk.dir" in it } + sdkDirLine?.substringAfter("=")?.trim() + } ?: System.getenv("ANDROID_HOME") + + if (sdkDir == null || sdkDir.isEmpty()) { + error("Android SDK home not set, " + + "try setting \$ANDROID_HOME " + + "or sdk.dir in runners/gradle-integration-tests/testData/android.local.properties") + } + val sdkDirFile = File(sdkDir) + if (!sdkDirFile.exists()) error("\$ANDROID_HOME and android.local.properties points to non-existing location") + val sdkLicensesDir = sdkDirFile.resolve("licenses") + + val acceptedLicenses = File("android-licenses") + acceptedLicenses.listFiles().forEach { licenseFile -> + val target = sdkLicensesDir.resolve(licenseFile.name) + if(!target.exists() || target.readText() != licenseFile.readText()) { + val overwrite = System.getProperty("android.licenses.overwrite", "false").toBoolean() + if (!target.exists() || overwrite) { + licenseFile.copyTo(target, true) + println("Accepted ${licenseFile.name}, by copying $licenseFile to $target") + } + } + + } + } + + } +}
\ No newline at end of file diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt index de22a980..1975d6e2 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAppTest.kt @@ -3,10 +3,9 @@ package org.jetbrains.dokka.gradle import org.gradle.testkit.runner.TaskOutcome import org.junit.Test import java.io.File -import java.nio.file.Files import kotlin.test.assertEquals -class AndroidAppTest : AbstractDokkaGradleTest() { +class AndroidAppTest : AbstractDokkaAndroidGradleTest() { override val pluginClasspath: List<File> = androidPluginClasspathData.toFile().readLines().map { File(it) } fun prepareTestData(testDataRootPath: String) { diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt index aee0e14c..0a9b2427 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidMultiFlavourAppTest.kt @@ -6,7 +6,7 @@ import org.junit.Test import java.io.File import kotlin.test.assertEquals -class AndroidMultiFlavourAppTest : AbstractDokkaGradleTest() { +class AndroidMultiFlavourAppTest : AbstractDokkaAndroidGradleTest() { override val pluginClasspath: List<File> = androidPluginClasspathData.toFile().readLines().map { File(it) } fun prepareTestData(testDataRootPath: String) { |