Skip to content

Commit

Permalink
Compose Multiplatform (#89)
Browse files Browse the repository at this point in the history
Huge credits to Maicol Battistini <maicolbattistini@live.it>
  • Loading branch information
DatL4g authored Oct 9, 2024
1 parent f46de6c commit 2af41f3
Show file tree
Hide file tree
Showing 1,193 changed files with 10,185 additions and 7,061 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: false
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
if: false
steps:
- name: Checkout add-docs
uses: actions/checkout@v2
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish Release

on:
workflow_dispatch:

jobs:
publish:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Publish release
run: ./gradlew publishAllPublicationsToMavenCentralRepository -x lint -x lintVitalRelease
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bin/
gen/
out/
release/
.kotlin/

# Gradle files
.gradle/
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ In your app `build.gradle` file:
```gradle
dependencies {
...
// Implementing the `core` module is mandatory for using other use cases.
implementation 'com.maxkeppeler.sheets-compose-dialogs:core:<version>'
implementation 'com.maxkeppeler.sheets-compose-dialogs:<module>:<version>'
}
```
Expand Down
72 changes: 28 additions & 44 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@
* limitations under the License.
*/
plugins {
id(Plugins.APPLICATION.id)
id(Plugins.KOTLIN.id)
alias(libs.plugins.android.application)
alias(libs.plugins.multiplatform)
}

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "${JavaVersion.VERSION_11}"
freeCompilerArgs += "-Xjdk-release=${JavaVersion.VERSION_11}"
}
}
}
}

android {
Expand Down Expand Up @@ -46,14 +57,11 @@ android {
// Flag to enable support for the new language APIs
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
packagingOptions {
resources {
Expand All @@ -67,7 +75,7 @@ dependencies {
// Modules

Modules.values().forEach { module ->
apis(project(module.path))
api(project(module.path))
}

// Dependencies of sheets-compose-dialogs
Expand All @@ -88,49 +96,25 @@ dependencies {
// implementation("com.maxkeppeler.sheets-compose-dialogs:emoji:$sheetsVersion")


coreLibraryDesugaring(Dependencies.DESUGAR)

// Kotlin libs

implementations(Dependencies.Kotlin.KOTLIN_STD)
coreLibraryDesugaring(libs.desugar)


// AndroidX libs

implementations(
Dependencies.AndroidX.CORE_KTX,
Dependencies.AndroidX.LIFECYCLE_KTX,
Dependencies.AndroidX.ACTIVITY_COMPOSE,
Dependencies.AndroidX.NAVIGATION_COMPOSE,
)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.navigation.compose)


// Compose libs

implementations(
platform(Dependencies.Compose.BOM),
Dependencies.Compose.UI,
Dependencies.Compose.UI_TOOLING,
Dependencies.Compose.ANIMATION,
Dependencies.Compose.RUNTIME,
Dependencies.Compose.MATERIAL_2,
Dependencies.Compose.MATERIAL_3,
Dependencies.Compose.ICONS_EXTENDED,
)

// Test libs

androidTestImplementations(
Dependencies.AndroidX.Test.TEST_CORE,
Dependencies.AndroidX.Test.TEST_RUNNER,
Dependencies.AndroidX.Test.JUNIT,
Dependencies.AndroidX.Test.ESPRESSO_CORE,
Dependencies.Compose.Test.JUNIT,
project(":test")
)
debugImplementations(
Dependencies.Compose.Test.TOOLING,
Dependencies.Compose.Test.MANIFEST
)
testImplementation(Dependencies.Test.JUNIT)
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.runner)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(project(":test"))
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
testImplementation(libs.junit)
}
123 changes: 18 additions & 105 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,128 +13,41 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.android.build.gradle.LibraryExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id(Plugins.SPOTLESS.id) version (Plugins.SPOTLESS.version)
id(Plugins.DOKKA.id) version (Plugins.DOKKA.version)
alias(libs.plugins.android) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.multiplatform) apply false
alias(libs.plugins.publish) apply false
}

buildscript {

repositories {
google()
mavenCentral()
maven("https://plugins.gradle.org/m2/")
}

dependencies {
classpath(Dependencies.Kotlin.GRADLE_PLUGIN)
classpath(Dependencies.Gradle.BUILD)
classpath(Dependencies.MAVEN_PUBLISH)
classpath(Dependencies.DOKKA)
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}
}

allprojects {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}
}

tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(projectDir.resolve("docs/api"))
}

subprojects {
plugins.apply(Plugins.SPOTLESS.id)
project.plugins.applyBaseConfig(project)
spotless {
kotlin {
target("**/*.kt")
// ktlint(Versions.KT_LINT)
}
kotlin {
target("**/*.kt")
targetExclude("**/core/icons/**/*.*")
licenseHeaderFile(rootProject.file("copyright.kt"))
}
kotlinGradle {
target("*.gradle.kts", "gradle/*.gradle.kts", "buildSrc/*.gradle.kts")
licenseHeaderFile(
rootProject.file("copyright.kt"),
"import|tasks|apply|plugins|rootProject"
)
}
}
}


/**
* Apply base configurations to the subjects that include specific custom plugins.
*/
fun PluginContainer.applyBaseConfig(project: Project) {
whenPluginAdded {
when (this) {
is LibraryModulePlugin -> {
project.extensions
.getByType<LibraryExtension>()
.apply {
baseLibraryConfig()
}
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
}

/**
* Apply base library configurations to the subprojects that include the plugin [LibraryModulePlugin].
*/
fun com.android.build.gradle.BaseExtension.baseLibraryConfig() {

compileSdkVersion(App.COMPILE_SDK)

defaultConfig {
minSdk = App.MIN_SDK
targetSdk = App.TARGET_SDK
testInstrumentationRunner = App.TEST_INSTRUMENTATION_RUNNER

javaCompileOptions {
annotationProcessorOptions {
arguments += mapOf("module" to "${App.ID}-$name")
}
}
}

compileOptions.apply {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}

buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER

packagingOptions.resources.excludes += listOf(
"META-INF/DEPENDENCIES.txt",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/AL2.0",
"META-INF/LGPL2.1"
)

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=androidx.compose.material.ExperimentalMaterial3Api",
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
"-Xopt-in=androidx.compose.ui.test.ExperimentalTestApi",
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
"-Xopt-in=androidx.compose.ui.ExperimentalComposeUiApi",
)
}
}
}
66 changes: 0 additions & 66 deletions buildSrc/src/main/java/Dependencies.kt

This file was deleted.

Loading

0 comments on commit 2af41f3

Please sign in to comment.