Skip to content

Commit

Permalink
Migrate to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed May 14, 2021
1 parent 533aa2c commit b6ca84c
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 142 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@ jobs:
uses: actions/checkout@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Prepare publishing environment
run: mkdir ~/.gradle && echo "$ARTIFACTORY_CREDENTIALS" > ./adobecolor/gradle.properties
env:
ARTIFACTORY_CREDENTIALS: ${{ secrets.ARTIFACTORY_CREDENTIALS }}
- name: Android Build
run: ./gradlew assembleDebug
65 changes: 33 additions & 32 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# Workflow for Android CI release

name: Publish to Artifactory
name: Publish to Sonatype

on:
release:
types: [ published ]
push:
tags:
- '*'

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest

steps:
- name: Get version name
id: get_version
uses: battila7/get-version-action@v2
- name: Checkout code
- name: Check out code
uses: actions/checkout@v2
with:
persist-credentials: false # Avoids messing up PagesDeployAction
- name: Configure JDK
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Make gradlew executable
run: chmod +x gradlew
- name: Prepare publishing environment
run: mkdir ~/.gradle && echo "$ARTIFACTORY_CREDENTIALS" > ./adobecolor/gradle.properties
env:
ARTIFACTORY_CREDENTIALS: ${{ secrets.ARTIFACTORY_CREDENTIALS }}
- name: Publish Dev
if: ${{ contains(steps.get_version.outputs.version, 'alpha') }}
run: ./gradlew adobecolor:assemble dokkaHtml
- name: Publish
if: ${{ !contains(steps.get_version.outputs.version, 'alpha') }}
run: ./gradlew adobecolor:assemble -PparamEnv=RELEASE dokkaHtml
- name: Deploy Documentation
uses: JamesIves/[email protected]
run: chmod +x ./gradlew

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: adobecolor/build/dokka/html
TARGET_FOLDER: docs
CLEAN: true
distribution: zulu
java-version: 11

- name: Prepare environment
env:
SONATYPE_GPG_FILE_CONTENTS: ${{ secrets.SONATYPE_GPG_FILE_CONTENTS }}
SONATYPE_GPG_FILE: ${{ secrets.SONATYPE_GPG_FILE }}
run: |
git fetch --unshallow
sudo bash -c "echo '$SONATYPE_GPG_FILE_CONTENTS' | base64 -d > '$SONATYPE_GPG_FILE'"
- name: Release build
run: ./gradlew adobecolor:assembleRelease

- name: Publish to MavenCentral
run: ./gradlew adobecolor:publishReleasePublicationToSonatypeRepository -Plibrary_only --no-configure-on-demand --no-parallel dokkaHtml
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
SONATYPE_GPG_KEY: ${{ secrets.SONATYPE_GPG_KEY }}
SONATYPE_GPG_PASS: ${{ secrets.SONATYPE_GPG_PASS }}
SONATYPE_GPG_FILE: ${{ secrets.SONATYPE_GPG_FILE }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
.externalNativeBuild
.cxx
local.properties
adobecolor/gradle.properties
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@ If you want to test the library, please visit the sample app on [Google Play](ht
## Usage
The first step for using this library is, to add it to the dependency section in your project:

Add repository to build.gradle file on project level:
```gradle
allprojects {
repositories {
...
maven { url "https://repo.chillibits.com/artifactory/android" }
}
}
```

Add dependencies to build.gradle file on module level (e.g. app/build.gradle):
```gradle
implementation 'com.chillibits:adobecolortool:1.0.0'
implementation 'com.chillibits:adobecolortool:1.0.1'
```
Also you have to declare a file provider in your manifest, which should look similar to this one:
```xml
Expand Down
92 changes: 9 additions & 83 deletions adobecolor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'com.jfrog.artifactory'
id 'maven-publish'
id 'android-maven'
id 'org.jetbrains.dokka'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 19
targetSdkVersion 30
versionCode library_version_code
versionName library_version
versionCode libraryVersionCode
versionName libraryVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand All @@ -37,11 +34,14 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

// specify the artifactId as module-name for kotlin
kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
}

dependencies {
// Base dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
Expand All @@ -59,80 +59,6 @@ dokkaHtml.configure {
dokkaSourceSets {}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier = "sources"
}

publishing {
publications {
android.libraryVariants.all { variant ->
def filename = "${archivesBaseName}-${variant.baseName}"
"${variant.name}"(MavenPublication) {
groupId 'com.chillibits'
artifactId = "adobecolortool"
if (project.hasProperty('paramEnv') && project.property('paramEnv') != 'RELEASE' || variant.name != "release") {
groupId "com.chillibits.${variant.name}"
}
version = "${android.defaultConfig.versionName}"
if (variant.buildType.name == "debug") {
artifact(sourcesJar)
}
artifact file("$buildDir/outputs/aar/${filename}.aar")
pom.withXml {
// for dependencies and exclusions
def dependenciesNode = asNode().appendNode('dependencies')
def configurationNames = ["implementation", "api", "runtimeOnly"]
configurationNames.each { confName ->
configurations[confName].allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
if (it.excludeRules.size() > 0) {
def exclusionsNode = dependencyNode.appendNode('exclusions')
it.excludeRules.each { rule ->
def exclusionNode = exclusionsNode.appendNode('exclusion')
exclusionNode.appendNode('groupId', rule.group)
exclusionNode.appendNode('artifactId', rule.module)
}
}
}
}
}
}
}
}
}
assemble.finalizedBy(artifactoryPublish)
artifactory {
contextUrl = "${artifactory_context_url}"
publish {
repository {
repoKey = "${artifactory_dev_repo_key}"
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') {
repoKey = "${artifactory_rel_repo_key}"
}
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') {
publications('release')
} else {
publications('debug', 'release')
}
publishArtifacts = true
publishPom = true
}
}
resolve {
repository {
repoKey = "${artifactory_rel_repo_key}"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
if (project.hasProperty('pushall') || project.hasProperty('library_only')) {
apply from: '../gradle-release.gradle'
}
8 changes: 8 additions & 0 deletions adobecolor/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright © Marc Auberer 2021. All rights reserved
#

POM_NAME=Adobe Color Tool
POM_DESCRIPTION=Android library for importing / exporting colors as ACO & ASE files.
POM_ARTIFACT_ID=adobecolortool
POM_PACKAGING=aar
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ plugins {

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.chillibits.adobecolorsample"
minSdkVersion 19
targetSdkVersion 30
versionCode library_version_code
versionName library_version
versionCode libraryVersionCode
versionName libraryVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -41,7 +41,7 @@ dependencies {
implementation project(':adobecolor')

// Base dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
*/

buildscript {
ext.library_version = '1.0.0'
ext.library_version_code = 1000
ext.kotlin_version = "1.5.0"
ext {
libraryVersion = "$VERSION"
libraryVersionCode = Integer.parseInt(rootProject.properties["VERSION_CODE"])
kotlinVersion = '1.4.32'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.23.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.32'
}
}
Expand Down
Loading

0 comments on commit b6ca84c

Please sign in to comment.