Skip to content

Commit a9ea95c

Browse files
committed
Add Maven Central publishing configuration
🚀 Maven Central Setup: - Added signing plugin and GPG configuration - Configured Sonatype OSS repository - Created comprehensive setup guide (MAVEN_CENTRAL_SETUP.md) - Added publishing script (publish-to-maven-central.sh) - Updated README with Maven Central installation instructions - Added Maven Central badge 📦 Publishing Features: - Automatic signing with GPG keys - Sonatype OSS staging repository - Comprehensive POM metadata - MIT license and developer info - SCM information for GitHub ✅ Ready for Maven Central: - Build configuration verified - AAR generation successful - Ready for Sonatype OSS publishing
1 parent d6f24ff commit a9ea95c

4 files changed

Lines changed: 222 additions & 21 deletions

File tree

MAVEN_CENTRAL_SETUP.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Maven Central Publishing Setup Guide
2+
3+
This guide will help you publish the Android Debug Drawer library to Maven Central.
4+
5+
## Prerequisites
6+
7+
1. **Sonatype OSS Account**: Create an account at https://s01.oss.sonatype.org/
8+
2. **GPG Key**: Generate a GPG key for signing artifacts
9+
3. **Domain Verification**: Verify ownership of the `com.abualzait` domain
10+
11+
## Step 1: Create Sonatype OSS Account
12+
13+
1. Go to https://s01.oss.sonatype.org/
14+
2. Click "Sign Up" and create an account
15+
3. Create a new project ticket for `com.abualzait` group ID
16+
4. Wait for approval (usually 1-2 business days)
17+
18+
## Step 2: Generate GPG Key
19+
20+
### On macOS/Linux:
21+
```bash
22+
# Install GPG if not already installed
23+
brew install gnupg # macOS
24+
# or
25+
sudo apt-get install gnupg # Ubuntu/Debian
26+
27+
# Generate a new key
28+
gpg --gen-key
29+
30+
# List your keys to get the key ID
31+
gpg --list-secret-keys
32+
33+
# Export your public key
34+
gpg --armor --export YOUR_KEY_ID > public_key.asc
35+
36+
# Export your private key
37+
gpg --armor --export-secret-keys YOUR_KEY_ID > private_key.asc
38+
```
39+
40+
### Upload Public Key to Keyservers:
41+
```bash
42+
gpg --send-keys YOUR_KEY_ID
43+
gpg --keyserver hkp://keyserver.ubuntu.com --send-keys YOUR_KEY_ID
44+
```
45+
46+
## Step 3: Configure Credentials
47+
48+
Create a `~/.gradle/gradle.properties` file with your credentials:
49+
50+
```properties
51+
# Sonatype OSS credentials
52+
sonatypeUsername=your-sonatype-username
53+
sonatypePassword=your-sonatype-password
54+
55+
# GPG signing credentials
56+
signingKeyId=YOUR_KEY_ID
57+
signingKey=YOUR_PRIVATE_KEY
58+
signingPassword=YOUR_KEY_PASSPHRASE
59+
```
60+
61+
**⚠️ Security Note**: Never commit these credentials to version control!
62+
63+
## Step 4: Publish to Maven Central
64+
65+
### Option 1: Using the Script
66+
```bash
67+
# Set environment variables
68+
export SONATYPE_USERNAME=your-username
69+
export SONATYPE_PASSWORD=your-password
70+
export SIGNING_KEY_ID=your-key-id
71+
export SIGNING_KEY=your-private-key
72+
export SIGNING_PASSWORD=your-passphrase
73+
74+
# Run the publishing script
75+
./publish-to-maven-central.sh
76+
```
77+
78+
### Option 2: Manual Gradle Commands
79+
```bash
80+
# Clean and build
81+
./gradlew clean
82+
./gradlew :debugdrawer:assembleRelease
83+
84+
# Publish to staging
85+
./gradlew :debugdrawer:publishReleasePublicationToSonatypeRepository
86+
```
87+
88+
## Step 5: Release from Staging
89+
90+
1. Go to https://s01.oss.sonatype.org/
91+
2. Login with your credentials
92+
3. Navigate to "Staging Repositories"
93+
4. Find your repository (should contain `comabualzait`)
94+
5. Click "Close" and wait for validation
95+
6. If validation passes, click "Release"
96+
7. The library will be available on Maven Central in ~10 minutes
97+
98+
## Step 6: Verify Publication
99+
100+
Check that your library is available at:
101+
- https://search.maven.org/artifact/com.abualzait/debugdrawer
102+
- https://repo1.maven.org/maven2/com/abualzait/debugdrawer/
103+
104+
## Usage in Projects
105+
106+
Once published, users can add the library to their projects:
107+
108+
```kotlin
109+
// In project-level build.gradle.kts
110+
allprojects {
111+
repositories {
112+
mavenCentral()
113+
// ... other repositories
114+
}
115+
}
116+
117+
// In app-level build.gradle.kts
118+
dependencies {
119+
implementation("com.abualzait:debugdrawer:1.2.3")
120+
}
121+
```
122+
123+
## Troubleshooting
124+
125+
### Common Issues:
126+
127+
1. **"Repository not found"**: Make sure you've created a ticket for the group ID
128+
2. **"Invalid signature"**: Verify your GPG key is uploaded to keyservers
129+
3. **"Authentication failed"**: Check your Sonatype credentials
130+
4. **"Staging validation failed"**: Check the validation errors in the Sonatype UI
131+
132+
### Getting Help:
133+
134+
- Sonatype OSS Documentation: https://central.sonatype.org/
135+
- Maven Central Search: https://search.maven.org/
136+
- GPG Documentation: https://gnupg.org/documentation/
137+
138+
## Library Information
139+
140+
- **Group ID**: `com.abualzait`
141+
- **Artifact ID**: `debugdrawer`
142+
- **Current Version**: `1.2.3`
143+
- **License**: MIT
144+
- **Repository**: https://github.com/mabualzait/Android-Debug-Drawer

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
44
[![CI](https://github.com/mabualzait/Android-Debug-Drawer/workflows/CI/badge.svg)](https://github.com/mabualzait/Android-Debug-Drawer/actions)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.abualzait/debugdrawer.svg)](https://search.maven.org/artifact/com.abualzait/debugdrawer)
56
[![JitPack](https://jitpack.io/v/mabualzait/Android-Debug-Drawer.svg)](https://jitpack.io/#mabualzait/Android-Debug-Drawer)
67
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)
78
[![Android](https://img.shields.io/badge/Platform-Android-green.svg)](https://developer.android.com/)
@@ -77,7 +78,28 @@ The Android Debug Drawer is designed to be simple to integrate and use. Follow t
7778

7879
### 1. Installation
7980

80-
#### 🚀 **Quick Start (JitPack - Recommended)**
81+
#### 🚀 **Maven Central (Recommended)**
82+
83+
Add to your project's `build.gradle.kts` (project level):
84+
```kotlin
85+
allprojects {
86+
repositories {
87+
google()
88+
mavenCentral()
89+
}
90+
}
91+
```
92+
93+
Add to your app's `build.gradle.kts`:
94+
```kotlin
95+
dependencies {
96+
debugImplementation("com.abualzait:debugdrawer:1.2.3")
97+
}
98+
```
99+
100+
#### 📦 **JitPack (Alternative)**
101+
102+
If Maven Central is not available, you can use JitPack:
81103

82104
Add to your project's `build.gradle.kts` (project level):
83105
```kotlin
@@ -93,13 +115,14 @@ allprojects {
93115
Add to your app's `build.gradle.kts`:
94116
```kotlin
95117
dependencies {
96-
debugImplementation 'com.abualzait:debugdrawer:1.0.0'
118+
debugImplementation("com.github.mabualzait:Android-Debug-Drawer:1.2.3")
97119
}
98120
```
99121

100122
**Available versions:**
101-
- `1.0.0` - Latest stable release
102-
- `main-SNAPSHOT` - Latest development version
123+
- `1.2.3` - Latest stable release (Maven Central)
124+
- `v1.2.3` - Latest stable release (JitPack)
125+
- `main-SNAPSHOT` - Latest development version (JitPack)
103126

104127
#### 🔧 **Local Development (Clone as Module)**
105128

debugdrawer/build.gradle.kts

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
id("org.jlleitschuh.gradle.ktlint")
99
id("jacoco")
1010
id("maven-publish")
11+
id("signing")
1112
}
1213

1314
android {
@@ -116,45 +117,69 @@ jacoco {
116117
toolVersion = "0.8.11"
117118
}
118119

119-
// Maven publishing configuration for JitPack
120+
// Maven Central publishing configuration
120121
afterEvaluate {
121122
publishing {
122123
publications {
123124
create<MavenPublication>("release") {
124125
from(components["release"])
125126

126127
groupId = "com.abualzait"
127-
artifactId = project.findProperty("POM_ARTIFACT_ID") as String? ?: "debugdrawer"
128-
version = project.findProperty("VERSION_NAME") as String? ?: "1.0.0"
128+
artifactId = "debugdrawer"
129+
version = "1.2.3"
129130

130131
pom {
131-
name.set(project.findProperty("POM_NAME") as String? ?: "Android Debug Drawer")
132-
description.set(project.findProperty("POM_DESCRIPTION") as String? ?: "A comprehensive, production-ready debug drawer for Android apps")
133-
url.set(project.findProperty("POM_URL") as String? ?: "https://github.com/mabualzait/Android-Debug-Drawer")
132+
name.set("Android Debug Drawer")
133+
description.set("A comprehensive, production-ready debug drawer for Android apps with plug-and-play integration")
134+
url.set("https://github.com/mabualzait/Android-Debug-Drawer")
134135

135136
licenses {
136137
license {
137-
name.set(project.findProperty("POM_LICENCE_NAME") as String? ?: "MIT")
138-
url.set(project.findProperty("POM_LICENCE_URL") as String? ?: "https://opensource.org/licenses/MIT")
139-
distribution.set(project.findProperty("POM_LICENCE_DIST") as String? ?: "repo")
138+
name.set("MIT")
139+
url.set("https://opensource.org/licenses/MIT")
140+
distribution.set("repo")
140141
}
141142
}
142143

143144
developers {
144145
developer {
145-
id.set(project.findProperty("POM_DEVELOPER_ID") as String? ?: "mabualzait")
146-
name.set(project.findProperty("POM_DEVELOPER_NAME") as String? ?: "Malik Abualzait")
147-
url.set(project.findProperty("POM_DEVELOPER_URL") as String? ?: "https://github.com/mabualzait")
146+
id.set("mabualzait")
147+
name.set("Malik Abualzait")
148+
email.set("malik.abualzait@gmail.com")
149+
url.set("https://github.com/mabualzait")
148150
}
149151
}
150152

151153
scm {
152-
url.set(project.findProperty("POM_SCM_URL") as String? ?: "https://github.com/mabualzait/Android-Debug-Drawer")
153-
connection.set(project.findProperty("POM_SCM_CONNECTION") as String? ?: "scm:git:git://github.com/mabualzait/Android-Debug-Drawer.git")
154-
developerConnection.set(project.findProperty("POM_SCM_DEV_CONNECTION") as String? ?: "scm:git:ssh://github.com/mabualzait/Android-Debug-Drawer.git")
154+
url.set("https://github.com/mabualzait/Android-Debug-Drawer")
155+
connection.set("scm:git:git://github.com/mabualzait/Android-Debug-Drawer.git")
156+
developerConnection.set("scm:git:ssh://github.com/mabualzait/Android-Debug-Drawer.git")
155157
}
156158
}
157159
}
158160
}
161+
162+
repositories {
163+
maven {
164+
name = "sonatype"
165+
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
166+
credentials {
167+
username = project.findProperty("sonatypeUsername") as String?
168+
password = project.findProperty("sonatypePassword") as String?
169+
}
170+
}
171+
}
172+
}
173+
}
174+
175+
// Signing configuration for Maven Central
176+
signing {
177+
val signingKeyId = project.findProperty("signingKeyId") as String?
178+
val signingKey = project.findProperty("signingKey") as String?
179+
val signingPassword = project.findProperty("signingPassword") as String?
180+
181+
if (signingKeyId != null && signingKey != null && signingPassword != null) {
182+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
183+
sign(publishing.publications)
159184
}
160185
}

gradle.properties

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ org.gradle.configuration-cache=true
3434
org.gradle.caching=true
3535

3636
# Library version for JitPack publishing
37-
VERSION_NAME=1.0.1
37+
VERSION_NAME=1.2.3
3838
POM_ARTIFACT_ID=debugdrawer
3939
POM_NAME=Android Debug Drawer
4040
POM_DESCRIPTION=A comprehensive, production-ready debug drawer for Android apps
@@ -47,4 +47,13 @@ POM_LICENCE_URL=https://opensource.org/licenses/MIT
4747
POM_LICENCE_DIST=repo
4848
POM_DEVELOPER_ID=abualzait
4949
POM_DEVELOPER_NAME=Malik Abualzait
50-
POM_DEVELOPER_URL=https://github.com/mabualzait
50+
POM_DEVELOPER_URL=https://github.com/mabualzait
51+
52+
# Maven Central publishing credentials
53+
# These should be set in your local gradle.properties or as environment variables
54+
# For security, do not commit these values to version control
55+
sonatypeUsername=your-sonatype-username
56+
sonatypePassword=your-sonatype-password
57+
signingKeyId=your-signing-key-id
58+
signingKey=your-signing-key
59+
signingPassword=your-signing-password

0 commit comments

Comments
 (0)