-
-
Notifications
You must be signed in to change notification settings - Fork 166
Update project build configuration and dependencies #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 23 commits
7124afd
75ff0ad
129360a
f3f10c2
88e345c
7d7450f
95db997
4f5bf41
a05ce49
4f66d4c
cd60348
664917d
4bd3336
2a768f1
a2fe0f7
db76d3f
75b7ec7
b4223d7
6de76c2
a4efe74
86a66e1
1a92029
72e2a9b
97bf62e
910a76b
8c3141d
7d3866b
1bd3f50
0738d86
6198a48
85e9663
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,63 @@ | ||
| /.idea | ||
| /local.properties | ||
| /build | ||
| /captures | ||
| .DS_Store | ||
| .externalNativeBuild | ||
| .gradle | ||
| # Dropbox focus plugin | ||
| *.focus | ||
|
|
||
| # https://github.com/github/gitignore/blob/main/Android.gitignore | ||
| # Gradle files | ||
| .gradle/ | ||
| build/ | ||
|
|
||
| # Local configuration file (sdk path, etc) | ||
| local.properties | ||
|
|
||
| # Log/OS Files | ||
| *.log | ||
|
|
||
| # Android Studio generated files and folders | ||
| captures/ | ||
| .externalNativeBuild/ | ||
| .cxx/ | ||
| *.apk | ||
| output.json | ||
|
|
||
| # IntelliJ | ||
| *.iml | ||
| *.focus | ||
| .idea/ | ||
| misc.xml | ||
| deploymentTargetDropDown.xml | ||
| render.experimental.xml | ||
|
|
||
| # Keystore files | ||
| *.jks | ||
| *.keystore | ||
|
|
||
| # Google Services (e.g. APIs or Firebase) | ||
| google-services.json | ||
|
|
||
| # Android Profiling | ||
| *.hprof | ||
|
|
||
| # https://github.com/github/gitignore/blob/main/Kotlin.gitignore | ||
| # Kotlin data directory | ||
| .kotlin/ | ||
|
|
||
| # Compiled class file | ||
| *.class | ||
|
|
||
| # BlueJ files | ||
| *.ctxt | ||
|
|
||
| # Mobile Tools for Java (J2ME) | ||
| .mtj.tmp/ | ||
|
|
||
| # Package Files # | ||
| *.jar | ||
| *.war | ||
| *.nar | ||
| *.ear | ||
| *.zip | ||
| *.tar.gz | ||
| *.rar | ||
|
|
||
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* | ||
| replay_pid* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| plugins { | ||
| `kotlin-dsl` | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(libs.pluginartifact.android) | ||
| compileOnly(libs.pluginartifact.kotlin) | ||
| compileOnly(libs.pluginartifact.ktlint) | ||
| compileOnly(libs.pluginartifact.mavenPublish) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| rootProject.name = "build-config" | ||
|
|
||
| dependencyResolutionManagement { | ||
| repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS | ||
| repositories { | ||
| mavenCentral() | ||
| google() | ||
| gradlePluginPortal() | ||
| } | ||
| versionCatalogs { | ||
| create("libs") { | ||
| from(files("../gradle/libs.versions.toml")) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import com.android.build.gradle.BaseExtension | ||
| import extensions.isAndroidApplicationModule | ||
| import extensions.isAndroidLibraryModule | ||
| import extensions.isMultiplatformModule | ||
|
|
||
| configure<BaseExtension> { | ||
| compileSdkVersion(36) | ||
| defaultConfig { | ||
| minSdk = 21 | ||
|
|
||
| if (isAndroidApplicationModule()) { | ||
| targetSdk = 36 | ||
| versionCode = 1 | ||
| versionName = "1.0" | ||
| } | ||
|
|
||
| if (isAndroidLibraryModule()) { | ||
| val proguardFilename = "consumer-rules.pro" | ||
| if (layout.projectDirectory.file(proguardFilename).asFile.exists()) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need check if exists. AGP ignores the file whether it doesn't exist.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGP will print that certain proguard files not found:
If you ok with this I remove an if clause.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You removed the empty files. That is the reason to complain about missing it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion a project has less clutter when it doesn't have files that don't affect anything. |
||
| consumerProguardFile(proguardFilename) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||
| } | ||
|
|
||
| testOptions { | ||
| unitTests.all(Test::useJUnitPlatform) | ||
| } | ||
|
|
||
| if (isMultiplatformModule()) { | ||
| sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension | ||
|
|
||
| configure<KotlinProjectExtension> { | ||
| explicitApi() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import extensions.kotlinAndroid | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
|
||
| kotlinAndroid { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import extensions.kotlinMultiplatform | ||
| import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget | ||
|
|
||
| @OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
| kotlinMultiplatform { | ||
| applyDefaultHierarchyTemplate { | ||
| common { | ||
| group("commonJvm") { | ||
| withCompilations { | ||
| it.target.targetName == "desktop" || it.target is KotlinAndroidTarget | ||
| } | ||
| } | ||
| group("nonAndroid") { | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| withCompilations { | ||
| it.target.targetName == "desktop" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| androidTarget { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } | ||
| jvm("desktop") { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import extensions.kotlinMultiplatform | ||
| import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
| import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget | ||
|
|
||
| @OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
| kotlinMultiplatform { | ||
| applyDefaultHierarchyTemplate { | ||
| common { | ||
| group("commonJvm") { | ||
| withCompilations { | ||
| it.target.targetName == "desktop" || it.target is KotlinAndroidTarget | ||
| } | ||
| } | ||
| group("nonAndroid") { | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| withJs() | ||
| withNative() | ||
| withWasmJs() | ||
| withCompilations { | ||
| it.target.targetName == "desktop" | ||
| } | ||
| } | ||
| group("commonWeb") { | ||
| withJs() | ||
| withWasmJs() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| js(IR) { | ||
| browser() | ||
| } | ||
| @OptIn(ExperimentalWasmDsl::class) | ||
| wasmJs { | ||
| browser() | ||
| } | ||
|
|
||
| androidTarget { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } | ||
| jvm("desktop") { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } | ||
|
|
||
| macosX64() | ||
| macosArm64() | ||
|
|
||
| iosArm64() | ||
| iosX64() | ||
| iosSimulatorArm64() | ||
|
|
||
| compilerOptions { | ||
| freeCompilerArgs.add("-Xexpect-actual-classes") | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import org.jlleitschuh.gradle.ktlint.KtlintExtension | ||
|
|
||
| plugins.apply("org.jlleitschuh.gradle.ktlint") | ||
|
|
||
| configure<KtlintExtension> { | ||
| val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
|
||
| version = libs.findVersion("ktlint").get().toString() | ||
| disabledRules = setOf("filename") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension | ||
|
|
||
| configure<KotlinProjectExtension> { | ||
| sourceSets.all { | ||
| languageSettings { | ||
| optIn("cafe.adriel.voyager.core.annotation.InternalVoyagerApi") | ||
| optIn("cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi") | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
| import com.vanniktech.maven.publish.SonatypeHost | ||
| import extensions.isMultiplatformModule | ||
| import extensions.kotlinMultiplatform | ||
|
|
||
| pluginManager.apply("com.vanniktech.maven.publish") | ||
|
|
||
| if (isMultiplatformModule()) { | ||
| kotlinMultiplatform { | ||
| androidTarget { | ||
| publishLibraryVariants("release") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| group = "cafe.adriel.voyager" | ||
|
|
||
| configure<MavenPublishBaseExtension> { | ||
| publishToMavenCentral(host = SonatypeHost.S01, automaticRelease = true) | ||
| signAllPublications() | ||
|
|
||
| pom { | ||
| description = "A pragmatic navigation library for Jetpack Compose" | ||
| inceptionYear = "2021" | ||
| url = "https://github.com/adrielcafe/voyager" | ||
|
|
||
| licenses { | ||
| license { | ||
| name = "The MIT License" | ||
| url = "https://opensource.org/licenses/MIT" | ||
| distribution = "repo" | ||
| } | ||
| } | ||
|
|
||
| scm { | ||
| url = "https://github.com/adrielcafe/voyager" | ||
| connection = "scm:git:ssh://git@github.com/adrielcafe/voyager.git" | ||
| developerConnection = "scm:git:ssh://git@github.com/adrielcafe/voyager.git" | ||
| } | ||
|
|
||
| developers { | ||
| developer { | ||
| id = "adrielcafe" | ||
| name = "Adriel Cafe" | ||
| url = "https://github.com/adrielcafe/" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+21
to
+48
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this was required? why not keep it on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think explicit configuration is better than implicit |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package extensions | ||
|
|
||
| import org.gradle.api.Project | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidExtension | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
|
||
| fun Project.hasPlugin(id: String) = plugins.hasPlugin(id) | ||
|
|
||
| fun Project.isAndroidLibraryModule(): Boolean = hasPlugin("com.android.library") | ||
|
|
||
| fun Project.isAndroidApplicationModule(): Boolean = hasPlugin("com.android.application") | ||
|
|
||
| fun Project.isMultiplatformModule() = hasPlugin("org.jetbrains.kotlin.multiplatform") | ||
|
|
||
| fun Project.kotlinMultiplatform(block: KotlinMultiplatformExtension.() -> Unit) = | ||
| extensions.configure<KotlinMultiplatformExtension>(block) | ||
|
|
||
| fun Project.kotlinAndroid(block: KotlinAndroidExtension.() -> Unit) = | ||
| extensions.configure<KotlinAndroidExtension>(block) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package extensions | ||
|
|
||
| import java.util.Locale | ||
|
|
||
| fun String.capitalize(): String = replaceFirstChar { firstChar -> | ||
| if (firstChar.isLowerCase()) { | ||
| firstChar.titlecase(Locale.getDefault()) | ||
| } else { | ||
| toString() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
|
||
| plugins { | ||
| id("configure-android") | ||
| id("configure-opt-in") | ||
| id("configure-ktlint") | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompile> { | ||
| compilerOptions { | ||
| jvmTarget = JvmTarget.JVM_1_8 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| plugins { | ||
| id("voyager-base-module") | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id("configure-kotlin-android") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| plugins { | ||
| id("configure-android") | ||
| id("configure-opt-in") | ||
| id("configure-explicit-api") | ||
| id("configure-publishing") | ||
| id("configure-ktlint") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| plugins { | ||
| id("voyager-base-module") | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id("configure-kotlin-jvm") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| plugins { | ||
| id("voyager-base-module") | ||
DevSrSouza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id("configure-kotlin-multiplatform") | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.focusfiles are generated by dropbox plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the dropbox plugin, voyager project is a small project for using the plugin honestly.