Skip to content

Commit b67d55f

Browse files
committed
added Gradle Nexus Publish Plugin
1 parent e6b4c0d commit b67d55f

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import org.apache.commons.io.FileUtils
44
import java.util.regex.Pattern
55
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
66

7-
apply plugin: 'java'
8-
97
buildscript {
108
repositories {
119
google()
@@ -18,9 +16,16 @@ buildscript {
1816
}
1917
}
2018

19+
plugins {
20+
id 'java'
21+
id('io.github.gradle-nexus.publish-plugin') version '1.1.0'
22+
}
23+
24+
apply from: "${rootDir}/scripts/publish-root.gradle"
25+
2126
allprojects {
2227
apply plugin: 'java'
23-
apply plugin: 'java-library'
28+
apply plugin: 'java-library'
2429

2530
Properties versions = new Properties()
2631
versions.load(project.rootProject.file("mode/version.properties").newDataInputStream())

buildSrc/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
apply plugin: 'groovy'
1+
// apply plugin: 'groovy'
2+
plugins {
3+
id 'groovy'
4+
}
25

36
repositories {
47
google()

core/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import org.apache.tools.ant.Project
22
import java.nio.file.Files
33
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
44

5-
apply plugin: 'aar'
6-
apply plugin: 'maven-publish'
5+
plugins {
6+
id 'aar'
7+
id 'maven-publish'
8+
}
79

810
dependencies {
911
implementation name: "android"

mode/libraries/ar/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import java.nio.file.Files
22
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
33

4-
apply plugin: 'aar'
5-
apply plugin: 'maven-publish'
4+
plugins {
5+
id 'aar'
6+
id 'maven-publish'
7+
}
68

79
dependencies {
810
compileOnly name: "android"

mode/libraries/vr/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import java.nio.file.Files
22
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
33

4-
apply plugin: 'aar'
5-
apply plugin: 'maven-publish'
4+
plugins {
5+
id 'aar'
6+
id 'maven-publish'
7+
}
68

79
dependencies {
810
compileOnly name: "android"

scripts/publish-module.gradle

Whitespace-only changes.

scripts/publish-root.gradle

Lines changed: 36 additions & 0 deletions
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.secretKeyRingFile"] = ''
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.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
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+
}

0 commit comments

Comments
 (0)