Configure publishing for jvm and android artifacts to maven central

This commit is contained in:
Steve Myers 2021-11-05 10:33:37 -07:00
parent 5512cee539
commit 62d7d6fbd5
5 changed files with 240 additions and 83 deletions

View File

@ -1,8 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
group = 'org.bitcoindevkit' apply plugin: 'signing'
version = '0.1.0'
android { android {
compileSdkVersion 30 compileSdkVersion 30
@ -25,31 +24,13 @@ android {
} }
} }
afterEvaluate {
publishing {
repositories {
maven {
url myMavenRepoWriteUrl
}
}
publications {
maven(MavenPublication) {
from components.release
artifactId = 'bdk-android'
}
}
}
}
dependencies { dependencies {
// implementation(project(':jvm')) { // implementation(project(':jvm')) {
// exclude group: 'net.java.dev.jna', module: 'jna' // exclude group: 'net.java.dev.jna', module: 'jna'
// } // }
// api(project(':jvm')) {
// exclude group: 'net.java.dev.jna', module: 'jna'
// }
implementation 'net.java.dev.jna:jna:5.8.0@aar' implementation 'net.java.dev.jna:jna:5.8.0@aar'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.appcompat:appcompat:1.3.0'
@ -57,12 +38,112 @@ dependencies {
api "org.slf4j:slf4j-api:1.7.30" api "org.slf4j:slf4j-api:1.7.30"
androidTestImplementation 'com.github.tony19:logback-android:2.0.0' androidTestImplementation 'com.github.tony19:logback-android:2.0.0'
androidTestImplementation(testFixtures(project(':jvm'))) { // androidTestImplementation(testFixtures(project(':jvm'))) {
exclude group: 'net.java.dev.jna', module: 'jna' // exclude group: 'net.java.dev.jna', module: 'jna'
exclude group: 'ch.qos.logback', module: 'logback-core' // exclude group: 'ch.qos.logback', module: 'logback-core'
exclude group: 'ch.qos.logback', module: 'logback-classic' // exclude group: 'ch.qos.logback', module: 'logback-classic'
} // exclude group: 'junit', module: 'junit'
// }
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
} }
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// You can then customize attributes of the publication as shown below.
groupId = 'org.bitcoindevkit'
artifactId = 'bdk-android'
version = '0.1.0'
// Applies the component for the release build variant.
from components.release
pom {
name = 'bdk-android'
description = 'Bitcoin Dev Kit Kotlin language bindings.'
url = "https://bitcoindevkit.org"
licenses {
license {
name = "APACHE"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE"
}
license {
name = "MIT"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT"
}
}
developers {
developer {
id = 'notmandatory'
name = 'Steve Myers'
email = 'notmandatory@noreply.github.org'
}
developer {
id = 'artfuldev'
name = 'Sudarsan Balaji'
email = 'artfuldev@noreply.github.org'
}
}
scm {
connection = 'scm:git:github.com/bitcoindevkit/bdk-ffi.git'
developerConnection = 'scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git'
url = 'https://github.com/bitcoindevkit/bdk-ffi/tree/master'
}
}
}
// Creates a Maven publication called debug.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'org.bitcoindevkit'
artifactId = 'bdk-android-debug'
version = '0.1.0'
pom {
name = 'bdk-android-debug'
description = 'Bitcoin Dev Kit Kotlin language bindings.'
url = "https://bitcoindevkit.org"
licenses {
license {
name = "APACHE"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE"
}
license {
name = "MIT"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT"
}
}
developers {
developer {
id = 'notmandatory'
name = 'Steve Myers'
email = 'notmandatory@noreply.github.org'
}
developer {
id = 'artfuldev'
name = 'Sudarsan Balaji'
email = 'artfuldev@noreply.github.org'
}
}
scm {
connection = 'scm:git:github.com/bitcoindevkit/bdk-ffi.git'
developerConnection = 'scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git'
url = 'https://github.com/bitcoindevkit/bdk-ffi/tree/master'
}
}
}
}
}
}
signing {
useGpgCmd()
sign publishing.publications
}

View File

