Skip to content

Commit 2c12594

Browse files
authored
feat: publish plugin to mavenLocal (#102)
1 parent 086ab14 commit 2c12594

File tree

4 files changed

+105
-3
lines changed

4 files changed

+105
-3
lines changed

gradle-plugins/publish-to-maven-local.sh

100644100755
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
cd ./gradle-plugins/react && ./gradlew build || exit 1
2-
./gradlew :brownfield:publishToMavenLocal
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd ./gradle-plugins/react
6+
./gradlew clean
7+
./gradlew build
8+
./gradlew :brownfield:publishMavenLocalPublicationToMavenLocalRepository

gradle-plugins/react/PUBLISHING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Publishing a Signed Plugin
2+
3+
To publish a signed plugin (currently to `mavenLocal` only), you need to configure the signing key data in plugin's `gradle.properties` file
4+
5+
> [!IMPORTANT]
6+
> Make sure to clear `~/.m2` directory before starting publishing process
7+
8+
### 1. Add Signing Key Data
9+
Update `gradle.properties` file with the following properties:
10+
```
11+
signing.keyId=<key>
12+
signing.password=<password>
13+
signing.secretKeyRingFile=<path-to-gpg-file>
14+
```
15+
* `keyId`: The public key ID.
16+
* `password`: The passphrase used when creating the key.
17+
* `secretKeyRingFile`: The absolute path to the private key file.
18+
19+
### 2. Publish the Plugin
20+
Once the signing key is set up correctly, run the following command:
21+
```sh
22+
yarn brownfield:plugin:publish:local
23+
```
24+
25+
### 3. Output
26+
If everything is configured properly, the signed plugin will be published to the `~/.m2` repository.
27+
28+
### 4. Publishing
29+
Go to `~/.m2/repository`, ZIP created plugin at `com` directory level (make sure there isn't any other plugin inside it) and upload it to [Maven Central](https://central.sonatype.com/)
30+

gradle-plugins/react/brownfield/build.gradle.kts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import java.util.Properties
2+
13
plugins {
24
alias(libs.plugins.kotlinJvm)
35
`java-gradle-plugin`
46
alias(libs.plugins.ktlint)
57
alias(libs.plugins.detekt)
68
`maven-publish`
9+
signing
710
}
811

912
ktlint {
@@ -42,6 +45,50 @@ publishing {
4245
publications.withType<MavenPublication>().configureEach {
4346
artifactId = property("ARTIFACT_ID").toString()
4447
}
48+
49+
publications {
50+
create<MavenPublication>("mavenLocal") {
51+
from(components["java"])
52+
53+
groupId = property("GROUP").toString()
54+
artifactId = property("ARTIFACT_ID").toString()
55+
version = property("VERSION").toString()
56+
57+
pom {
58+
name.set(property("DISPLAY_NAME").toString())
59+
description.set(property("DESCRIPTION").toString())
60+
url.set(property("GITHUB_URL").toString())
61+
62+
licenses {
63+
license {
64+
name.set("The MIT License")
65+
url.set("https://opensource.org/licenses/MIT")
66+
distribution.set("repo")
67+
}
68+
}
69+
developers {
70+
developer {
71+
id.set("callstack")
72+
name.set("Callstack Team")
73+
email.set("[email protected]")
74+
}
75+
}
76+
scm {
77+
connection.set(property("SCM_CONNECTION").toString())
78+
developerConnection.set(property("SCM_DEV_CONNECTION").toString())
79+
url.set(property("GITHUB_URL").toString())
80+
}
81+
}
82+
}
83+
}
84+
85+
repositories {
86+
mavenLocal()
87+
}
88+
}
89+
90+
signing {
91+
sign(publishing.publications["mavenLocal"])
4592
}
4693

4794
repositories {
@@ -62,3 +109,19 @@ tasks.named("detekt").configure {
62109
tasks.register("lint") {
63110
dependsOn(":ktlintFormat")
64111
}
112+
113+
java {
114+
withJavadocJar()
115+
withSourcesJar()
116+
}
117+
118+
tasks.javadoc {
119+
if (JavaVersion.current().isJava9Compatible) {
120+
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
121+
}
122+
options {
123+
encoding = "UTF-8"
124+
source = "8"
125+
}
126+
}
127+

gradle-plugins/react/brownfield/gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ GROUP=com.callstack.react
55
IMPLEMENTATION_CLASS=com.callstack.react.brownfield.plugin.RNBrownfieldPlugin
66

77
DISPLAY_NAME=React Native Brownfield Gradle Plugin
8-
DESCRIPTION=Helps you generate Fat Aar for React Native Brownfield Projects
8+
DESCRIPTION=Helps you generate Fat Aar for React Native Brownfield Projects
9+
GITHUB_URL=https://github.com/callstack/react-native-brownfield/
10+
SCM_CONNECTION=scm:git:git://github.com/callstack/react-native-brownfield.git
11+
SCM_DEV_CONNECTION=scm:git:ssh://[email protected]:callstack/react-native-brownfield.git

0 commit comments

Comments
 (0)