diff --git a/android/build.gradle b/android/build.gradle index 97cc37d..67bb67e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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 @@ -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 { @@ -26,6 +28,8 @@ android { } } + namespace = "org.godotengine.plugin.vr.openxr" + compileOptions { sourceCompatibility versions.javaVersion targetCompatibility versions.javaVersion @@ -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"])) - } - + implementation "io.github.m4gr3d:godot:${versions.godotVersion}" implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlinVersion}" } diff --git a/android/libs/godot-lib.3.4.3.stable.release.aar b/android/libs/godot-lib.3.4.3.stable.release.aar deleted file mode 100644 index 250cc6d..0000000 Binary files a/android/libs/godot-lib.3.4.3.stable.release.aar and /dev/null differ diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index e8ac0f9..ec9f883 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -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"> diff --git a/android_samples/demo/build.gradle b/android_samples/demo/build.gradle index af9a576..cb8b9c2 100644 --- a/android_samples/demo/build.gradle +++ b/android_samples/demo/build.gradle @@ -56,7 +56,7 @@ android { dependencies { implementation project(":GodotOpenXR") - implementation(fileTree(dir: "../../android/libs", include: ["godot-lib*.aar"])) + implementation "io.github.m4gr3d:godot:${versions.godotVersion}" implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlinVersion}" implementation 'androidx.appcompat:appcompat:1.3.1' } diff --git a/build.gradle b/build.gradle index 6000729..2aefcc9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,6 @@ +apply plugin: 'io.github.gradle-nexus.publish-plugin' apply from: 'config.gradle' +apply from: 'scripts/publish-root.gradle' buildscript { apply from: 'config.gradle' @@ -6,10 +8,12 @@ buildscript { 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' } } diff --git a/config.gradle b/config.gradle index 1958efd..b8df1f4 100644 --- a/config.gradle +++ b/config.gradle @@ -1,10 +1,18 @@ -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 + godotVersion : '3.5.0.beta', + ] + + PUBLISH_ARTIFACT_ID = 'godot-openxr' + STUB_PUBLISH_ARTIFACT_ID = PUBLISH_ARTIFACT_ID + "-stub" +} diff --git a/demo/addons/godot-openxr/CHANGES.md b/demo/addons/godot-openxr/CHANGES.md index 3ba7dd0..e4f69f0 100644 --- a/demo/addons/godot-openxr/CHANGES.md +++ b/demo/addons/godot-openxr/CHANGES.md @@ -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 ------------------- diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 29e4134..a0f7639 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle new file mode 100644 index 0000000..2fd3efc --- /dev/null +++ b/scripts/publish-module.gradle @@ -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 +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..ae88487 --- /dev/null +++ b/scripts/publish-root.gradle @@ -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/")) + } + } +} +