Skip to content

Commit e3fd9f8

Browse files
committed
CHG from maven-publish ossrh to central portal publishing
1 parent 2b6ce0a commit e3fd9f8

File tree

5 files changed

+162
-134
lines changed

5 files changed

+162
-134
lines changed

build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
2+
13
// Top-level build file where you can add configuration options common to all sub-projects/modules.
24
buildscript {
35
extra.set("kotlin_version", "1.9.10")
@@ -20,12 +22,13 @@ plugins {
2022
id("org.jetbrains.dokka") version "1.9.10"
2123
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
2224
id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false
25+
id("com.vanniktech.maven.publish") version "0.31.0" apply false
2326
}
2427

2528

26-
apply {
27-
from("${rootDir}/scripts/publish-root.gradle")
28-
}
29+
// apply {
30+
// from("${rootDir}/scripts/publish-root.gradle")
31+
// }
2932

3033

3134

@@ -38,4 +41,4 @@ allprojects {
3841

3942
tasks.register("clean", Delete::class) {
4043
delete(rootProject.layout.buildDirectory)
41-
}
44+
}

core/build.gradle.kts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
2+
import com.vanniktech.maven.publish.SonatypeHost
3+
14
plugins {
25
id("com.android.library")
36
id("kotlin-android")
47
id("com.google.devtools.ksp")
5-
id("maven-publish")
68
id("org.jetbrains.dokka")
9+
id("com.vanniktech.maven.publish") version "0.31.0"
710
}
811

912
version = properties["VERSION_NAME"] as String
@@ -34,10 +37,30 @@ android {
3437

3538
}
3639

37-
apply {
38-
from("${rootDir}/scripts/publish-module.gradle")
40+
41+
mavenPublishing {
42+
configure(
43+
AndroidSingleVariantLibrary(
44+
// the published variant
45+
variant = "release",
46+
// whether to publish a sources jar
47+
sourcesJar = true,
48+
// whether to publish a javadoc jar
49+
publishJavadocJar = true,
50+
)
51+
)
52+
53+
54+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
55+
signAllPublications()
3956
}
4057

58+
59+
// apply {
60+
// from("${rootDir}/scripts/publish-module.gradle")
61+
// }
62+
63+
4164
dependencies {
4265
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
4366
implementation("androidx.core:core-ktx:1.15.0")
@@ -71,7 +94,7 @@ dependencies {
7194
implementation("androidx.security:security-crypto:1.1.0-alpha06")
7295

7396
//Google Guava
74-
implementation("com.google.guava:guava:33.3.1-jre")
97+
implementation("com.google.guava:guava:33.4.5-jre")
7598

7699
//Apache commons io
77100
//https://mvnrepository.com/artifact/commons-io/commons-io

gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Project-wide Gradle settings.
2-
GROUP_ID=de.raphaelebner
3-
ARTIFACT_ID=roomdatabasebackup
2+
GROUP=de.raphaelebner
3+
POM_ARTIFACT_ID=roomdatabasebackup
44
VERSION_NAME=1.0.2
55
VERSION_CODE=1
66

7+
POM_NAME="roomdatabasebackup"
8+
POM_INCEPTION_YEAR=2020
79
POM_DESCRIPTION=Simple tool to Backup and Restore your Room Database
810
POM_URL=https://github.com/rafi0101/Android-Room-Database-Backup
911
POM_SCM_URL=https://github.com/rafi0101/Android-Room-Database-Backup/tree/master

scripts/publish-module.gradle

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
11

2-
apply plugin: 'maven-publish'
3-
apply plugin: 'signing'
4-
apply plugin: 'org.jetbrains.dokka'
2+
// apply plugin: 'com.vanniktech.maven.publish'
3+
// apply plugin: 'signing'
4+
// apply plugin: 'org.jetbrains.dokka'
55

6-
tasks.withType(Jar).configureEach {
7-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
8-
}
6+
// tasks.withType(Jar).configureEach {
7+
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
8+
// }
99

10-
tasks.register('androidSourcesJar', Jar) {
11-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
12-
archiveClassifier.set('sources')
13-
if (project.plugins.findPlugin("com.android.library")) {
14-
// For Android libraries
15-
from android.sourceSets.main.kotlin.srcDirs
16-
from android.sourceSets.main.java.srcDirs
17-
} else {
18-
// For pure Kotlin libraries, in case you have them
19-
from sourceSets.main.java.srcDirs
20-
from sourceSets.main.kotlin.srcDirs
21-
}
22-
}
10+
// tasks.register('androidSourcesJar', Jar) {
11+
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
12+
// archiveClassifier.set('sources')
13+
// if (project.plugins.findPlugin("com.android.library")) {
14+
// // For Android libraries
15+
// from android.sourceSets.main.kotlin.srcDirs
16+
// from android.sourceSets.main.java.srcDirs
17+
// } else {
18+
// // For pure Kotlin libraries, in case you have them
19+
// from sourceSets.main.java.srcDirs
20+
// from sourceSets.main.kotlin.srcDirs
21+
// }
22+
// }
2323

24-
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
25-
pluginsMapConfiguration.set(
26-
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
27-
)
28-
}
24+
// tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
25+
// pluginsMapConfiguration.set(
26+
// ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
27+
// )
28+
// }
2929

30-
tasks.register('javadocJar', Jar) {
31-
dependsOn dokkaJavadoc
32-
archiveClassifier.set("javadoc")
33-
from dokkaJavadoc.outputDirectory
34-
}
30+
// tasks.register('javadocJar', Jar) {
31+
// dependsOn dokkaJavadoc
32+
// archiveClassifier.set("javadoc")
33+
// from dokkaJavadoc.outputDirectory
34+
// }
3535

36-
tasks.register('htmldocJar', Jar) {
37-
dependsOn dokkaHtml
38-
archiveClassifier.set("htmldoc")
39-
from dokkaHtml.outputDirectory
40-
}
36+
// tasks.register('htmldocJar', Jar) {
37+
// dependsOn dokkaHtml
38+
// archiveClassifier.set("htmldoc")
39+
// from dokkaHtml.outputDirectory
40+
// }
4141

42-
artifacts {
43-
archives androidSourcesJar
44-
archives javadocJar
45-
archives htmldocJar
46-
}
42+
// artifacts {
43+
// archives androidSourcesJar
44+
// archives javadocJar
45+
// archives htmldocJar
46+
// }
4747

48-
group = GROUP_ID
49-
version = VERSION_NAME
48+
// group = GROUP_ID
49+
// version = VERSION_NAME
5050

51-
afterEvaluate {
52-
publishing {
53-
publications {
54-
release(MavenPublication) {
55-
tasks.named("generateMetadataFileForReleasePublication").configure {dependsOn(androidSourcesJar)}
51+
// afterEvaluate {
52+
// publishing {
53+
// publications {
54+
// release(MavenPublication) {
55+
// tasks.named("generateMetadataFileForReleasePublication").configure {dependsOn(androidSourcesJar)}
5656

57-
groupId GROUP_ID
58-
artifactId ARTIFACT_ID
59-
version VERSION_NAME
57+
// groupId GROUP_ID
58+
// artifactId ARTIFACT_ID
59+
// version VERSION_NAME
6060

61-
// Two artifacts, the `aar` (or `jar`) and the sources
62-
if (project.plugins.findPlugin("com.android.library")) {
63-
from components.release
64-
} else {
65-
from components.java
66-
}
61+
// // Two artifacts, the `aar` (or `jar`) and the sources
62+
// if (project.plugins.findPlugin("com.android.library")) {
63+
// from components.release
64+
// } else {
65+
// from components.java
66+
// }
6767

68-
artifact javadocJar
69-
artifact htmldocJar
70-
// artifact androidSourcesJar
68+
// artifact javadocJar
69+
// artifact htmldocJar
70+
// // artifact androidSourcesJar
7171

72-
// Mostly self-explanatory metadata
73-
pom {
74-
name = ARTIFACT_ID
75-
description = POM_DESCRIPTION
76-
url = POM_URL
77-
licenses {
78-
license {
79-
name = POM_LICENCE_NAME
80-
url = POM_LICENCE_URL
81-
}
82-
}
83-
developers {
84-
developer {
85-
id = POM_DEVELOPER_ID
86-
name = POM_DEVELOPER_NAME
87-
}
88-
}
72+
// // Mostly self-explanatory metadata
73+
// pom {
74+
// name = ARTIFACT_ID
75+
// description = POM_DESCRIPTION
76+
// url = POM_URL
77+
// licenses {
78+
// license {
79+
// name = POM_LICENCE_NAME
80+
// url = POM_LICENCE_URL
81+
// }
82+
// }
83+
// developers {
84+
// developer {
85+
// id = POM_DEVELOPER_ID
86+
// name = POM_DEVELOPER_NAME
87+
// }
88+
// }
8989

90-
// Version control info - if you're using GitHub, follow the
91-
// format as seen here
92-
scm {
93-
connection = POM_SCM_CONNECTION
94-
developerConnection = POM_SCM_DEV_CONNECTION
95-
url = POM_SCM_URL
96-
}
97-
}
98-
}
99-
}
100-
}
101-
}
90+
// // Version control info - if you're using GitHub, follow the
91+
// // format as seen here
92+
// scm {
93+
// connection = POM_SCM_CONNECTION
94+
// developerConnection = POM_SCM_DEV_CONNECTION
95+
// url = POM_SCM_URL
96+
// }
97+
// }
98+
// }
99+
// }
100+
// }
101+
// }
102102

103-
signing {
104-
sign publishing.publications
105-
}
103+
// signing {
104+
// sign publishing.publications
105+
// }

scripts/publish-root.gradle

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
// Create variables with empty default values
2-
ext["signing.keyId"] = ''
3-
ext["signing.password"] = ''
4-
ext["signing.secretKeyRingFile"] = ''
5-
ext["ossrhUsername"] = ''
6-
ext["ossrhPassword"] = ''
7-
ext["sonatypeStagingProfileId"] = ''
1+
// // Create variables with empty default values
2+
// ext["signing.keyId"] = ''
3+
// ext["signing.password"] = ''
4+
// ext["signing.secretKeyRingFile"] = ''
5+
// ext["ossrhUsername"] = ''
6+
// ext["ossrhPassword"] = ''
7+
// ext["sonatypeStagingProfileId"] = ''
88

9-
File secretPropsFile = project.rootProject.file('local.properties')
10-
if (secretPropsFile.exists()) {
11-
// Read local.properties file first if it exists
12-
Properties p = new Properties()
13-
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
14-
p.each { name, value -> ext[name] = value }
15-
} else {
16-
// Use system environment variables
17-
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
18-
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
19-
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
20-
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
21-
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
22-
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEYRIGNFILE')
9+
// File secretPropsFile = project.rootProject.file('local.properties')
10+
// if (secretPropsFile.exists()) {
11+
// // Read local.properties file first if it exists
12+
// Properties p = new Properties()
13+
// new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
14+
// p.each { name, value -> ext[name] = value }
15+
// } else {
16+
// // Use system environment variables
17+
// ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
18+
// ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
19+
// ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
20+
// ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
21+
// ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
22+
// ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEYRIGNFILE')
2323

24-
}
25-
26-
nexusPublishing {
27-
repositories {
28-
sonatype {
29-
stagingProfileId = sonatypeStagingProfileId
30-
username = ossrhUsername
31-
password = ossrhPassword
32-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
33-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
34-
}
35-
}
36-
}
24+
// }
3725

26+
// nexusPublishing {
27+
// repositories {
28+
// sonatype {
29+
// stagingProfileId = sonatypeStagingProfileId
30+
// username = ossrhUsername
31+
// password = ossrhPassword
32+
// nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
33+
// snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
34+
// }
35+
// }
36+
// }
37+
// import com.vanniktech.maven.publish.AndroidSingleVariantLibrary

0 commit comments

Comments
 (0)