Add custom value denoting module lifecycles. (#1253)

* Add custom value denoting module lifecycles.

* Make the module validation work.

My hand has been forced - we must use buildSrc since JsonSlurper is not available in main buildscript.

* Apply task to each project and dont cross projects

* A horrible hack

* Wait what

* It works now.

* Not needed

* Drop unneeded maven repo, cache map lookup

(cherry picked from commit daa38b3d82)
This commit is contained in:
i509VCB 2021-01-19 18:48:09 +00:00 committed by modmuss50
parent b254046e61
commit 9826cad8ac
44 changed files with 306 additions and 139 deletions

View file

@ -153,6 +153,10 @@ allprojects {
}
}
// Apply auxiliary buildscripts to submodules
// This must be done after all plugins are applied to subprojects
apply from: "gradle/module-validation.gradle"
javadoc {
options {
source = "8"

View file

@ -18,5 +18,8 @@
"depends": {
"fabricloader": ">=0.4.0"
},
"description": "Contains the essentials for Fabric API modules."
"description": "Contains the essentials for Fabric API modules.",
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -21,5 +21,8 @@
"description": "Hooks for adding biomes to the default world generator.",
"mixins": [
"fabric-biomes-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -23,5 +23,8 @@
"description": "Registration utility for block and fluid render layers.",
"mixins": [
"fabric-blockrenderlayer-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -23,5 +23,8 @@
"description": "Re-implements the minecraft:climbable tag from 1.16+ back in 1.15",
"mixins": [
"fabric-climbable-api-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
"description": "Adds command-related hooks.",
"mixins": [
"fabric-command-api-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
},
"description": "Deprecated. Please migrate to v1",
"mixins": [
]
],
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -29,5 +29,8 @@
"client": [
"net.fabricmc.fabric.impl.client.container.ScreenProviderRegistryImpl::init"
]
},
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -23,5 +23,8 @@
"description": "Adds registries for vanilla mechanics that are missing them.",
"mixins": [
"fabric-content-registries-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -21,5 +21,8 @@
"description": "Adds Fabric-related debug info to crash reports.",
"mixins": [
"fabric-crash-report-info-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -16,5 +16,8 @@
},
"mixins": [
"fabric-dimensions-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "experimental"
}
}

View file

@ -31,5 +31,8 @@
"description": "Events for player interaction with blocks and entities.",
"mixins": [
"fabric-events-interaction-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -29,5 +29,8 @@
"fabric-item-api-v1": "*",
"fabric-lifecycle-events-v1": "*"
},
"description": "Legacy events for the game's lifecycle, superseded by fabric-lifecycle-events-v1 and fabric-item-api-v1."
"description": "Legacy events for the game's lifecycle, superseded by fabric-lifecycle-events-v1 and fabric-item-api-v1.",
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -22,5 +22,8 @@
"fabricloader": ">=0.4.0",
"fabric-api-base": "*"
},
"description": "Hooks for items"
"description": "Hooks for items",
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -24,5 +24,8 @@
"description": "An API for adding custom item groups.",
"mixins": [
"fabric-item-groups-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -21,5 +21,8 @@
"description": "Key Binding registry API.",
"mixins": [
"fabric-key-binding-api-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -19,5 +19,8 @@
"fabricloader": ">=0.4.0",
"fabric-key-binding-api-v1": "*"
},
"description": "Keybinding registry API."
"description": "Keybinding registry API.",
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -22,5 +22,8 @@
"fabricloader": ">=0.4.0",
"fabric-api-base": "*"
},
"description": "Events for the game's lifecycle."
"description": "Events for the game's lifecycle.",
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
"description": "Hooks for manipulating loot tables.",
"mixins": [
"fabric-loot-tables-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -21,5 +21,8 @@
"fabric-tag-extensions-v0": "*",
"fabric-tool-attribute-api-v1": "*"
},
"description": "Block mining level tags for tools. Deprecated and replaced by fabric-tool-attribute-v1."
"description": "Block mining level tags for tools. Deprecated and replaced by fabric-tool-attribute-v1.",
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -22,5 +22,8 @@
"description": "Hooks for models and model loading.",
"mixins": [
"fabric-models-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -30,5 +30,8 @@
"description": "Low-level, vanilla protocol oriented networking hooks.",
"mixins": [
"fabric-networking-api-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
"description": "Networking hooks for block entities.",
"mixins": [
"fabric-networking-blockentity-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -28,5 +28,8 @@
"fabric-api-base": "*",
"fabric-networking-api-v1": "*"
},
"description": "Legacy Networking packet hooks and registries, superseded by fabric-networking-api-v1."
"description": "Legacy Networking packet hooks and registries, superseded by fabric-networking-api-v1.",
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -24,5 +24,8 @@
"mixins": [
"fabric-object-builder-v1.mixins.json"
],
"accessWidener" : "fabric-object-builder-api-v1.accesswidener"
"accessWidener" : "fabric-object-builder-api-v1.accesswidener",
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -23,5 +23,8 @@
"description": "Legacy builders for objects vanilla has locked down, superseded by fabric-object-builder-api-v1.",
"mixins": [
"fabric-object-builders-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -8,5 +8,8 @@
},
"mixins": [
"fabric-particles-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -28,5 +28,8 @@
"client": [
"net.fabricmc.fabric.impl.registry.sync.FabricRegistryClientInit"
]
},
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -24,5 +24,8 @@
"mixins": [
"fabric-renderer-api-v1.mixins.json",
"fabric-renderer-api-v1.debughud.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -29,5 +29,8 @@
"client": [
"net.fabricmc.fabric.impl.client.indigo.Indigo"
]
},
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -23,5 +23,8 @@
"description": "Registries for entity and block renderers.",
"mixins": [
"fabric-renderer-registries-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
"description": "Thread-safe hooks for block entity data use during terrain rendering.",
"mixins": [
"fabric-rendering-data-attachment-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -25,5 +25,8 @@
"description": "Hooks for registering fluid renders.",
"mixins": [
"fabric-rendering-fluids-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -26,5 +26,8 @@
"fabric-api-base": "*",
"fabric-rendering-v1": "*"
},
"description": "Hooks and registries for rendering-related things."
"description": "Hooks and registries for rendering-related things.",
"custom": {
"fabric-api:module-lifecycle": "deprecated"
}
}

View file

@ -22,5 +22,8 @@
"description": "Hooks and registries for rendering-related things.",
"mixins": [
"fabric-rendering-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -21,5 +21,8 @@
"description": "Asset and data resource loading.",
"mixins": [
"fabric-resource-loader-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -23,5 +23,8 @@
"description": "Hooks for tags.",
"mixins": [
"fabric-tag-extensions-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -22,5 +22,8 @@
"description": "Hooks for texture loading and registration.",
"mixins": [
"fabric-textures-v0.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -28,5 +28,8 @@
"description": "Dynamic atttributes for tools.",
"mixins": [
"fabric-tool-attribute-api-v1.mixins.json"
]
],
"custom": {
"fabric-api:module-lifecycle": "stable"
}
}

View file

@ -0,0 +1,61 @@
import groovy.json.JsonSlurper
/*
* This buildscript contains tasks related to the validation of each module in fabric api.
*
* Right now this task verifies each Fabric API module has a module lifecycle specified.
* More functionality will probably be added in the future.
*/
subprojects {
// Create the task
task validateModules(type: ValidateModuleTask)
}
/**
* Verifies that each module has the required custom values for module lifecycle in it's FMJ.
*
* <p>Example:
* <pre>{@code
* "custom": {
* "fabric-api:module-lifecycle": "stable"
* }
* }</pre>
*/
class ValidateModuleTask extends DefaultTask {
ValidateModuleTask() {
group = "verification"
// Hook up validation to check task
project.tasks.check.dependsOn(this)
}
@TaskAction
void validate() {
def json = new JsonSlurper().parse(project.file("src/main/resources/fabric.mod.json") as File) as Map<String, Map<String, String>>;
if (json.custom == null) {
throw new GradleException("Module ${project} does not have a custom value containing module lifecycle!")
}
def moduleLifecycle = json.custom.get("fabric-api:module-lifecycle")
if (moduleLifecycle == null) {
throw new GradleException("Module ${project} does not have module lifecycle in custom values!")
}
if (!moduleLifecycle instanceof String) {
throw new GradleException("Module ${project} has an invalid module lifecycle value. The value must be a string but read a ${moduleLifecycle.class}")
}
// Validate the lifecycle value
switch (moduleLifecycle) {
case "stable":
case "experimental":
case "deprecated":
break;
default:
throw new GradleException("Module ${project} has an invalid module lifecycle ${json.custom.get('fabric-api:module-lifecycle')}");
}
}
}

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View file

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

192
gradlew.bat vendored
View file

@ -1,103 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega