Skip to content

Commit

Permalink
#29 use convention-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
anton6tak committed Jun 30, 2021
1 parent 33f6b5c commit 490a539
Show file tree
Hide file tree
Showing 18 changed files with 313 additions and 203 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/compilation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Check build
run: ./gradlew build publishToMavenLocal
run: ./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
- name: Install pods
run: cd sample/ios-app && pod install
if: matrix.os == 'macOS-latest'
- name: Check iOS
run: cd sample/ios-app && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
run: cd sample/ios-app && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty
if: matrix.os == 'macOS-latest'
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Publish
run: ./gradlew publish -DIS_MAIN_HOST=${{ matrix.os == 'ubuntu-latest' }}
release:
Expand All @@ -42,6 +42,6 @@ jobs:
with:
commitish: ${{ github.ref }}
tag_name: release/${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
release_name: ${{ github.event.inputs.version }}
body: "Will be filled later"
draft: true
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:parcelize:0.7.0")
commonMainApi("dev.icerock.moko:parcelize:0.7.1")
}
```

Expand All @@ -63,6 +63,7 @@ Please see more examples in the [sample directory](sample).
## Set Up Locally
- The [parcelize directory](parcelize) contains the `parcelize` library;
- The [sample directory](sample) contains sample apps for Android and iOS; plus the mpp-library connected to the apps.
- For publish to MavenLocal repository run `./gradlew publishToMavenLocal -DIS_MAIN_HOST=true`

## Contributing
All development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`.
Expand Down
22 changes: 5 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@ buildscript {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
dependencies {
classpath("dev.icerock:mobile-multiplatform:0.9.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
classpath("com.android.tools.build:gradle:4.2.1")
classpath(":parcelize-build-logic")
}
}

allprojects {
repositories {
mavenCentral()
google()
}

plugins.withId("com.android.library") {
configure<com.android.build.gradle.LibraryExtension> {
compileSdkVersion(libs.versions.compileSdk.get().toInt())

defaultConfig {
minSdkVersion(libs.versions.minSdk.get().toInt())
targetSdkVersion(libs.versions.targetSdk.get().toInt())
}
}
plugins.withId("org.gradle.maven-publish") {
group = "dev.icerock.moko"
version = libs.versions.mokoParcelizeVersion.get()
}
}
10 changes: 3 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[versions]
androidAppCompatVersion = "1.1.0"
mokoParcelizeVersion = "0.7.0"
compileSdk = "28"
targetSdk = "28"
minSdk = "16"
androidAppCompatVersion = "1.2.0"
mokoParcelizeVersion = "0.7.1"

[libraries]
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
mokoParcelize = { module = "dev.icerock.moko:parcelize", version.ref = "mokoParcelizeVersion" }
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
17 changes: 17 additions & 0 deletions parcelize-build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
google()

gradlePluginPortal()
}

dependencies {
api("dev.icerock:mobile-multiplatform:0.12.0")
api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
api("com.android.tools.build:gradle:4.2.1")
api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("com.android.application")
id("android-base-convention")
id("kotlin-android")
}

android {
dexOptions {
javaMaxHeapSize = "2g"
}

buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
getByName("debug") {
isDebuggable = true
applicationIdSuffix = ".debug"
}
}

packagingOptions {
exclude("META-INF/*.kotlin_module")
exclude("META-INF/AL2.0")
exclude("META-INF/LGPL2.1")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import com.android.build.gradle.BaseExtension

configure<BaseExtension> {
compileSdkVersion(30)

defaultConfig {
minSdkVersion(16)
targetSdkVersion(30)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("com.android.library")
id("kotlin-android")
id("android-base-convention")
}

android {
sourceSets.all { java.srcDir("src/$name/kotlin") }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("publication-convention")
}

afterEvaluate {
publishing.publications {
create("release", MavenPublication::class.java) {
from(components.getByName("release"))
}
}
}
15 changes: 15 additions & 0 deletions parcelize-build-logic/src/main/kotlin/detekt-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("io.gitlab.arturbosch.detekt")
}

detekt {
input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", "src/main/kotlin")
}

dependencies {
"detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("org.gradle.maven-publish")
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

publishing.publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
id("android-base-convention")
id("dev.icerock.mobile.multiplatform.android-manifest")
}

kotlin {
macosX64("macOS")
tvos()
watchos()
jvm()
js(BOTH) {
nodejs()
browser()
}
linux()
windows()
wasm32()

sourceSets {
all {
languageSettings.apply {
useExperimentalAnnotation("kotlin.RequiresOptIn")
}
}

val commonMain by getting

val notAndroidMain by creating {
dependsOn(commonMain)
}

val intermediateSourceSets = listOf(commonMain, notAndroidMain)
matching { sourceSet ->
!sourceSet.name.startsWith("android") && sourceSet !in intermediateSourceSets
}.all {
dependsOn(notAndroidMain)
}
}
}

fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.linux() {
linuxArm64()
linuxArm32Hfp()
linuxMips32()
linuxMipsel32()
linuxX64()
}

fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.windows() {
mingwX64()
mingwX86()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import java.util.Base64

plugins {
id("javadoc-stub-convention")
id("org.gradle.maven-publish")
id("signing")
}

publishing {
repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
name = "OSSRH"

credentials {
username = System.getenv("OSSRH_USER")
password = System.getenv("OSSRH_KEY")
}
}

// Make sure to avoid duplicate publications
val publicationsFromMainHost = listOf(
"wasm32",
"jvm",
"js",
"kotlinMultiplatform",
"androidRelease",
"androidDebug",
"linuxArm64",
"linuxArm32Hfp",
"linuxX64"
)

publications
.matching { it.name in publicationsFromMainHost }
.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.all { onlyIf { System.getProperty("IS_MAIN_HOST") == "true" } }
}

publications.withType<MavenPublication> {

// Provide artifacts information requited by Maven Central
pom {
name.set("MOKO parcelize")
description.set("@Parcelize support for android from common code in Kotlin Multiplatform")
url.set("https://github.com/icerockdev/moko-parcelize")
licenses {
license {
name.set("Apache-2.0")
distribution.set("repo")
url.set("https://github.com/icerockdev/moko-parcelize/blob/master/LICENSE.md")
}
}

developers {
developer {
id.set("Alex009")
name.set("Aleksey Mikhailov")
email.set("[email protected]")
}
developer {
id.set("nrobi144")
name.set("Nagy Robert")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:ssh://github.com/icerockdev/moko-parcelize.git")
developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-parcelize.git")
url.set("https://github.com/icerockdev/moko-parcelize")
}
}
}

signing {
val signingKeyId: String? = System.getenv("SIGNING_KEY_ID")
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")
val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key ->
String(Base64.getDecoder().decode(base64Key))
}
if (signingKeyId != null) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}
}
}
Loading

0 comments on commit 490a539

Please sign in to comment.