Skip to content

Commit 6b5d4ee

Browse files
committed
Configure the validation_layers module for upload to maven central
1 parent f938f34 commit 6b5d4ee

File tree

7 files changed

+92
-9
lines changed

7 files changed

+92
-9
lines changed

config.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ ext {
3737
return releaseVersion
3838
}
3939

40+
getValidationLayersVersion = { ->
41+
return "${versions.openxrVersion}-${getReleaseVersion()}"
42+
}
43+
4044
shouldNotStrip = { ->
4145
return project.hasProperty("doNotStrip")
4246
}

plugin/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins {
55

66
ext {
77
PUBLISH_ARTIFACT_ID = 'godot-openxr-vendors'
8+
PUBLISH_ARTIFACT_VERSION = getReleaseVersion()
9+
PUBLISH_ARTIFACT_DESCRIPTION_LABEL = 'Godot OpenXR Vendors'
810
}
911

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

plugin/src/main/cpp/export/export_plugin.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ String OpenXRVendorsEditorExportPlugin::_get_android_aar_file_path(bool debug) c
7272
}
7373

7474
String OpenXRVendorsEditorExportPlugin::_get_android_maven_central_dependency() const {
75-
return "org.godotengine:godot-openxr-vendors-" + _vendor + ":" + _plugin_version;
75+
String version = _plugin_version;
76+
if (!version.to_lower().ends_with("-stable") && !version.to_lower().ends_with("-snapshot")) {
77+
version = version + "-SNAPSHOT";
78+
}
79+
return "org.godotengine:godot-openxr-vendors-" + _vendor + ":" + version;
7680
}
7781

7882
String OpenXRVendorsEditorExportPlugin::_get_vendor_toggle_option_name(const String &vendor_name) const {
@@ -268,7 +272,7 @@ PackedStringArray OpenXRVendorsEditorExportPlugin::_get_android_dependencies_mav
268272
return maven_repos;
269273
}
270274

