Skip to content

[build] publish lib to maven repo #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ dependencies {
implementation 'com.github.beatjs:react-android:0.63.4.+'
}
```


### publish lib to maven repo
1. create `local.properties` file to project root dir.
```properties
OSS_USERNAME={username}
OSS_PASSWORD={password}
OSS_REPOSITORY_URL={repo_url}
```

2. specify `GROUP_ID` , `VERSION_NAME` in `gradle.properties`

3. exec gradle cmd `gradle uploadArchives`
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ allprojects {
jcenter()
maven { url 'https://jitpack.io' }
}
}

subprojects {
apply from:"$rootDir/scripts/publish-module.gradle"
}
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.useDeprecatedNdk=true
android.useDeprecatedNdk=true


VERSION_NAME=0.63.4.1
GROUP_ID=com.github.beatjs
36 changes: 36 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apply plugin: "maven"

ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value ->
ext[name] = value
}
} else {
ext["OSS_USERNAME"] = System.getenv('OSS_USERNAME')
ext["OSS_PASSWORD"] = System.getenv('OSS_PASSWORD')
}


logger.quiet("project:$project.name GROUP_ID:$GROUP_ID")
logger.quiet(">>> OSS_REPOSITORY_URL:$OSS_REPOSITORY_URL")

uploadArchives {
repositories {
mavenDeployer {
repository(url: OSS_REPOSITORY_URL) {
authentication(userName: OSS_USERNAME, password: OSS_PASSWORD)
}
pom.project {
artifactId project.name
version VERSION_NAME
groupId GROUP_ID
packaging 'aar'
}
}
}
}