diff --git a/adam/build.gradle.kts b/adam/build.gradle.kts index 78bafa460..aa395943a 100644 --- a/adam/build.gradle.kts +++ b/adam/build.gradle.kts @@ -36,17 +36,6 @@ protobuf { protoc { artifact = "com.google.protobuf:protoc:${Versions.protobuf}" } - plugins { - id("java") { - artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}" - } - id("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}" - } - id("grpckt") { - artifact = "io.grpc:protoc-gen-grpc-kotlin:${Versions.grpcKotlin}:jdk7@jar" - } - } generateProtoTasks { all().forEach { it.builtins { @@ -56,12 +45,6 @@ protobuf { id("java") { option("lite") } - id("grpc") { - option("lite") - } - id("grpckt") { - option("lite") - } } } } @@ -153,17 +136,14 @@ dependencies { implementation(kotlin("stdlib-jdk8", version = Versions.kotlin)) implementation(Libraries.coroutines) implementation(Libraries.logging) - api(Libraries.protobufLite) - api(Libraries.grpcProtobufLite) - api(Libraries.grpcKotlinStub) - api(Libraries.grpcOkhttp) - api(Libraries.grpcStub) implementation(Libraries.javaxAnnotations) implementation(Libraries.vertxCore) implementation(Libraries.vertxKotlin) implementation(Libraries.vertxCoroutines) implementation(Libraries.apacheCommonsPool2) + api(Libraries.protobufLite) + testImplementation(TestLibraries.assertk) testImplementation(TestLibraries.junit4) testImplementation(TestLibraries.imageComparison) @@ -175,4 +155,5 @@ dependencies { integrationTestImplementation(TestLibraries.assertk) integrationTestImplementation(TestLibraries.junit4) integrationTestImplementation(kotlin("reflect", version = Versions.kotlin)) + integrationTestImplementation(project(":testing")) } diff --git a/android-junit4/build.gradle.kts b/android-junit4/build.gradle.kts index b8d40f408..e8cbc8d93 100644 --- a/android-junit4/build.gradle.kts +++ b/android-junit4/build.gradle.kts @@ -59,6 +59,7 @@ dependencies { api(Libraries.coroutines) api(AndroidX.testMonitor) api(project(":android-testrunner-contract")) + api(project(":emulator-proto")) } afterEvaluate { diff --git a/emulator-proto/build.gradle.kts b/emulator-proto/build.gradle.kts new file mode 100644 index 000000000..5cccecd2a --- /dev/null +++ b/emulator-proto/build.gradle.kts @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2021 Anton Malinskiy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.google.protobuf.gradle.builtins +import com.google.protobuf.gradle.generateProtoTasks +import com.google.protobuf.gradle.id +import com.google.protobuf.gradle.plugins +import com.google.protobuf.gradle.protobuf +import com.google.protobuf.gradle.protoc +import com.google.protobuf.gradle.remove + +plugins { + kotlin("jvm") + id("jacoco") + id("org.jetbrains.dokka") + id("com.google.protobuf") version Versions.protobufGradle + id("idea") +} + +Deployment.initialize(project) + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:${Versions.protobuf}" + } + plugins { + id("java") { + artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}" + } + id("grpc") { + artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}" + } + id("grpckt") { + artifact = "io.grpc:protoc-gen-grpc-kotlin:${Versions.grpcKotlin}:jdk7@jar" + } + } + generateProtoTasks { + all().forEach { + it.builtins { + remove("java") + } + it.plugins { + id("java") { + option("lite") + } + id("grpc") { + option("lite") + } + id("grpckt") { + option("lite") + } + } + } + } +} + +sourceSets { + create("integrationTest") { + compileClasspath += sourceSets.main.get().output + runtimeClasspath += sourceSets.main.get().output + } +} + +val integrationTestImplementation: Configuration by configurations.getting { + extendsFrom(configurations.implementation.get()) +} + +configurations["integrationTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get()) + +fun DependencyHandler.`integrationTestImplementation`(dependencyNotation: Any): Dependency? = + add("integrationTestImplementation", dependencyNotation) + + +val integrationTest = task("integrationTest") { + description = "Runs integration tests" + group = "verification" + + testClassesDirs = sourceSets["integrationTest"].output.classesDirs + classpath = sourceSets["integrationTest"].runtimeClasspath + shouldRunAfter("test") + + jacoco { + include("**") + } +} +integrationTest.outputs.upToDateWhen { false } + +val connectedAndroidTest = task("connectedAndroidTest") { + description = "Runs integration tests" + group = "verification" + + dependsOn(integrationTest) +} + +val jacocoIntegrationTestReport = task("jacocoIntegrationTestReport") { + description = "Generates code coverage report for integrationTest task" + group = "verification" + reports { + xml.isEnabled = true + } + + executionData(integrationTest) + sourceSets(sourceSets.getByName("integrationTest")) + classDirectories.setFrom(sourceSets.getByName("main").output.classesDirs) +} +tasks.check { dependsOn(integrationTest, jacocoIntegrationTestReport) } + +val jacocoCombinedTestReport = task("jacocoCombinedTestReport") { + description = "Generates code coverage report for all test tasks" + group = "verification" + + executionData(integrationTest, tasks["test"]) + sourceSets(sourceSets.getByName("integrationTest"), sourceSets.getByName("test")) + classDirectories.setFrom(sourceSets.getByName("main").output.classesDirs) + dependsOn(tasks["test"], integrationTest) +} + +tasks.jacocoTestReport { + reports { + xml.isEnabled = true + } +} + +tasks.dokkaHtml.configure { + outputDirectory.set(rootProject.rootDir.resolve("docs/api")) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { + kotlinOptions.jvmTarget = "1.8" + kotlinOptions.apiVersion = "1.5" +} + +dependencies { + implementation(Libraries.annotations) + implementation(kotlin("stdlib-jdk8", version = Versions.kotlin)) + implementation(Libraries.coroutines) + implementation(Libraries.ktorNetwork) + implementation(Libraries.logging) + api(Libraries.protobufLite) + api(Libraries.grpcProtobufLite) + api(Libraries.grpcKotlinStub) + api(Libraries.grpcOkhttp) + api(Libraries.grpcStub) + implementation(Libraries.javaxAnnotations) + implementation(Libraries.vertxCore) + implementation(Libraries.vertxKotlin) + implementation(Libraries.vertxCoroutines) + implementation(Libraries.apacheCommonsPool2) + + testImplementation(TestLibraries.assertk) + testImplementation(TestLibraries.junit4) + testImplementation(TestLibraries.imageComparison) + testImplementation(kotlin("reflect", version = Versions.kotlin)) + testImplementation(TestLibraries.coroutinesDebug) + testImplementation(project(":server:server-stub-junit4")) + + integrationTestImplementation(TestLibraries.coroutinesDebug) + integrationTestImplementation(TestLibraries.assertk) + integrationTestImplementation(TestLibraries.junit4) + integrationTestImplementation(kotlin("reflect", version = Versions.kotlin)) + integrationTestImplementation(project(":testing")) +} diff --git a/adam/src/integrationTest/kotlin/com/malinskiy/adam/integration/EmulatorGrpcE2ETest.kt b/emulator-proto/src/integrationTest/kotlin/com/malinskiy/adam/integration/EmulatorGrpcE2ETest.kt similarity index 100% rename from adam/src/integrationTest/kotlin/com/malinskiy/adam/integration/EmulatorGrpcE2ETest.kt rename to emulator-proto/src/integrationTest/kotlin/com/malinskiy/adam/integration/EmulatorGrpcE2ETest.kt diff --git a/adam/src/main/proto/emulator_controller.proto b/emulator-proto/src/main/proto/emulator_controller.proto similarity index 100% rename from adam/src/main/proto/emulator_controller.proto rename to emulator-proto/src/main/proto/emulator_controller.proto diff --git a/settings.gradle.kts b/settings.gradle.kts index 587de5e5d..7206536f1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,6 +25,8 @@ include(":transport-ktor") include(":android-junit4") include(":android-junit4-test-annotation-producer") include(":android-testrunner-contract") +include(":emulator-proto") include(":server:server-stub") include(":server:server-stub-junit4") include(":server:server-stub-junit5") +include(":testing") diff --git a/testing/build.gradle.kts b/testing/build.gradle.kts new file mode 100644 index 000000000..60ebf6940 --- /dev/null +++ b/testing/build.gradle.kts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 Anton Malinskiy + * + * 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. + */ + +plugins { + kotlin("jvm") + id("idea") +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { + kotlinOptions.jvmTarget = "1.8" + kotlinOptions.apiVersion = "1.5" +} + +dependencies { + implementation(project(":adam")) + implementation(Libraries.coroutines) + implementation(TestLibraries.junit4) +} diff --git a/adam/src/integrationTest/kotlin/com/malinskiy/adam/rule/AdbDeviceRule.kt b/testing/src/main/kotlin/com/malinskiy/adam/rule/AdbDeviceRule.kt similarity index 100% rename from adam/src/integrationTest/kotlin/com/malinskiy/adam/rule/AdbDeviceRule.kt rename to testing/src/main/kotlin/com/malinskiy/adam/rule/AdbDeviceRule.kt diff --git a/adam/src/integrationTest/kotlin/com/malinskiy/adam/rule/DeviceType.kt b/testing/src/main/kotlin/com/malinskiy/adam/rule/DeviceType.kt similarity index 100% rename from adam/src/integrationTest/kotlin/com/malinskiy/adam/rule/DeviceType.kt rename to testing/src/main/kotlin/com/malinskiy/adam/rule/DeviceType.kt