Skip to content

Commit

Permalink
Add logic to publish the Godot OpenXR Android library to MavenCentral
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Mar 15, 2022
1 parent c38e12e commit 6fda84f
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 22 deletions.
29 changes: 20 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: "com.android.library"
apply plugin: "kotlin-android"

apply from: "../scripts/publish-module.gradle"

android {
buildToolsVersion = versions.buildTools
compileSdkVersion versions.compileSdk
Expand All @@ -9,8 +11,8 @@ android {
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode 10300 // Also update 'src/main/AndroidManifest.xml#versionCode' value
versionName '1.3.0' // Also update 'src/main/AndroidManifest.xml#versionName' value
versionCode versions.versionCode
versionName versions.versionName
setProperty("archivesBaseName", "godotopenxr.${versionName}")

externalNativeBuild {
Expand All @@ -26,6 +28,8 @@ android {
}
}

namespace = "org.godotengine.plugin.vr.openxr"

compileOptions {
sourceCompatibility versions.javaVersion
targetCompatibility versions.javaVersion
Expand All @@ -51,16 +55,23 @@ android {
}
}
}

// TODO: Enable when issues with AGP 7.1+ are resolved (https://github.com/GodotVR/godot_openxr/issues/187).
// publishing {
// singleVariant("fullRelease") {
// withSourcesJar()
// withJavadocJar()
// }

//singleVariant("stubRelease") {
// withSourcesJar()
// withJavadocJar()
// }
// }
}

dependencies {
if (rootProject.findProject(":godot:lib") != null) {
// Used for development and debugging
compileOnly(project(":godot:lib"))
} else {
compileOnly(fileTree(dir: "libs", include: ["godot-lib*.aar"]))
}

api "io.github.m4gr3d:godot:3.5.0.beta"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlinVersion}"
}

Expand Down
Binary file removed android/libs/godot-lib.3.4.3.stable.release.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.godotengine.plugin.vr.openxr"
android:versionCode="10300"
android:versionName="1.3.0">
android:versionName="1.3.0.beta">

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />

Expand Down
1 change: 0 additions & 1 deletion android_samples/demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ android {

dependencies {
implementation project(":GodotOpenXR")
implementation(fileTree(dir: "../../android/libs", include: ["godot-lib*.aar"]))
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlinVersion}"
implementation 'androidx.appcompat:appcompat:1.3.1'
}
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: 'config.gradle'
apply from: 'scripts/publish-root.gradle'

buildscript {
apply from: 'config.gradle'

repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.android.tools.build:gradle:$versions.gradlePluginVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion"
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
}
}

Expand Down
27 changes: 17 additions & 10 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
ext.versions = [
gradlePluginVersion: '7.0.3',
compileSdk : 30,
minSdk : 19, // Also update 'android/src/main/AndroidManifest.xml#minSdkVersion' value
targetSdk : 30, // Also update 'android/src/main/AndroidManifest.xml#targetSdkVersion' value
buildTools : '30.0.3',
kotlinVersion : '1.6.10',
ndkVersion : "21.4.7075529",
javaVersion : JavaVersion.VERSION_1_8
]
ext {
versions = [
gradlePluginVersion: '7.0.3',
compileSdk : 30,
minSdk : 19, // Also update 'android/src/main/AndroidManifest.xml#minSdkVersion' value
targetSdk : 30, // Also update 'android/src/main/AndroidManifest.xml#targetSdkVersion' value
buildTools : '30.0.3',
kotlinVersion : '1.6.10',
ndkVersion : "21.4.7075529",
javaVersion : JavaVersion.VERSION_1_8,
versionCode : 10300, // Also update 'src/main/AndroidManifest.xml#versionCode' value
versionName : '1.3.0.beta', // Also update 'src/main/AndroidManifest.xml#versionName' value
]

PUBLISH_ARTIFACT_ID = 'godot-openxr'
STUB_PUBLISH_ARTIFACT_ID = PUBLISH_ARTIFACT_ID + "-stub"
}
1 change: 1 addition & 0 deletions demo/addons/godot-openxr/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes to the Godot OpenXR asset
1.3.0
-------------------
- Added default interaction profiles for Samsung Odyssey, HTC Cosmos, HTC Focus and Huawei controllers.
- Added logic to enable publishing of the Godot OpenXR Android library to MavenCentral.

1.2.0
-------------------
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
118 changes: 118 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

group = ossrhGroupId
version = versions.versionName

afterEvaluate {
publishing {
publications {
fullRelease(MavenPublication) {
from components.fullRelease

// The coordinates of the library, being set from variables that
// we'll set up later
groupId ossrhGroupId
artifactId PUBLISH_ARTIFACT_ID
version versions.versionName

// Mostly self-explanatory metadata
pom {
name = PUBLISH_ARTIFACT_ID
description = 'Godot OpenXR Android Library'
url = 'https://docs.godotengine.org/en/stable/tutorials/vr/openxr/index.html'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/GodotVR/godot_openxr/blob/master/LICENSE'
}
}
developers {
developer {
id = 'm4gr3d'
name = 'Fredia Huya-Kouadio'
email = 'fhuyakou@gmail.com'
}
developer {
id = 'BastiaanOlij'
name = 'Bastiaan Olij'
email = 'mux213@gmail.com'
}
developer {
id = 'ChristophHaag'
name = 'Christoph Haag'
email = 'haagch@frickel.club'
}
// Add all other devs here...
}

// Version control info - if you're using GitHub, follow the
// format as seen here
scm {
connection = 'scm:git:github.com/GodotVR/godot_openxr.git'
developerConnection = 'scm:git:ssh://github.com/GodotVR/godot_openxr.git'
url = 'https://github.com/GodotVR/godot_openxr/tree/master'
}
}
}

stubRelease(MavenPublication) {
from components.stubRelease

// The coordinates of the library, being set from variables that
// we'll set up later
groupId ossrhGroupId
artifactId STUB_PUBLISH_ARTIFACT_ID
version versions.versionName

// Mostly self-explanatory metadata
pom {
name = STUB_PUBLISH_ARTIFACT_ID
description = 'Godot OpenXR Android (Stub) Library'
url = 'https://docs.godotengine.org/en/stable/tutorials/vr/openxr/index.html'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/GodotVR/godot_openxr/blob/master/LICENSE'
}
}
developers {
developer {
id = 'm4gr3d'
name = 'Fredia Huya-Kouadio'
email = 'fhuyakou@gmail.com'
}
developer {
id = 'BastiaanOlij'
name = 'Bastiaan Olij'
email = 'mux213@gmail.com'
}
developer {
id = 'ChristophHaag'
name = 'Christoph Haag'
email = 'haagch@frickel.club'
}
// Add all other devs here...
}

// Version control info - if you're using GitHub, follow the
// format as seen here
scm {
connection = 'scm:git:github.com/GodotVR/godot_openxr.git'
developerConnection = 'scm:git:ssh://github.com/GodotVR/godot_openxr.git'
url = 'https://github.com/GodotVR/godot_openxr/tree/master'
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"],
)
sign publishing.publications
}
39 changes: 39 additions & 0 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Create variables with empty default values
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.key"] = ''
ext["ossrhGroupId"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhGroupId"] = System.getenv('OSSRH_GROUP_ID')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.key"] = System.getenv('SIGNING_KEY')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}

0 comments on commit 6fda84f

Please sign in to comment.