Skip to content

Commit

Permalink
Merge pull request #35 from ericktijerou/feature/migrate-to-maven
Browse files Browse the repository at this point in the history
Migrate to Maven Central and Fix issues
  • Loading branch information
ericktijerou authored Aug 3, 2021
2 parents ca5f6b2 + 98bb4f1 commit 5091675
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 113 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
# assembleRelease for all modules, excluding non-library modules: samples, docs
run: ./gradlew assembleRelease -x :stream-chat-android-sample:assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
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 }}
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

> The easiest library to show skeleton screens in an Android app.
[![bintray](https://api.bintray.com/packages/ericktijerou/maven/koleton/images/download.svg)](https://bintray.com/ericktijerou/maven/koleton/_latestVersion)
[![Build Status](https://travis-ci.com/ericktijerou/koleton.svg?branch=master)](https://travis-ci.com/ericktijerou/koleton)
[![Kotlin](https://img.shields.io/badge/Kotlin-1.4.30-blueviolet.svg)](https://kotlinlang.org)
<a href="https://github.com/ericktijerou/koleton/actions"><img src="https://github.com/ericktijerou/koleton/workflows/Build%20and%20test/badge.svg" /></a>
<a href="https://github.com/ericktijerou/koleton/releases"><img src="https://img.shields.io/github/v/release/ericktijerou/koleton" /></a>
[![Kotlin](https://img.shields.io/badge/Kotlin-1.5.10-blueviolet.svg)](https://kotlinlang.org)
<a href="https://github.com/GetStream/stream-chat-android/actions"><img src="https://github.com/GetStream/stream-chat-android/workflows/Build%20and%20test/badge.svg" /></a>
<a href="https://github.com/GetStream/stream-chat-android/releases"><img src="https://img.shields.io/github/v/release/GetStream/stream-chat-android" /></a>
![Minimum SDK Version](https://img.shields.io/badge/minSdkVersion-14-brightgreen.svg)

An Android library that provides an easy way to show skeleton of any view.
Expand All @@ -18,19 +20,19 @@ Made with ❤ by [ericktijerou](https://ericktijerou.com).
![img](image/journey_detail.gif)

## Installation
You can [download](https://bintray.com/ericktijerou/maven/koleton/_latestVersion) and install `Koleton` with `Maven` and `Gradle`:
You can [download](https://bintray.com/ericktijerou/maven/koleton/_latestVersion) and install `Koleton` with `Maven Central` and `Gradle`:

```gradle
// In your module's `build.gradle.kts`
dependencies {
implementation("com.ericktijerou.koleton:koleton:0.8.8")
implementation("com.ericktijerou.koleton:koleton:1.0.0-beta01")
}
```

Make sure to include `jcenter()` in your repositories
Make sure to include `mavenCentral()` in your repositories
```gradle
repositories {
jcenter()
mavenCentral()
}
```

Expand Down Expand Up @@ -176,4 +178,4 @@ You can find more information about Facebook's shimmer effect on the [shimmer-an
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.
limitations under the License.
109 changes: 12 additions & 97 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ plugins {
java
kotlin("jvm")
`maven-publish`
id(Release.Bintray.plugin) version Release.Bintray.version
id(Release.Nexus.plugin) version Release.Nexus.version
id("org.jetbrains.dokka") version "1.5.0" apply false
}


buildscript {
apply(from = "buildSrc/extra.gradle.kts")
repositories {
google()
mavenCentral()
gradlePluginPortal()
jcenter()
}
dependencies {
classpath(rootProject.extra["androidPlugin"].toString())
Expand All @@ -28,10 +29,11 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}

apply(from ="${rootDir}/scripts/publish-root.gradle")

val androidModules = listOf("koleton-singleton", "koleton-base")
val androidSampleModules = listOf("koleton-sample")

Expand Down Expand Up @@ -109,18 +111,6 @@ subprojects {
testOptions {
unitTests.isReturnDefaultValues = true
}

val sourcesJar by tasks.registering(Jar::class) {
from(sourceSets["main"].java.srcDirs)
archiveClassifier.set("sources")
}

val doc by tasks.creating(Javadoc::class) {
isFailOnError = false
source = sourceSets["main"].java.getSourceFiles()
classpath += files(bootClasspath.joinToString(File.pathSeparator))
classpath.plus(configurations["compile"])
}
}

if (!isSample) {
Expand All @@ -130,7 +120,7 @@ subprojects {

apply {
plugin(Release.MavenPublish.plugin)
plugin(Release.Bintray.plugin)
plugin("org.jetbrains.dokka")
}

tasks.withType<KotlinCompile> {
Expand All @@ -144,89 +134,14 @@ subprojects {
implementation(Kotlin.stdlib)
}

bintray {
user = findProperty("bintrayUser") as? String
key = findProperty("bintrayKey") as? String
publish = !project.publishVersion.endsWith("SNAPSHOT")
setPublications(artifactName)
with(pkg) {
repo = Koleton.repository
name = artifactName
desc = Koleton.description
githubRepo = project.vcsUrl
userOrg = Developer.id
websiteUrl = project.vcsUrl
vcsUrl = project.vcsUrl
issueTrackerUrl = project.issueTrackerUrl
setLicenses(Koleton.licenseName)
with(version) {
name = project.publishVersion
vcsTag = "v${project.publishVersion}"
}
}
ext {
set("PUBLISH_GROUP_ID", project.groupId)
set("PUBLISH_VERSION", project.publishVersion)
set("PUBLISH_ARTIFACT_ID", artifactName)
}

fun org.gradle.api.publish.maven.MavenPom.addDependencies() = withXml {
asNode().appendNode("dependencies").let { depNode ->
configurations.implementation.get().allDependencies.forEach {
depNode.appendNode("dependency").apply {
appendNode("groupId", it.group)
appendNode("artifactId", it.name)
appendNode("version", it.version)
}
}
}
}

val javadocJar by tasks.creating(Jar::class) {
val doc by tasks
dependsOn(doc)
from(doc)
archiveClassifier.set("javadoc")
}
apply(from = "${rootProject.projectDir}/scripts/publish-module.gradle")

val sourcesJar by tasks
publishing {
publications {
register(artifactName, MavenPublication::class) {
if (project.hasProperty("android")) {
artifact("$buildDir/outputs/aar/${project.name}-release.aar") {
builtBy(tasks.getByPath("assemble"))
}
} else {
from(components["java"])
}
groupId = project.groupId
artifactId = artifactName
version = project.publishVersion
artifact(sourcesJar)
artifact(javadocJar)
pom {
name.set(artifactName)
description.set(Koleton.description)
url.set(project.vcsUrl)
scm { url.set(project.vcsUrl) }
issueManagement { url.set(project.issueTrackerUrl) }
licenses {
license {
name.set(Koleton.licenseName)
url.set(Koleton.licenseUrl)
}
}
developers {
developer {
id.set(Developer.id)
name.set(Developer.name)
}
}
}
if (project.hasProperty("android")) {
pom.addDependencies()
}
}
}
}
}
}
}

}
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
repositories {
google()
mavenCentral()
jcenter()
}

apply(from = "extra.gradle.kts")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/extra.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.extra.apply {
set("androidPlugin", "com.android.tools.build:gradle:4.1.1")
set("kotlinPlugin", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
set("kotlinPlugin", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
}
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object Versions {
}

object Kotlin {
const val version = "1.4.30"
const val version = "1.5.10"
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version"
const val plugin = "kotlin"
const val androidPlugin = "kotlin-android"
Expand All @@ -50,15 +50,15 @@ object Release {
const val plugin = "maven-publish"
}

object Bintray {
const val version = "1.8.5"
const val plugin = "com.jfrog.bintray"
object Nexus {
const val version = "1.1.0"
const val plugin = "io.github.gradle-nexus.publish-plugin"
}
}

object Developer {
const val id = "ericktijerou"
const val name = "Erick Tijero"
const val fullName = "Erick Tijero"
}

object Koleton {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ compileSdk=30
groupId=com.ericktijerou.koleton
vcsUrl=https://github.com/ericktijerou/koleton
issueTrackerUrl=https://github.com/ericktijerou/koleton/issues
publishVersion=0.8.8
publishVersion=1.0.0-beta01
85 changes: 85 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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 = Koleton.description
url = project.vcsUrl
licenses {
license {
name = Koleton.licenseName
url = Koleton.licenseUrl
}
}
developers {
developer {
id = Developer.id
name = Developer.fullName
}
}
scm {
connection = 'scm:git:github.com/ericktijerou/koleton.git'
developerConnection = 'scm:git:ssh://github.com/ericktijerou/koleton.git'
url = 'https://github.com/ericktijerou/koleton/tree/main'
}
}
}
}
}
}

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

0 comments on commit 5091675

Please sign in to comment.