mirror of
https://github.com/wgtunnel/Android-Room-Database-Backup.git
synced 2026-10-09 14:40:29 -07:00
ADD possibility to publish android library to MavenCentral
This commit is contained in:
5 files changed
+159
-18
No files matched your search
+5
-3
@@ -1,6 +1,8 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
plugins {
|
||||
id('com.android.application')
|
||||
id('kotlin-android')
|
||||
id('kotlin-kapt')
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
|
||||
@@ -14,6 +14,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id('io.github.gradle-nexus.publish-plugin') version "1.1.0"
|
||||
id("org.jetbrains.dokka") version "1.6.0"
|
||||
}
|
||||
|
||||
apply from: "${rootDir}/scripts/publish-root.gradle"
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
|
||||
+13
-15
@@ -1,7 +1,10 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'maven-publish'
|
||||
plugins {
|
||||
id('com.android.library')
|
||||
id('kotlin-android')
|
||||
id('kotlin-kapt')
|
||||
id('maven-publish')
|
||||
id('org.jetbrains.dokka')
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
@@ -39,19 +42,14 @@ android {
|
||||
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
from components.release
|
||||
groupId = 'de.raphaelebner.roomdatabasebackup.core'
|
||||
artifactId = 'Android-Room-Database-Backup'
|
||||
version = android.defaultConfig.versionName
|
||||
}
|
||||
}
|
||||
}
|
||||
ext {
|
||||
PUBLISH_GROUP_ID = 'de.raphaelebner'
|
||||
PUBLISH_VERSION = android.defaultConfig.versionName
|
||||
PUBLISH_ARTIFACT_ID = 'Android-Room-Database-Backup'
|
||||
}
|
||||
|
||||
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
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")) {
|
||||
// For Android libraries
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
from android.sourceSets.main.kotlin.srcDirs
|
||||
} else {
|
||||
// For pure Kotlin libraries, in case you have them
|
||||
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
|
||||
}
|
||||
|
||||
task htmldocJar(type: Jar, dependsOn: dokkaHtml) {
|
||||
archiveClassifier.set("htmldoc")
|
||||
from dokkaHtml.outputDirectory
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives androidSourcesJar
|
||||
archives javadocJar
|
||||
archives htmldocJar
|
||||
}
|
||||
|
||||
group = PUBLISH_GROUP_ID
|
||||
version = PUBLISH_VERSION
|
||||
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
// The coordinates of the library, being set from variables that
|
||||
// we'll set up later
|
||||
groupId PUBLISH_GROUP_ID
|
||||
artifactId PUBLISH_ARTIFACT_ID
|
||||
version PUBLISH_VERSION
|
||||
|
||||
// Two artifacts, the `aar` (or `jar`) and the sources
|
||||
if (project.plugins.findPlugin("com.android.library")) {
|
||||
from components.release
|
||||
} else {
|
||||
from components.java
|
||||
}
|
||||
|
||||
artifact javadocJar
|
||||
artifact htmldocJar
|
||||
artifact androidSourcesJar
|
||||
|
||||
// Mostly self-explanatory metadata
|
||||
pom {
|
||||
name = PUBLISH_ARTIFACT_ID
|
||||
description = 'Simple tool to Backup and Restore your Room Database'
|
||||
url = 'https://github.com/rafi0101/Android-Room-Database-Backup'
|
||||
licenses {
|
||||
license {
|
||||
name = 'MIT License'
|
||||
url = 'https://github.com/rafi0101/Android-Room-Database-Backup/blob/master/LICENSE'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = 'rafi0101'
|
||||
name = 'Raphael Ebner'
|
||||
}
|
||||
}
|
||||
|
||||
// Version control info - if you're using GitHub, follow the
|
||||
// format as seen here
|
||||
scm {
|
||||
connection = 'scm:git:github.com/rafi0101/Android-Room-Database-Backup.git'
|
||||
developerConnection = 'scm:git:ssh://github.com/rafi0101/Android-Room-Database-Backup.git'
|
||||
url = 'https://github.com/rafi0101/Android-Room-Database-Backup/tree/master'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
sign publishing.publications
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Create variables with empty default values
|
||||
ext["signing.keyId"] = ''
|
||||
ext["signing.password"] = ''
|
||||
ext["signing.secretKeyRingFile"] = ''
|
||||
ext["ossrhUsername"] = ''
|
||||
ext["ossrhPassword"] = ''
|
||||
ext["sonatypeStagingProfileId"] = ''
|
||||
|
||||
File secretPropsFile = project.rootProject.file('local.properties')
|
||||
if (secretPropsFile.exists()) {
|
||||
// Read local.properties file first if it exists
|
||||
Properties p = new Properties()
|
||||
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
|
||||
p.each { name, value -> ext[name] = value }
|
||||
} else {
|
||||
// Use system environment variables
|
||||
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
|
||||
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
|
||||
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
|
||||
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
|
||||
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
|
||||
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEYRIGNFILE')
|
||||
|
||||
}
|
||||
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype {
|
||||
stagingProfileId = sonatypeStagingProfileId
|
||||
username = ossrhUsername
|
||||
password = ossrhPassword
|
||||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
|
||||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user