-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ee7398
commit bbaf8d2
Showing
18 changed files
with
145 additions
and
45 deletions.
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
12 changes: 0 additions & 12 deletions
12
buildSrc/src/main/kotlin/enable-explicit-api-mode.gradle.kts
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
buildSrc/src/main/kotlin/io/embrace/internal/BuildPlugin.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,76 @@ | ||
package io.embrace.internal | ||
|
||
import gradle.kotlin.dsl.accessors._3413c52528fd46b4e275cc05d0f006bb.android | ||
import gradle.kotlin.dsl.accessors._3413c52528fd46b4e275cc05d0f006bb.kotlin | ||
import gradle.kotlin.dsl.accessors._3413c52528fd46b4e275cc05d0f006bb.kotlinOptions | ||
import io.embrace.gradle.Versions | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.assign | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
|
||
class BuildPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project) { | ||
val extension = project.extensions.create("embrace", EmbraceBuildLogicExtension::class.java) | ||
project.configureAndroidExtension() | ||
|
||
if (extension.explicitApiMode.get()) { | ||
project.configureExplicitApiMode() | ||
} | ||
// project.logger.lifecycle(extension.printSomething.get()) | ||
// } | ||
// project.logger.lifecycle("Embrace Build Plugin applied!") | ||
// | ||
// // Example: Apply common settings to all subprojects | ||
// project.subprojects { | ||
// plugins.apply("java-library") | ||
// | ||
// // Configure dependencies | ||
// dependencies.add("implementation", "org.jetbrains.kotlin:kotlin-stdlib") | ||
// } | ||
} | ||
|
||
private fun Project.configureAndroidExtension() { | ||
android { | ||
compileSdk = Versions.COMPILE_SDK | ||
|
||
defaultConfig { | ||
minSdk = Versions.MIN_SDK | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
lint { | ||
abortOnError = true | ||
warningsAsErrors = true | ||
checkAllWarnings = true | ||
checkReleaseBuilds = false // run on CI instead, speeds up release builds | ||
baseline = project.file("lint-baseline.xml") | ||
disable.addAll(mutableSetOf("GradleDependency", "NewerVersionAvailable")) | ||
} | ||
|
||
kotlin { | ||
compilerOptions { | ||
apiVersion.set(KotlinVersion.KOTLIN_1_8) | ||
languageVersion.set(KotlinVersion.KOTLIN_1_8) | ||
jvmTarget.set(JvmTarget.JVM_1_8) | ||
allWarningsAsErrors = true | ||
} | ||
} | ||
} | ||
} | ||
private fun Project.configureExplicitApiMode() { | ||
android { | ||
kotlinOptions { | ||
freeCompilerArgs = freeCompilerArgs + listOf("-Xexplicit-api=strict") | ||
} | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
buildSrc/src/main/kotlin/io/embrace/internal/EmbraceBuildLogicExtension.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,30 @@ | ||
package io.embrace.internal | ||
|
||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
|
||
/** | ||
* Controls Embrace build logic for a given module. | ||
*/ | ||
abstract class EmbraceBuildLogicExtension(objectFactory: ObjectFactory) { // TODO: support Java modules | ||
|
||
/** | ||
* Whether binary compatibility checks should be enabled for this module to avoid adding | ||
* unintentional API changes. | ||
*/ | ||
val apiCompatChecks: Property<Boolean> = | ||
objectFactory.property(Boolean::class.java).convention(false) // TODO: support | ||
|
||
/** | ||
* Whether Kotlin's explicit API mode should be enabled. | ||
*/ | ||
val explicitApiMode: Property<Boolean> = | ||
objectFactory.property(Boolean::class.java).convention(false) // TODO: support | ||
|
||
/** | ||
* If this is false then the module will not be published & will be treated as something that | ||
* contains internal code used for testing. | ||
*/ | ||
val productionModule: Property<Boolean> = | ||
objectFactory.property(Boolean::class.java).convention(true) // TODO: support | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("embrace-prod-defaults") | ||
id("io.embrace.internal.build-logic") | ||
id("com.google.devtools.ksp") | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("embrace-test-defaults") | ||
id("io.embrace.internal.build-logic") | ||
} | ||
|
||
android { | ||
|
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("embrace-test-defaults") | ||
id("io.embrace.internal.build-logic") | ||
} | ||
|
||
android { | ||
|