Skip to content

Commit c4c609d

Browse files
committed
publishing
1 parent 1f5aa73 commit c4c609d

File tree

15 files changed

+168
-130
lines changed

15 files changed

+168
-130
lines changed

.idea/gradle.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

-84
This file was deleted.

app/src/androidTest/java/com/example/cozoandroid/ExampleInstrumentedTest.java

-26
This file was deleted.

app/src/test/java/com/example/cozoandroid/ExampleUnitTest.java

-17
This file was deleted.

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ plugins {
33
id 'com.android.application' version '7.3.1' apply false
44
id 'com.android.library' version '7.3.1' apply false
55
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
6-
}
6+
}
7+
8+
apply from: "${rootDir}/scripts/publish-root.gradle"
File renamed without changes.

cozo_android/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
plugins {
2+
id 'com.android.library'
3+
}
4+
5+
android {
6+
namespace 'org.cozodb'
7+
compileSdk 33
8+
9+
defaultConfig {
10+
minSdk 16
11+
targetSdk 33
12+
versionCode 1
13+
versionName "1.0"
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
compileOptions {
23+
sourceCompatibility JavaVersion.VERSION_1_8
24+
targetCompatibility JavaVersion.VERSION_1_8
25+
}
26+
}
27+
28+
dependencies {
29+
implementation 'org.sharegov:mjson:1.4.1'
30+
}
31+
32+
ext {
33+
PUBLISH_GROUP_ID = 'io.github.cozodb'
34+
PUBLISH_VERSION = '0.2.1'
35+
PUBLISH_ARTIFACT_ID = 'cozo_android'
36+
}
37+
38+
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
File renamed without changes.
File renamed without changes.

publish.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./gradlew cozo_android:publishReleasePublicationToSonatypeRepository

scripts/publish-module.gradle

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
task androidSourcesJar(type: Jar) {
5+
archiveClassifier.set('sources')
6+
if (project.plugins.findPlugin("com.android.library")) {
7+
// For Android libraries
8+
from android.sourceSets.main.java.srcDirs
9+
from android.sourceSets.main.kotlin.srcDirs
10+
} else {
11+
// For pure Kotlin libraries, in case you have them
12+
from sourceSets.main.java.srcDirs
13+
from sourceSets.main.kotlin.srcDirs
14+
}
15+
}
16+
17+
artifacts {
18+
archives androidSourcesJar
19+
}
20+
21+
group = PUBLISH_GROUP_ID
22+
version = PUBLISH_VERSION
23+
24+
afterEvaluate {
25+
publishing {
26+
publications {
27+
release(MavenPublication) {
28+
// The coordinates of the library, being set from variables that
29+
// we'll set up later
30+
groupId PUBLISH_GROUP_ID
31+
artifactId PUBLISH_ARTIFACT_ID
32+
version PUBLISH_VERSION
33+
34+
// Two artifacts, the `aar` (or `jar`) and the sources
35+
if (project.plugins.findPlugin("com.android.library")) {
36+
from components.release
37+
} else {
38+
from components.java
39+
}
40+
41+
artifact androidSourcesJar
42+
// artifact javadocJar
43+
44+
// Mostly self-explanatory metadata
45+
pom {
46+
name = PUBLISH_ARTIFACT_ID
47+
description = 'CozoDB for Android'
48+
url = 'https://github.com/cozodb/cozo-lib-android'
49+
inceptionYear = '2022'
50+
51+
licenses {
52+
license {
53+
name = 'MIT License'
54+
url = 'https://opensource.org/licenses/MIT'
55+
}
56+
}
57+
developers {
58+
developer {
59+
id = 'zh217'
60+
name = 'Ziyang Hu'
61+
62+
}
63+
}
64+
scm {
65+
connection = 'scm:git:git:github.com/cozodb/cozo-lib-android.git'
66+
developerConnection = 'scm:git:https://github.com/cozodb/cozo-lib-android.git'
67+
url = 'https://github.com/cozodb/cozo-lib-android.git'
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
75+
signing {
76+
println(rootProject.ext["signing.keyId"])
77+
println(rootProject.ext["signing.key"])
78+
println(rootProject.ext["signing.password"])
79+
80+
useInMemoryPgpKeys(
81+
rootProject.ext["signing.keyId"],
82+
rootProject.ext["signing.key"],
83+
rootProject.ext["signing.password"],
84+
)
85+
sign publishing.publications
86+
}

scripts/publish-root.gradle

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Create variables with empty default values
2+
ext["signing.keyId"] = ''
3+
ext["signing.password"] = ''
4+
ext["signing.key"] = ''
5+
ext["ossrhUsername"] = ''
6+
ext["ossrhPassword"] = ''
7+
ext["sonatypeStagingProfileId"] = ''
8+
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.key"] = System.getenv('SIGNING_KEY')
23+
}
24+
25+
// Set up Sonatype repository
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+
}

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ dependencyResolutionManagement {
1313
}
1414
}
1515
rootProject.name = "CozoAndroid"
16-
include ':app'
16+
include ':cozo_android'

0 commit comments

Comments
 (0)