271-
if (_is_vendor_plugin_enabled() && !_is_android_aar_file_available(debug) && _plugin_version.ends_with("-SNAPSHOT")) {
275+
if (_is_vendor_plugin_enabled() && !_is_android_aar_file_available(debug) && !_plugin_version.to_lower().ends_with("-stable")) {
272276
maven_repos.append("https://central.sonatype.com/repository/maven-snapshots/");
273277
}
274278
return maven_repos;

plugin/src/main/cpp/export/validation_layers_export_plugin.cpp

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2828
/**************************************************************************/
2929

30+
#include "export/export_plugin.h"
3031
#include "export/validation_layers_export_plugin.h"
3132

3233
#include <godot_cpp/classes/editor_export_platform_android.hpp>
3334
#include <godot_cpp/classes/project_settings.hpp>
35+
#include <openxr/openxr.h>
3436

3537
OpenXRValidationLayersEditorExportPlugin::OpenXRValidationLayersEditorExportPlugin() {
3638
{
@@ -89,10 +91,50 @@ PackedStringArray OpenXRValidationLayersEditorExportPlugin::_get_android_librari
8991
return dependencies;
9092
}
9193

92-
if ((bool)get_option("xr_features/enable_openxr_validation_layers")) {
93-
const String debug_label = debug ? "debug" : "release";
94-
dependencies.append("res://addons/godotopenxrvendors/.bin/android/" + debug_label + "/openxr-validation-layers-" + debug_label + ".aar");
94+
if (_is_enabled() && _is_android_aar_file_available(debug)) {
95+
dependencies.append(_get_android_aar_file_path(debug));
9596
}
9697

9798
return dependencies;
9899
}
100+
101+
PackedStringArray OpenXRValidationLayersEditorExportPlugin::_get_android_dependencies(const Ref<godot::EditorExportPlatform> &platform, bool debug) const {
102+
PackedStringArray dependencies;
103+
if (!_supports_platform(platform)) {
104+
return dependencies;
105+
}
106+
107+
if (_is_enabled() && !_is_android_aar_file_available(debug)) {
108+
dependencies.append("org.godotengine:openxr-validation-layers:" + _get_version());
109+
}
110+
return dependencies;
111+
}
112+
113+
PackedStringArray OpenXRValidationLayersEditorExportPlugin::_get_android_dependencies_maven_repos(const Ref<godot::EditorExportPlatform> &platform, bool debug) const {
114+
PackedStringArray maven_repos;
115+
if (!_supports_platform(platform)) {
116+
return maven_repos;
117+
}
118+
119+
if (_is_enabled() && !_is_android_aar_file_available(debug) && !_get_version().to_lower().ends_with("-stable")) {
120+
maven_repos.append("https://central.sonatype.com/repository/maven-snapshots/");
121+
}
122+
return maven_repos;
123+
}
124+
125+
String OpenXRValidationLayersEditorExportPlugin::_get_android_aar_file_path(bool debug) const {
126+
const String debug_label = debug ? "debug" : "release";
127+
return "res://addons/godotopenxrvendors/.bin/android/" + debug_label + "/openxr-validation-layers-" + debug_label + ".aar";
128+
}
129+
130+
String OpenXRValidationLayersEditorExportPlugin::_get_version() const {
131+
String version = vformat("%d.%d.%d-%s",
132+
XR_VERSION_MAJOR(XR_CURRENT_API_VERSION),
133+
XR_VERSION_MINOR(XR_CURRENT_API_VERSION),
134+
XR_VERSION_PATCH(XR_CURRENT_API_VERSION),
135+
PLUGIN_VERSION);
136+
if (!version.to_lower().ends_with("-stable") && !version.to_lower().ends_with("-snapshot")) {
137+
version = version + "-SNAPSHOT";
138+
}
139+
return version;
140+
}

plugin/src/main/cpp/include/export/validation_layers_export_plugin.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#pragma once
3131

3232
#include <godot_cpp/classes/editor_export_plugin.hpp>
33+
#include <godot_cpp/classes/file_access.hpp>
3334
#include <godot_cpp/classes/ref.hpp>
3435

3536
using namespace godot;
@@ -52,5 +53,22 @@ class OpenXRValidationLayersEditorExportPlugin : public EditorExportPlugin {
5253
String _get_export_option_warning(const Ref<EditorExportPlatform> &platform, const String &option) const override;
5354
TypedArray<Dictionary> _get_export_options(const Ref<EditorExportPlatform> &platform) const override;
5455

56+
PackedStringArray _get_android_dependencies(const Ref<EditorExportPlatform> &platform, bool debug) const override;
57+
PackedStringArray _get_android_dependencies_maven_repos(const Ref<EditorExportPlatform> &platform, bool debug) const override;
5558
PackedStringArray _get_android_libraries(const Ref<EditorExportPlatform> &platform, bool debug) const;
59+
60+
private:
61+
/// Path to the Android library aar file. If the return file path is not available, we
62+
/// fall back to the maven central dependency.
63+
String _get_android_aar_file_path(bool debug) const;
64+
65+
bool _is_android_aar_file_available(bool debug) const {
66+
return FileAccess::file_exists(_get_android_aar_file_path(debug));
67+
}
68+
69+
bool _is_enabled() const {
70+
return (bool)get_option("xr_features/enable_openxr_validation_layers");
71+
}
72+
73+
String _get_version() const;
5674
};

scripts/publish-module.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'maven-publish'
22
apply plugin: 'signing'
33

44
group = ossrhGroupId
5-
version = getReleaseVersion()
5+
version = PUBLISH_ARTIFACT_VERSION
66

77
afterEvaluate {
88
publishing {
@@ -14,7 +14,7 @@ afterEvaluate {
1414
flavorArtifactId = "$flavorArtifactId-$flavorName"
1515
}
1616

17-
String descriptionLabel = "Godot OpenXR Vendors"
17+
String descriptionLabel = PUBLISH_ARTIFACT_DESCRIPTION_LABEL
1818
String buildType = variant.buildType.name
1919
if (buildType == "debug") {
2020
flavorArtifactId = "$flavorArtifactId-debug"
@@ -29,7 +29,7 @@ afterEvaluate {
2929
// The coordinates of the library, being set from variables that we'll set up later
3030
groupId ossrhGroupId
3131
artifactId flavorArtifactId
32-
version getReleaseVersion()
32+
version PUBLISH_ARTIFACT_VERSION
3333

3434
// Mostly self-explanatory metadata
3535
pom {

validation_layers/build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ plugins {
33
id 'org.jetbrains.kotlin.android'
44
}
55

6+
ext {
7+
PUBLISH_ARTIFACT_ID = 'openxr-validation-layers'
8+
PUBLISH_ARTIFACT_VERSION = getValidationLayersVersion()
9+
PUBLISH_ARTIFACT_DESCRIPTION_LABEL = "Godot OpenXR Validation Layers"
10+
}
11+
12+
apply from: "../scripts/publish-module.gradle"
13+
614
def khronosOpenxrValidationLayersAndroidAssetsTargetDir = file("${buildDir}/temp/openxr_validation_layers_assets")
715
def khronosOpenxrValidationLayersAndroidBuildDir = file("${buildDir}/temp/openxr_validation_layers_build")
816

@@ -19,7 +27,7 @@ android {
1927
defaultConfig {
2028
minSdk versions.minSdk
2129
targetSdk versions.targetSdk
22-
versionName getReleaseVersion()
30+
versionName getValidationLayersVersion()
2331

2432
setProperty("archivesBaseName", "openxr-validation-layers")
2533

@@ -122,6 +130,11 @@ android {
122130
dependsOn("copyOpenxrValidationLayersAndroid${capitalizedBuildType}JSON")
123131
}
124132
}
133+
134+
publishing {
135+
singleVariant("debug") {}
136+
singleVariant("release") {}
137+
}
125138
}
126139

127140
task copyDebugAARToAddons(type: Copy) {

0 commit comments

Comments
 (0)