Skip to content

Commit

Permalink
Migrate to maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Sep 18, 2022
1 parent 94262b7 commit 7cce3d6
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 39 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 19 additions & 10 deletions androidveil/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import com.skydoves.androidveil.Configuration
import com.skydoves.androidveil.Dependencies

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'binary-compatibility-validator'
apply from: "$rootDir/dependencies.gradle"

ext {
PUBLISH_GROUP_ID = Configuration.artifactGroup
PUBLISH_ARTIFACT_ID = 'androidveil'
PUBLISH_VERSION = rootVersionName
}

apply from: "${rootDir}/scripts/publish-module.gradle"

android {
compileSdkVersion versions.compileSdk
compileSdkVersion Configuration.compileSdk
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.compileSdk
versionCode versions.versionCode
versionName versions.versionName
minSdkVersion Configuration.minSdk
targetSdkVersion Configuration.compileSdk
versionCode Configuration.versionCode
versionName Configuration.versionName
}

resourcePrefix "veil"
Expand Down Expand Up @@ -44,9 +55,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}

dependencies {
implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat"
implementation "androidx.recyclerview:recyclerview:$versions.recyclerView"
api "com.facebook.shimmer:shimmer:$versions.shimmer"
implementation Dependencies.appcompat
implementation Dependencies.recyclerview
api Dependencies.shimmer
}

apply plugin: "com.vanniktech.maven.publish"
41 changes: 22 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import com.skydoves.androidveil.Configuration
import com.skydoves.androidveil.Dependencies

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$rootDir/dependencies.gradle"

android {
compileSdkVersion versions.compileSdk
defaultConfig {
applicationId "com.skydoves.androidveildemo"
minSdkVersion versions.minSdk
targetSdkVersion versions.compileSdk
versionCode versions.versionCode
versionName versions.versionName
}
lintOptions {
abortOnError false
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
compileSdkVersion Configuration.compileSdk
defaultConfig {
applicationId "com.skydoves.androidveildemo"
minSdkVersion Configuration.minSdk
targetSdkVersion Configuration.compileSdk
versionCode Configuration.versionCode
versionName Configuration.versionName
}
lintOptions {
abortOnError false
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation "com.google.android.material:material:$versions.googleMaterial"
implementation project(":androidveil")
implementation Dependencies.material
implementation project(":androidveil")
}

23 changes: 13 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import com.skydoves.androidveil.Dependencies

apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply plugin: 'org.jetbrains.dokka'

buildscript {
apply from: "$rootDir/dependencies.gradle"
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.android.tools.build:gradle:$versions.gradleBuildTool"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
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"
classpath Dependencies.androidGradlePlugin
classpath Dependencies.kotlinGradlePlugin
classpath Dependencies.spotlessGradlePlugin
classpath Dependencies.gradleNexusPublishPlugin
classpath Dependencies.dokka
classpath Dependencies.kotlinBinaryValidator
}
}

Expand All @@ -25,7 +31,4 @@ allprojects {
}
}

tasks.withType(Javadoc) {
excludes = ['**/*.kt']
options.addBooleanOption('Xdoclint:none', true)
}
apply from: "${rootDir}/scripts/publish-root.gradle"
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
30 changes: 30 additions & 0 deletions buildSrc/src/main/kotlin/com/skydoves/androidveil/Configuration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2018 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.androidveil

object Configuration {
const val compileSdk = 32
const val targetSdk = 32
const val minSdk = 16
const val majorVersion = 1
const val minorVersion = 1
const val patchVersion = 3
const val versionName = "$majorVersion.$minorVersion.$patchVersion"
const val versionCode = 14
const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT"
const val artifactGroup = "com.github.skydoves"
}
33 changes: 33 additions & 0 deletions buildSrc/src/main/kotlin/com/skydoves/androidveil/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.skydoves.androidveil

object Versions {
internal const val ANDROID_GRADLE_PLUGIN = "7.2.1"
internal const val ANDROID_GRADLE_SPOTLESS = "6.7.0"
internal const val GRADLE_NEXUS_PUBLISH_PLUGIN = "1.1.0"
internal const val KOTLIN = "1.7.10"
internal const val KOTLIN_GRADLE_DOKKA = "1.7.10"
internal const val KOTLIN_BINARY_VALIDATOR = "0.11.0"

internal const val APPCOMPAT = "1.5.0"
internal const val MATERIAL = "1.6.1"
internal const val RECYCLERVIEW = "1.2.1"
internal const val SHIMMER = "0.5.0"
}

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 recyclerview = "androidx.recyclerview:recyclerview:${Versions.RECYCLERVIEW}"
const val shimmer = "com.facebook.shimmer:shimmer:${Versions.SHIMMER}"
}
87 changes: 87 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -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 = 'An easy, flexible way to implement veil skeletons and shimmering effect for Android.'
url = 'https://github.com/skydoves/androidveil'
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 = "[email protected]"
url = "https://github.com/skydoves"
}
}
scm {
connection = 'scm:git:github.com/skydoves/androidveil.git'
developerConnection = 'scm:git:ssh://github.com/skydoves/androidveil.git'
url = 'https://github.com/skydoves/androidveil/tree/main'
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"],
)
sign publishing.publications
}
Loading

0 comments on commit 7cce3d6

Please sign in to comment.