diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..376f7bb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true +[*] +# Most of the standard properties are supported +indent_size=2 +max_line_length=100 \ No newline at end of file diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 943bac5..b237bb4 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] pull_request: - branches: [ '*' ] + branches: [ main ] jobs: lint: @@ -36,24 +36,25 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 + - name: set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 - - name: Cache Gradle and wrapper - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Make Gradle executable - run: chmod +x ./gradlew - - - name: Build with Gradle - run: ./gradlew build \ No newline at end of file + - name: Cache Gradle and wrapper + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Make Gradle executable + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew build diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..75d6b46 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,34 @@ +name: Publish Snapshot builds + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + publish: + name: Snapshot build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + - name: Release build + run: ./gradlew assemble --scan + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar --scan + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --scan + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SNAPSHOT: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..96f97a1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish + +on: + release: + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + - name: Release build + run: ./gradlew assemble --scan + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar --scan + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository --scan + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} diff --git a/.gitignore b/.gitignore index 79dcce7..890800c 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,9 @@ captures/ .idea/dictionaries .idea/libraries +# Mac +*.DS_Store + # Keystore files *.jks diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1c1cab1 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +skydoves2@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/app/build.gradle b/app/build.gradle index 30bbd72..e4d7549 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,52 +13,51 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ + +import com.skydoves.bindables.Configuration +import com.skydoves.bindables.Dependencies + plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-kapt' - id 'kotlin-parcelize' - id 'dagger.hilt.android.plugin' + id "com.android.application" + id "org.jetbrains.kotlin.android" + id "kotlin-kapt" + id "kotlin-parcelize" + id "dagger.hilt.android.plugin" } android { - compileSdkVersion versions.compileSdk - defaultConfig { - applicationId "com.skydoves.bindablesdemo" - minSdkVersion versions.minSdkDemo - targetSdkVersion versions.compileSdk - versionCode versions.versionCode - versionName versions.versionName - } - lintOptions { - abortOnError false - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - dataBinding true - } -} + compileSdkVersion Configuration.compileSdk + defaultConfig { + applicationId "com.skydoves.bindablesdemo" + minSdkVersion Configuration.minSdk + targetSdkVersion Configuration.targetSdk + versionCode Configuration.versionCode + versionName Configuration.versionName + } -dependencies { - implementation "com.google.android.material:material:$versions.googleMaterial" - implementation "androidx.fragment:fragment-ktx:$versions.fragmentVersion" + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } - implementation "com.github.bumptech.glide:glide:$versions.glideVersion" - kapt "com.github.bumptech.glide:compiler:$versions.glideVersion" + kotlinOptions { + jvmTarget = '1.8' + } - implementation "com.google.dagger:hilt-android:$versions.hiltCoreVersion" - kapt "com.google.dagger:hilt-compiler:$versions.hiltCoreVersion" - kapt "androidx.hilt:hilt-compiler:$versions.hiltVersion" + buildFeatures { + dataBinding true + } +} - implementation "com.github.skydoves:whatif:$versions.whatIfVersion" +dependencies { + implementation project(":bindables") - implementation project(":bindables") + implementation Dependencies.material + implementation Dependencies.fragment + implementation Dependencies.glide + implementation Dependencies.hilt + kapt Dependencies.hiltCompiler + implementation Dependencies.whatIf } -apply from: "$rootDir/spotless.gradle" \ No newline at end of file +apply from: "$rootDir/spotless/spotless.gradle" \ No newline at end of file diff --git a/bindables/build.gradle b/bindables/build.gradle index 0415cf8..4644b46 100644 --- a/bindables/build.gradle +++ b/bindables/build.gradle @@ -13,58 +13,67 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ + +import com.skydoves.bindables.Configuration +import com.skydoves.bindables.Dependencies + plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-kapt' - id 'org.jetbrains.dokka' - id 'binary-compatibility-validator' + id 'com.android.library' + id 'kotlin-android' + id 'kotlin-kapt' + id 'org.jetbrains.dokka' + id 'binary-compatibility-validator' +} + +ext { + PUBLISH_GROUP_ID = Configuration.artifactGroup + PUBLISH_ARTIFACT_ID = 'bindables' + PUBLISH_VERSION = rootVersionName } -apply from: "$rootDir/dependencies.gradle" +apply from: "${rootDir}/scripts/publish-module.gradle" android { - compileSdkVersion versions.compileSdk - defaultConfig { - minSdkVersion versions.minSdk - targetSdkVersion versions.compileSdk - versionCode versions.versionCode - versionName versions.versionName - consumerProguardFiles "consumer-rules.pro" - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - buildConfig false - dataBinding true - } + compileSdkVersion Configuration.compileSdk + defaultConfig { + minSdkVersion Configuration.minSdk + targetSdkVersion Configuration.targetSdk + versionCode Configuration.versionCode + versionName Configuration.versionName + consumerProguardFiles "consumer-rules.pro" + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + buildConfig false + dataBinding true + } } apiValidation { - ignoredPackages += [ - "com/skydoves/bindables/databinding", - ] - nonPublicMarkers += [ - "kotlin.PublishedApi", - ] + ignoredPackages += [ + "com/skydoves/bindables/databinding", + ] + nonPublicMarkers += [ + "kotlin.PublishedApi", + ] } tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions.freeCompilerArgs += ["-Xexplicit-api=strict"] + kotlinOptions.freeCompilerArgs += ["-Xexplicit-api=strict"] } dependencies { - implementation "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin" - implementation "com.google.android.material:material:$versions.googleMaterial" - implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat" - api "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.lifecycleVersion" - api "androidx.lifecycle:lifecycle-viewmodel-savedstate:$versions.lifecycleVersion" + implementation Dependencies.kotlinReflect + implementation Dependencies.material + implementation Dependencies.appcompat + api Dependencies.viewModelKtx + api Dependencies.viewModelSavedState } -apply plugin: "com.vanniktech.maven.publish" -apply from: "$rootDir/spotless.gradle" \ No newline at end of file +apply from: "$rootDir/spotless/spotless.gradle" \ No newline at end of file diff --git a/build.gradle b/build.gradle index ef4f6a7..1e41163 100644 --- a/build.gradle +++ b/build.gradle @@ -13,32 +13,31 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ + +import com.skydoves.bindables.Dependencies + +apply plugin: "io.github.gradle-nexus.publish-plugin" +apply plugin: "org.jetbrains.dokka" + buildscript { - apply from: "$rootDir/dependencies.gradle" - repositories { - google() - mavenCentral() - jcenter() - } - dependencies { - classpath "com.android.tools.build:gradle:$versions.gradleBuildTool" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin" - classpath "com.google.dagger:hilt-android-gradle-plugin:$versions.hiltCoreVersion" - classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessGradle" - classpath "com.vanniktech:gradle-maven-publish-plugin:$versions.mavenPublish" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokkaGradle" - classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$versions.binaryValidator" - } + repositories { + google() + mavenCentral() + maven { url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath Dependencies.androidGradlePlugin + classpath Dependencies.kotlinGradlePlugin + classpath Dependencies.spotlessGradlePlugin + classpath Dependencies.gradleNexusPublishPlugin + classpath Dependencies.dokka + classpath Dependencies.hiltPlugin + classpath Dependencies.kotlinBinaryValidator + } } -allprojects { - repositories { - google() - mavenCentral() - jcenter() - } +task clean(type: Delete) { + delete rootProject.buildDir } -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file +apply from: "${rootDir}/scripts/publish-root.gradle" \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..b22ed73 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt b/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt new file mode 100644 index 0000000..cc51d40 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2021 skydoves + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.skydoves.bindables + +object Configuration { + const val compileSdk = 32 + const val targetSdk = 32 + const val minSdk = 21 + const val majorVersion = 1 + const val minorVersion = 1 + const val patchVersion = 0 + const val versionName = "$majorVersion.$minorVersion.$patchVersion" + const val versionCode = 11 + const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT" + const val artifactGroup = "com.github.skydoves" +} diff --git a/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt b/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt new file mode 100644 index 0000000..b07bbfc --- /dev/null +++ b/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt @@ -0,0 +1,46 @@ +package com.skydoves.bindables + +object Versions { + internal const val ANDROID_GRADLE_PLUGIN = "7.2.1" + internal const val ANDROID_GRADLE_SPOTLESS = "6.3.0" + internal const val GRADLE_NEXUS_PUBLISH_PLUGIN = "1.1.0" + internal const val KOTLIN = "1.7.0" + internal const val KOTLIN_GRADLE_DOKKA = "1.6.21" + internal const val KOTLIN_BINARY_VALIDATOR = "0.10.1" + + internal const val APPCOMPAT = "1.4.1" + internal const val MATERIAL = "1.6.0" + internal const val LIFECYCLE = "2.4.1" + + internal const val FRAGMENT = "1.2.5" + internal const val HILT = "2.42" + internal const val GLIDE = "4.13.0" + internal const val WHATIF = "1.1.1" +} + +object Dependencies { + const val androidGradlePlugin = + "com.android.tools.build:gradle:${Versions.ANDROID_GRADLE_PLUGIN}" + const val gradleNexusPublishPlugin = + "io.github.gradle-nexus:publish-plugin:${Versions.GRADLE_NEXUS_PUBLISH_PLUGIN}" + const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN}" + const val spotlessGradlePlugin = + "com.diffplug.spotless:spotless-plugin-gradle:${Versions.ANDROID_GRADLE_SPOTLESS}" + const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.KOTLIN_GRADLE_DOKKA}" + const val kotlinBinaryValidator = + "org.jetbrains.kotlinx:binary-compatibility-validator:${Versions.KOTLIN_BINARY_VALIDATOR}" + + const val appcompat = "androidx.appcompat:appcompat:${Versions.APPCOMPAT}" + const val material = "com.google.android.material:material:${Versions.MATERIAL}" + const val lifecycle = "androidx.lifecycle:lifecycle-common-java8:${Versions.LIFECYCLE}" + const val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.KOTLIN}" + const val viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LIFECYCLE}" + const val viewModelSavedState = "androidx.lifecycle:lifecycle-viewmodel-savedstate:${Versions.LIFECYCLE}" + + const val fragment = "androidx.fragment:fragment-ktx:${Versions.FRAGMENT}" + const val hilt = "com.google.dagger:hilt-android:${Versions.HILT}" + const val hiltCompiler = "com.google.dagger:hilt-compiler:${Versions.HILT}" + const val hiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:${Versions.HILT}" + const val glide = "com.github.bumptech.glide:glide:${Versions.GLIDE}" + const val whatIf = "com.github.skydoves:whatif:${Versions.WHATIF}" +} diff --git a/dependencies.gradle b/dependencies.gradle deleted file mode 100644 index e76f2c2..0000000 --- a/dependencies.gradle +++ /dev/null @@ -1,40 +0,0 @@ -// Designed and developed by 2021 skydoves (Jaewoong Eum) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -ext.versions = [ - minSdk : 16, - minSdkDemo : 21, - compileSdk : 31, - versionCode : 10, - versionName : '1.0.9', - - gradleBuildTool : '7.0.2', - spotlessGradle : '6.1.0', - ktlintGradle : '0.41.0', - dokkaGradle : '1.4.32', - binaryValidator : '0.7.1', - mavenPublish : '0.15.1', - - kotlin : '1.5.32', - androidxAppcompat: '1.4.0', - googleMaterial : '1.4.0', - lifecycleVersion : '2.4.0', - - // for demo - fragmentVersion : '1.2.5', - hiltCoreVersion : '2.40.5', - hiltVersion : '1.0.0', - glideVersion : '4.12.0', - whatIfVersion : '1.1.0', -] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2b24020..6fb5ae0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -16,4 +16,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle new file mode 100644 index 0000000..ea8ce59 --- /dev/null +++ b/scripts/publish-module.gradle @@ -0,0 +1,87 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: 'org.jetbrains.dokka' + +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + if (project.plugins.findPlugin("com.android.library")) { + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs + } else { + from sourceSets.main.java.srcDirs + from sourceSets.main.kotlin.srcDirs + } +} + +tasks.withType(dokkaHtmlPartial.getClass()).configureEach { + pluginsMapConfiguration.set( + ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] + ) +} + +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + archiveClassifier.set('javadoc') + from dokkaJavadoc.outputDirectory +} + +artifacts { + archives androidSourcesJar + archives javadocJar +} + +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } else { + from components.java + } + + artifact androidSourcesJar + artifact javadocJar + + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Android DataBinding kit for notifying data changes to UI layers.' + url = 'https://github.com/skydoves/bindables' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'skydoves' + name = 'Jaewoong Eum' + email = "skydoves2@gmail.com" + url = "https://github.com/skydoves" + } + } + scm { + connection = 'scm:git:github.com/skydoves/bindables.git' + developerConnection = 'scm:git:ssh://github.com/skydoves/bindables.git' + url = 'https://github.com/skydoves/bindables/tree/main' + } + } + } + } + } +} + +signing { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..84ef429 --- /dev/null +++ b/scripts/publish-root.gradle @@ -0,0 +1,45 @@ +import com.skydoves.bindables.Configuration + +// Create variables with empty default values +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' +ext["snapshot"] = '' + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.key"] = System.getenv('SIGNING_KEY') + ext["snapshot"] = System.getenv('SNAPSHOT') +} + +if (snapshot) { + ext["rootVersionName"] = Configuration.snapshotVersionName +} else { + ext["rootVersionName"] = Configuration.versionName +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + version = rootVersionName + } + } +} diff --git a/settings.gradle b/settings.gradle index 38b0114..50d83d3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,6 +13,22 @@ // * See the License for the specific language governing permissions and // * limitations under the License. // */ + +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + include ':bindables' include ':app' rootProject.name = "BindablesDemo" \ No newline at end of file diff --git a/spotless/.DS_Store b/spotless/.DS_Store new file mode 100644 index 0000000..6966dc1 Binary files /dev/null and b/spotless/.DS_Store differ diff --git a/spotless.gradle b/spotless/spotless.gradle similarity index 79% rename from spotless.gradle rename to spotless/spotless.gradle index 4a2ff38..db2d1dd 100644 --- a/spotless.gradle +++ b/spotless/spotless.gradle @@ -13,13 +13,14 @@ // limitations under the License. apply plugin: "com.diffplug.spotless" -apply from: '../dependencies.gradle' + spotless { kotlin { target "**/*.kt" - ktlint("$versions.ktlintGradle").userData(['indent_size': '2', 'continuation_indent_size': '2']) - licenseHeaderFile "$rootDir/spotless.license.kt" + targetExclude "**/build/**/*.kt" + ktlint().userData(['indent_size': '2', 'continuation_indent_size': '2']) + licenseHeaderFile "$rootDir/spotless/spotless.license.kt" trimTrailingWhitespace() endWithNewline() } -} +} \ No newline at end of file diff --git a/spotless.license.kt b/spotless/spotless.license.kt similarity index 100% rename from spotless.license.kt rename to spotless/spotless.license.kt