Skip to content

Commit

Permalink
Update lz4 to 1.9.3, gradle to 7.0.2 and publish to maven central. Er…
Browse files Browse the repository at this point in the history
…adicate jcenter from project.
  • Loading branch information
jurmous committed May 24, 2021
1 parent 3e824b1 commit 937d0b2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 49 deletions.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
buildscript {
repositories {
google()
jcenter()

mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.2.1'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
114 changes: 71 additions & 43 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import com.jfrog.bintray.gradle.BintrayExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import java.util.*

plugins {
id("com.android.library")
id("maven-publish")
id("com.jfrog.bintray").version("1.8.4")
id("signing")
}

val lz4Version = "1.9.2"
val lz4Version = "1.9.3"

group = "io.maryk.lz4"
version = lz4Version

val lz4Home = projectDir.resolve("lz4/lz4-$lz4Version")

android {
compileSdkVersion(29)
buildToolsVersion("29.0.3")
compileSdkVersion(30)
buildToolsVersion("30.0.3")
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
targetSdkVersion(30)
versionCode = 1
versionName = "1.0"
versionName = "1.0"
externalNativeBuild {
cmake {
targets.add("liblz4")
Expand All @@ -36,8 +39,8 @@ android {
}
externalNativeBuild {
cmake {
setPath("CMakeLists.txt")
setVersion("3.10.2")
path = File("$projectDir/CMakeLists.txt")
version = "3.18.1"
}
}
}
Expand Down Expand Up @@ -71,6 +74,33 @@ tasks.withType<com.android.build.gradle.tasks.ExternalNativeBuildJsonTask> {
dependsOn(downloadLz4)
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}

fun getExtraString(name: String) = ext[name]?.toString()

afterEvaluate {
val publishTasks = mutableListOf<Jar>()

Expand All @@ -93,6 +123,17 @@ afterEvaluate {
}

publishing {
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

publications {
register<MavenPublication>("lz4").configure {
artifact(sourcesJar)
Expand All @@ -117,47 +158,34 @@ afterEvaluate {
}
}
}
}


fun findProperty(s: String) = project.findProperty(s) as String?
bintray {
user = findProperty("bintrayUser")
key = findProperty("bintrayApiKey")
publish = true
pkg(delegateClosureOf<BintrayExtension.PackageConfig> {
repo = "maven"
name = "lz4-android"
userOrg = "maryk"
setLicenses("Apache-2.0")
setPublications(*project.publishing.publications.names.toTypedArray())
vcsUrl = "https://github.com/marykdb/lz4-android.git"
})
}

project.publishing.publications.withType<MavenPublication>().forEach { publication ->
publication.pom.withXml {
asNode().apply {
appendNode("name", project.name)
appendNode("description", "lz4 compression library")
appendNode("url", "https://github.com/marykdb/lz4-android")
appendNode("licenses").apply {
appendNode("license").apply {
appendNode("name", "The Apache Software License, Version 2.0")
appendNode("url", "http://www.apache.org/licenses/LICENSE-2.0.txt")
appendNode("distribution", "repo")
publications.withType<MavenPublication> {
pom {
name.set(project.name)
description.set("lz4 compression library")
url.set("https://github.com/marykdb/lz4-android")

licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
appendNode("developers").apply {
appendNode("developer").apply {
appendNode("id", "jurmous")
appendNode("name", "Jurriaan Mous")
developers {
developer {
id.set("jurmous")
name.set("Jurriaan Mous")
}
}
appendNode("scm").apply {
appendNode("url", "https://github.com/marykdb/lz4-android.git")
scm {
url.set("https://github.com/marykdb/lz4-android.git")
}
}
}
}
}

signing {
sign(publishing.publications)
}
}
2 changes: 1 addition & 1 deletion library/downloadLz4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LZ4_VERSION=$1
if [ ! -d "${LZ4_TARGET_DIRECTORY}/lz4-${LZ4_VERSION}" ]; then
echo "Downloading lz4 ${LZ4_VERSION} into $LZ4_TARGET_DIRECTORY ..."
mkdir -p "$LZ4_TARGET_DIRECTORY"
curl -s -L "https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz" | tar -C "$LZ4_TARGET_DIRECTORY" -xz
curl -s -L "https://github.com/lz4/lz4/archive/refs/tags/v${LZ4_VERSION}.tar.gz" | tar -C "$LZ4_TARGET_DIRECTORY" -xz
else
echo "lz4 ${LZ4_VERSION} has already been downloaded!"
fi

0 comments on commit 937d0b2

Please sign in to comment.