Skip to content

Commit 995ea19

Browse files
committed
Allow to skip gradle tasks depending on Android if SKIP_ANDROID env variable is defined
1 parent 44ebe35 commit 995ea19

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ While developing, you can build, run pre-commits, checks & tests on the plugin u
165165

166166
Make sure your tests are all green ✅ locally before submitting PRs.
167167

168+
NOTE: If you don't have the [Android SDK](https://developer.android.com/studio/releases/sdk-tools) you can skip the Android related tasks by setting `SKIP_ANDROID` enviromental variable (tests will be run on the CI anyway).
169+
168170
## Contributing/Support
169171

170172
Support for this project is offered in the [#swagger-gradle-codegen](https://kotlinlang.slack.com/archives/CU233PG2Z) channel on the Kotlinlang slack ([request an invite here](http://slack.kotlinlang.org/)).

samples/junit-tests/build.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
plugins {
2-
id("com.android.library")
3-
id("kotlin-android")
2+
id("kotlin")
43
id("com.yelp.codegen.plugin")
54
id("io.gitlab.arturbosch.detekt")
65
id("kotlin-kapt")
76
}
87

9-
android {
10-
compileSdkVersion = 28
11-
defaultConfig {
12-
minSdkVersion 21
13-
targetSdkVersion 28
14-
versionCode = 1
15-
versionName = "1.0"
16-
}
17-
}
18-
198
dependencies {
209
// Kotlin
2110
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.70"

samples/junit-tests/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,27 @@ pluginManagement {
1717
}
1818
}
1919

20-
include(
21-
":samples:junit-tests",
20+
include(":samples:junit-tests")
21+
22+
if (shouldIncludeAndroidProjects()) {
23+
include(
2224
":samples:kotlin-android",
2325
":samples:kotlin-coroutines",
24-
":samples:groovy-android")
26+
":samples:groovy-android"
27+
)
28+
}
2529

2630
includeBuild("gradle-plugin")
31+
32+
fun shouldIncludeAndroidProjects(): Boolean {
33+
if (System.getenv("CI") != null) {
34+
// Ensure that on CI systems we run all the gradle tasks (including the Android specific ones)
35+
return true;
36+
}
37+
38+
if (System.getenv("SKIP_ANDROID") != null) {
39+
return false;
40+
}
41+
42+
return true;
43+
}

0 commit comments

Comments
 (0)