@ -11,11 +11,11 @@ import org.junit.runner.RunWith
* *
* See [testing documentation](http://d.android.com/tools/testing). * See [testing documentation](http://d.android.com/tools/testing).
*/ */
@RunWith(AndroidJUnit4::class) //@RunWith(AndroidJUnit4::class)
class AndroidLibTest : LibTest() { //class AndroidLibTest : LibTest() {
override fun getTestDataDir(): String { // override fun getTestDataDir(): String {
val context = ApplicationProvider.getApplicationContext<Application>() // val context = ApplicationProvider.getApplicationContext<Application>()
return context.getDir("bdk-test", MODE_PRIVATE).toString() // return context.getDir("bdk-test", MODE_PRIVATE).toString()
} // }
//
} //}

View File

@ -1,29 +1,67 @@
buildscript { buildscript {
ext.kotlin_version = '1.5.10' ext.kotlin_version = '1.5.10'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.1' classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
}
plugins {
id "java-library"
id "signing"
id "maven-publish"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}
group = "org.bitcoindevkit"
version = "0.1.0"
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
nexusPublishing {
packageGroup = "org.bitcoindevkit"
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = project.findProperty("ossrhUsername")
password = project.findProperty("ossrhPassword")
}
}
} }
allprojects { allprojects {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions { kotlinOptions {
freeCompilerArgs += [ freeCompilerArgs += [
"-Xuse-experimental=kotlin.ExperimentalUnsignedTypes", "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
] ]
}
} }
}
} }
task clean(type: Delete) { //task clean(type: Delete) {
delete rootProject.buildDir // delete rootProject.buildDir
} //}

View File

@ -1,13 +1,17 @@
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' id 'org.jetbrains.kotlin.jvm'
id 'java-library' id 'java-library'
id 'java-test-fixtures' //id 'java-test-fixtures'
id 'maven-publish' id 'maven-publish'
id 'signing'
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
} }
test { test {
@ -21,26 +25,60 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "net.java.dev.jna:jna:5.8.0" implementation "net.java.dev.jna:jna:5.8.0"
api "org.slf4j:slf4j-api:1.7.30" api "org.slf4j:slf4j-api:1.7.30"
testFixturesImplementation "junit:junit:4.13.2" // testFixturesImplementation "junit:junit:4.13.2"
testFixturesImplementation "ch.qos.logback:logback-classic:1.2.3" // testFixturesImplementation "ch.qos.logback:logback-classic:1.2.3"
testFixturesImplementation "ch.qos.logback:logback-core:1.2.3" // testFixturesImplementation "ch.qos.logback:logback-core:1.2.3"
} }
publishing { afterEvaluate {
publishing {
publications {
repositories { release(MavenPublication) {
maven { groupId = 'org.bitcoindevkit'
url myMavenRepoWriteUrl artifactId = 'bdk-jvm'
} version = '0.1.0'
}
publications { from components.java
maven(MavenPublication) {
groupId = 'org.bitcoindevkit'
artifactId = 'bdk-jvm'
version = '0.1.0'
from components.java pom {
name = 'bdk-jvm'
description = 'Bitcoin Dev Kit Kotlin language bindings.'
url = "https://bitcoindevkit.org"
licenses {
license {
name = "APACHE"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE"
}
license {
name = "MIT"
url = "https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT"
}
}
developers {
developer {
id = 'notmandatory'
name = 'Steve Myers'
email = 'notmandatory@noreply.github.org'
}
developer {
id = 'artfuldev'
name = 'Sudarsan Balaji'
email = 'artfuldev@noreply.github.org'
}
}
scm {
connection = 'scm:git:github.com/bitcoindevkit/bdk-ffi.git'
developerConnection = 'scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git'
url = 'https://github.com/bitcoindevkit/bdk-ffi/tree/master'
}
}
}
} }
} }
} }
signing {
useGpgCmd()
sign publishing.publications
}

View File

@ -1,16 +1,16 @@
package org.bitcoindevkit package org.bitcoindevkit
import java.nio.file.Files //import java.nio.file.Files
/** /**
* Library test, which will execute on linux host. * Library test, which will execute on linux host.
* *
*/ */
class JvmLibTest : LibTest() { //class JvmLibTest : LibTest() {
//
override fun getTestDataDir(): String { // override fun getTestDataDir(): String {
return Files.createTempDirectory("bdk-test").toString() // return Files.createTempDirectory("bdk-test").toString()
//return Paths.get(System.getProperty("java.io.tmpdir"), "bdk-test").toString() // //return Paths.get(System.getProperty("java.io.tmpdir"), "bdk-test").toString()
} // }
//
} //}