mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Some gradle deprecation fixes (#4308)
This commit is contained in:
parent
b3e1e3dddf
commit
c6364727a0
3 changed files with 49 additions and 17 deletions
|
@ -7,7 +7,7 @@ plugins {
|
|||
id "fabric-loom" version "1.9.2" apply false
|
||||
id "com.diffplug.spotless" version "6.20.0"
|
||||
id "org.ajoberstar.grgit" version "5.2.2"
|
||||
id "me.modmuss50.remotesign" version "0.4.0" apply false
|
||||
id "me.modmuss50.remotesign" version "0.5.0" apply false
|
||||
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ javadoc {
|
|||
|
||||
classpath = files(sourceSets.main.compileClasspath, sourceSets.client.compileClasspath)
|
||||
include("**/api/**")
|
||||
failOnError true
|
||||
failOnError = true
|
||||
}
|
||||
|
||||
tasks.register('javadocJar', Jar) {
|
||||
|
|
|
@ -13,7 +13,7 @@ subprojects {
|
|||
}
|
||||
|
||||
// Create the task
|
||||
task validateModules(type: ValidateModuleTask)
|
||||
tasks.register("validateModules", ValidateModuleTask)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,38 +26,63 @@ subprojects {
|
|||
* }
|
||||
* }</pre>
|
||||
*/
|
||||
class ValidateModuleTask extends DefaultTask {
|
||||
abstract class ValidateModuleTask extends DefaultTask {
|
||||
@InputFile
|
||||
@Optional
|
||||
abstract RegularFileProperty getFmj()
|
||||
|
||||
@InputFile
|
||||
@Optional
|
||||
abstract RegularFileProperty getClientFmj()
|
||||
|
||||
@Input
|
||||
abstract Property<String> getProjectName()
|
||||
|
||||
@Input
|
||||
abstract Property<String> getProjectPath()
|
||||
|
||||
@Input
|
||||
abstract Property<String> getLoaderVersion()
|
||||
|
||||
ValidateModuleTask() {
|
||||
group = "verification"
|
||||
|
||||
// Hook up validation to check task
|
||||
project.tasks.check.dependsOn(this)
|
||||
|
||||
fmj.set(project.file("src/main/resources/fabric.mod.json"))
|
||||
clientFmj.set(project.file("src/client/resources/fabric.mod.json"))
|
||||
|
||||
projectName.set(project.name)
|
||||
projectPath.set(project.path)
|
||||
loaderVersion.set(project.loader_version)
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void validate() {
|
||||
def clientOnlyMod = false
|
||||
def file = (project.file("src/main/resources/fabric.mod.json") as File)
|
||||
|
||||
def file = fmj.get().asFile
|
||||
|
||||
if (!file.exists()) {
|
||||
file = (project.file("src/client/resources/fabric.mod.json") as File)
|
||||
file = clientFmj.get().asFile
|
||||
clientOnlyMod = true
|
||||
}
|
||||
|
||||
def json = new JsonSlurper().parse(file)
|
||||
|
||||
if (json.custom == null) {
|
||||
throw new GradleException("Module ${project} does not have a custom value containing module lifecycle!")
|
||||
throw new GradleException("Module ${projectName.get()} 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!")
|
||||
throw new GradleException("Module ${projectName.get()} 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}")
|
||||
throw new GradleException("Module ${projectName.get()} has an invalid module lifecycle value. The value must be a string but read a ${moduleLifecycle.class}")
|
||||
}
|
||||
|
||||
// Validate the lifecycle value
|
||||
|
@ -66,20 +91,20 @@ class ValidateModuleTask extends DefaultTask {
|
|||
case "experimental":
|
||||
break
|
||||
case "deprecated":
|
||||
if (!project.path.startsWith(":deprecated")) {
|
||||
throw new GradleException("Deprecated module ${project} must be in the deprecated sub directory.")
|
||||
if (!projectPath.get().startsWith(":deprecated")) {
|
||||
throw new GradleException("Deprecated module ${projectName.get()} must be in the deprecated sub directory.")
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new GradleException("Module ${project} has an invalid module lifecycle ${json.custom.get('fabric-api:module-lifecycle')}")
|
||||
throw new GradleException("Module ${projectName.get()} has an invalid module lifecycle ${json.custom.get('fabric-api:module-lifecycle')}")
|
||||
}
|
||||
|
||||
if (json.depends == null) {
|
||||
throw new GradleException("Module ${project} does not have a depends value!")
|
||||
throw new GradleException("Module ${projectName.get()} does not have a depends value!")
|
||||
}
|
||||
|
||||
if (json.depends.fabricloader != ">=${project.loader_version}") {
|
||||
throw new GradleException("Module ${project} does not have a valid fabricloader value! Got \"${json.depends.fabricloader}\" but expected \">=${project.loader_version}\"")
|
||||
if (json.depends.fabricloader != ">=${loaderVersion.get()}") {
|
||||
throw new GradleException("Module ${projectName.get()} does not have a valid fabricloader value! Got \"${json.depends.fabricloader}\" but expected \">=${project.loader_version}\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,13 @@ for (def sourceSet in [
|
|||
clean.dependsOn cleanTask
|
||||
}
|
||||
|
||||
class GenerateImplPackageInfos extends DefaultTask {
|
||||
abstract class GenerateImplPackageInfos extends DefaultTask {
|
||||
@InputFile
|
||||
File header
|
||||
|
||||
@Input
|
||||
abstract Property<String> getProjectName()
|
||||
|
||||
@SkipWhenEmpty
|
||||
@InputDirectory
|
||||
final DirectoryProperty sourceRoot = project.objects.directoryProperty()
|
||||
|
@ -38,6 +41,10 @@ class GenerateImplPackageInfos extends DefaultTask {
|
|||
@OutputDirectory
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
GenerateImplPackageInfos() {
|
||||
projectName.set(project.name)
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
def output = outputDir.get().asFile.toPath()
|
||||
|
@ -66,7 +73,7 @@ class GenerateImplPackageInfos extends DefaultTask {
|
|||
def packageName = relativePath.toString().replace(File.separator, '.')
|
||||
it.write("""$headerText
|
||||
|/**
|
||||
| * Implementation code for ${project.name}.
|
||||
| * Implementation code for ${projectName.get()}.
|
||||
| */
|
||||
|@ApiStatus.Internal
|
||||
|package $packageName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue