-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds android app and lib conventions (#9)
* Creates initial app convention * Creates initial lib convention * Adds plugin accessors
- Loading branch information
Showing
8 changed files
with
455 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
conventions/src/main/kotlin/com.github.kyhule.polyworld.build.android-app.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import com.github.kyhule.polyworld.build.jdkVersion | ||
import com.github.kyhule.polyworld.build.compileSdkVersion as polyCompileSdkVersion | ||
import com.github.kyhule.polyworld.build.minSdkVersion | ||
import com.github.kyhule.polyworld.build.targetSdkVersion | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("kotlin-android") | ||
} | ||
|
||
android { | ||
compileSdk = polyCompileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = minSdkVersion | ||
targetSdk = targetSdkVersion | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
matchingFallbacks.add("release") | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.toVersion(jdkVersion) | ||
targetCompatibility = JavaVersion.toVersion(jdkVersion) | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = jdkVersion.toString() | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
conventions/src/main/kotlin/com.github.kyhule.polyworld.build.android-lib.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import com.github.kyhule.polyworld.build.jdkVersion | ||
import com.github.kyhule.polyworld.build.compileSdkVersion as polyCompileSdkVersion | ||
import com.github.kyhule.polyworld.build.minSdkVersion | ||
import com.github.kyhule.polyworld.build.targetSdkVersion | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("kotlin-android") | ||
} | ||
|
||
android { | ||
compileSdk = polyCompileSdkVersion | ||
|
||
defaultConfig { | ||
minSdk = minSdkVersion | ||
targetSdk = targetSdkVersion | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
matchingFallbacks.add("release") | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.toVersion(jdkVersion) | ||
targetCompatibility = JavaVersion.toVersion(jdkVersion) | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = jdkVersion.toString() | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
conventions/src/main/kotlin/com/github/kyhule/polyworld/build/PolyworldProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.kyhule.polyworld.build | ||
|
||
import com.github.kyhule.polyworld.build.util.* | ||
import com.github.kyhule.polyworld.build.util.booleanProperty | ||
import com.github.kyhule.polyworld.build.util.longProperty | ||
import org.gradle.api.Project | ||
|
||
|
||
val Project.compileSdkVersion: Int | ||
get() = intProperty("polyworld.compileSdkVersion", defaultValue = 33) | ||
|
||
val Project.minSdkVersion: Int | ||
get() = intProperty("polyworld.minSdkVersion", defaultValue = 24) | ||
|
||
val Project.targetSdkVersion: Int | ||
get() = intProperty("polyworld.targetSdkVersion", defaultValue = 33) | ||
|
||
val Project.jdkVersion: Int | ||
get() = intProperty("polyworld.jdkVersion", defaultValue = 17) | ||
|
||
/** Flag to enable verbose logging in unit tests. */ | ||
val Project.testVerboseLogging: Boolean | ||
get() = booleanProperty("polyworld.test.verboseLogging") | ||
|
||
/** | ||
* Property corresponding to the number unit tests to run on a fork before it is disposed. | ||
* This helps when tests leak memory. | ||
* | ||
* **See Also:** [Forking options](https://docs.gradle.org/current/userguide/performance.html#forking_options) | ||
*/ | ||
val Project.testForkEvery: Long | ||
get() = longProperty("polyworld.test.forkEvery", defaultValue = 100L) |
73 changes: 73 additions & 0 deletions
73
conventions/src/main/kotlin/com/github/kyhule/polyworld/build/util/HasConfigurableValues.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.github.kyhule.polyworld.build.util | ||
|
||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.MapProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.provider.SetProperty | ||
|
||
/* | ||
* APIs adapted from `HasConfigurableValues.kt` in AGP. Copied for binary safety. | ||
*/ | ||
|
||
internal fun ConfigurableFileCollection.fromDisallowChanges(vararg arg: Any) { | ||
from(*arg) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> Property<T>.setDisallowChanges(value: T?) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> Property<T>.setDisallowChanges(value: Provider<out T>) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> ListProperty<T>.setDisallowChanges(value: Provider<out Iterable<T>>) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> ListProperty<T>.setDisallowChanges(value: Iterable<T>?) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <K, V> MapProperty<K, V>.setDisallowChanges(map: Provider<Map<K, V>>) { | ||
set(map) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <K, V> MapProperty<K, V>.setDisallowChanges(map: Map<K, V>?) { | ||
set(map) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> SetProperty<T>.setDisallowChanges(value: Provider<out Iterable<T>>) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> SetProperty<T>.setDisallowChanges(value: Iterable<T>?) { | ||
set(value) | ||
disallowChanges() | ||
} | ||
|
||
internal fun <T> ListProperty<T>.setDisallowChanges( | ||
value: Provider<out Iterable<T>>?, | ||
handleNullable: ListProperty<T>.() -> Unit | ||
) { | ||
value?.let { set(value) } ?: handleNullable() | ||
disallowChanges() | ||
} | ||
|
||
internal fun <K, V> MapProperty<K, V>.setDisallowChanges( | ||
map: Provider<Map<K, V>>?, | ||
handleNullable: MapProperty<K, V>.() -> Unit | ||
) { | ||
map?.let { set(map) } ?: handleNullable() | ||
disallowChanges() | ||
} |
Oops, something went wrong.