diff --git a/annotation-processor/build.gradle b/annotation-processor/build.gradle index 7e6da96d08f..c6466921c37 100644 --- a/annotation-processor/build.gradle +++ b/annotation-processor/build.gradle @@ -2,8 +2,8 @@ plugins { id 'java' } -group 'mekanism.annotation-processor' -version '2.0.0' +group = 'mekanism.annotation-processor' +version = '2.0.0' java.toolchain.languageVersion = JavaLanguageVersion.of("${java_version}") repositories { @@ -24,5 +24,5 @@ dependencies { implementation('org.openzen.zencode:JavaAnnotations:0.3.8') //Version of GSON used by vanilla (and thus packed and already downloaded) implementation('com.google.code.gson:gson:2.10.1') - implementation('com.squareup:javapoet:1.13.0') + implementation('com.palantir.javapoet:javapoet:0.6.0') } diff --git a/annotation-processor/src/main/java/mekanism/ComputerMethodProcessor.java b/annotation-processor/src/main/java/mekanism/ComputerMethodProcessor.java index d2c0dec48e9..edbffc87a80 100644 --- a/annotation-processor/src/main/java/mekanism/ComputerMethodProcessor.java +++ b/annotation-processor/src/main/java/mekanism/ComputerMethodProcessor.java @@ -1,6 +1,6 @@ package mekanism; -import com.squareup.javapoet.JavaFile; +import com.palantir.javapoet.JavaFile; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; diff --git a/annotation-processor/src/main/java/mekanism/MekAnnotationProcessors.java b/annotation-processor/src/main/java/mekanism/MekAnnotationProcessors.java index 5236af006a4..ad1e48cedbb 100644 --- a/annotation-processor/src/main/java/mekanism/MekAnnotationProcessors.java +++ b/annotation-processor/src/main/java/mekanism/MekAnnotationProcessors.java @@ -1,6 +1,6 @@ package mekanism; -import com.squareup.javapoet.ClassName; +import com.palantir.javapoet.ClassName; public class MekAnnotationProcessors { diff --git a/annotation-processor/src/main/java/mekanism/MethodFactoryProcessor.java b/annotation-processor/src/main/java/mekanism/MethodFactoryProcessor.java index cceaff0d691..cf98fb28cd5 100644 --- a/annotation-processor/src/main/java/mekanism/MethodFactoryProcessor.java +++ b/annotation-processor/src/main/java/mekanism/MethodFactoryProcessor.java @@ -1,10 +1,10 @@ package mekanism; -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.CodeBlock; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.TypeSpec; +import com.palantir.javapoet.ClassName; +import com.palantir.javapoet.CodeBlock; +import com.palantir.javapoet.JavaFile; +import com.palantir.javapoet.MethodSpec; +import com.palantir.javapoet.TypeSpec; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; @@ -56,6 +56,7 @@ public boolean process(Set annotatedTypes, RoundEnvironme TypeSpec.Builder registryType = TypeSpec.classBuilder("ComputerMethodRegistry_" + mekModule) .addModifiers(Modifier.PUBLIC) .addSuperinterface(methodRegistryInterface); + boolean hasOriginatingElements = false; //this should only ever be 1 annotation for (Element element : roundEnvironment.getElementsAnnotatedWithAny(annotatedTypes.toArray(new TypeElement[0]))) { @@ -73,12 +74,13 @@ public boolean process(Set annotatedTypes, RoundEnvironme continue; } registryType.addOriginatingElement(factoryTypeEl); + hasOriginatingElements = true; AnnotationHelper helper = new AnnotationHelper(processingEnv.getElementUtils(), annotationMirror); addHandlerToRegistry((TypeElement) typeUtils().asElement(helper.getClassValue("target")), ClassName.get(factoryTypeEl)); } } - if (!registryType.originatingElements.isEmpty()) { + if (hasOriginatingElements) { registryType.addMethod(registryInit.build()); TypeSpec registrySpec = registryType.build(); String packageName = "mekanism.generated." + mekModule; @@ -88,7 +90,7 @@ public boolean process(Set annotatedTypes, RoundEnvironme throw new RuntimeException(e); } try (Writer serviceWriter = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/services/" + methodRegistryInterface.canonicalName()).openWriter()) { - serviceWriter.write(packageName + "." + registrySpec.name); + serviceWriter.write(packageName + "." + registrySpec.name()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/annotation-processor/src/main/java/mekanism/builder/ComputerHandlerBuilder.java b/annotation-processor/src/main/java/mekanism/builder/ComputerHandlerBuilder.java index dcfc6309f80..a5dae93f4fe 100644 --- a/annotation-processor/src/main/java/mekanism/builder/ComputerHandlerBuilder.java +++ b/annotation-processor/src/main/java/mekanism/builder/ComputerHandlerBuilder.java @@ -1,15 +1,15 @@ package mekanism.builder; -import com.squareup.javapoet.AnnotationSpec; -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.CodeBlock; -import com.squareup.javapoet.FieldSpec; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.ParameterSpec; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; +import com.palantir.javapoet.AnnotationSpec; +import com.palantir.javapoet.ClassName; +import com.palantir.javapoet.CodeBlock; +import com.palantir.javapoet.FieldSpec; +import com.palantir.javapoet.JavaFile; +import com.palantir.javapoet.MethodSpec; +import com.palantir.javapoet.ParameterSpec; +import com.palantir.javapoet.ParameterizedTypeName; +import com.palantir.javapoet.TypeName; +import com.palantir.javapoet.TypeSpec; import java.lang.invoke.MethodHandle; import java.lang.invoke.WrongMethodTypeException; import java.util.ArrayList; @@ -451,7 +451,7 @@ private MethodSpec getMethodProxy(String annotatedName, ExecutableElement execut .returns(returnType) .beginControlFlow("try") //invoke the method handle - .addStatement("return ($T)$N.invokeExact($L)", returnType, methodHandleField, proxyParams.stream().map(param -> param.name).collect(Collectors.joining(", "))) + .addStatement("return ($T)$N.invokeExact($L)", returnType, methodHandleField, proxyParams.stream().map(ParameterSpec::name).collect(Collectors.joining(", "))) //catch a failing method handle (throw as RuntimeException) .nextControlFlow("catch ($T wmte)", WrongMethodTypeException.class) .addStatement("throw new $T($S, wmte)", RuntimeException.class, "Method not bound correctly") diff --git a/annotation-processor/src/main/java/mekanism/visitors/AnnotationHelper.java b/annotation-processor/src/main/java/mekanism/visitors/AnnotationHelper.java index 954644823d0..37dfcef06b6 100644 --- a/annotation-processor/src/main/java/mekanism/visitors/AnnotationHelper.java +++ b/annotation-processor/src/main/java/mekanism/visitors/AnnotationHelper.java @@ -1,6 +1,6 @@ package mekanism.visitors; -import com.squareup.javapoet.CodeBlock; +import com.palantir.javapoet.CodeBlock; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/annotation-processor/src/main/java/mekanism/visitors/AnnotationValueToLiteralVisitor.java b/annotation-processor/src/main/java/mekanism/visitors/AnnotationValueToLiteralVisitor.java index 35ebd74cabb..9f05c723a8d 100644 --- a/annotation-processor/src/main/java/mekanism/visitors/AnnotationValueToLiteralVisitor.java +++ b/annotation-processor/src/main/java/mekanism/visitors/AnnotationValueToLiteralVisitor.java @@ -1,7 +1,7 @@ package mekanism.visitors; -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.CodeBlock; +import com.palantir.javapoet.ClassName; +import com.palantir.javapoet.CodeBlock; import java.util.List; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; diff --git a/annotation-processor/src/main/java/mekanism/visitors/ParamToHelperMapper.java b/annotation-processor/src/main/java/mekanism/visitors/ParamToHelperMapper.java index 1aa30f0e604..716e28d84e4 100644 --- a/annotation-processor/src/main/java/mekanism/visitors/ParamToHelperMapper.java +++ b/annotation-processor/src/main/java/mekanism/visitors/ParamToHelperMapper.java @@ -1,8 +1,8 @@ package mekanism.visitors; -import com.squareup.javapoet.ClassName; -import com.squareup.javapoet.CodeBlock; -import com.squareup.javapoet.ParameterSpec; +import com.palantir.javapoet.ClassName; +import com.palantir.javapoet.CodeBlock; +import com.palantir.javapoet.ParameterSpec; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; diff --git a/build.gradle b/build.gradle index 1331099498d..fd84b2f5b20 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ import java.util.function.Consumer plugins { id('org.ajoberstar.grgit.service')//Version declared in buildSrc - id('net.darkhax.curseforgegradle') version('1.1.25') + id('net.darkhax.curseforgegradle') version('1.1.26') id('com.modrinth.minotaur') version('2.8.7') id('java') id('eclipse') @@ -23,9 +23,9 @@ plugins { id('net.neoforged.gradle.userdev') version('7.0.154')//https://projects.neoforged.net/neoforged/neogradle } -tasks.named('wrapper', Wrapper).configure { +tasks.named('wrapper', Wrapper) { //Define wrapper values here so as to not have to always do so when updating gradlew.properties - gradleVersion = '8.10' + gradleVersion = '8.12' distributionType = Wrapper.DistributionType.ALL } @@ -184,43 +184,42 @@ for (String name : secondaryModules) { } def setupTasks(SourceSet sourceSet) { - def compileTask = tasks.named(sourceSet.compileJavaTaskName, JavaCompile) + def compileTask = tasks.named(sourceSet.compileJavaTaskName, JavaCompile) { + //Configure specific compile tasks to have the proper annotation processor info + setGroup('compile') + options.annotationProcessorPath = configurations.annotationProcessor + options.compilerArgs.addAll([ + "-AmekanismModule=mekanism${sourceSet == sourceSets.main ? '' : sourceSet.name}",//annotation processor param + '-parameters' + ]) + } //Set the various variables/settings for the different process resources tasks - tasks.named(sourceSet.processResourcesTaskName, ProcessResources).configure { ProcessResources process -> - process.setGroup('process resources') - process.duplicatesStrategy(DuplicatesStrategy.FAIL) + tasks.named(sourceSet.processResourcesTaskName, ProcessResources) { + setGroup('process resources') + duplicatesStrategy = DuplicatesStrategy.FAIL var versionProperties = ['version': mod_version, 'mc_version': minecraft_version_range, 'forge_version': forge_version_range, 'loader_version': loader_version_range, 'jei_version': jei_version_range] //Mark the properties as inputs so that when they change things update - process.inputs.properties(versionProperties) - process.filesMatching('META-INF/neoforge.mods.toml') { expand(versionProperties) } - process.from("${projectDir}") { include('logo.png') } + inputs.properties(versionProperties) + filesMatching('META-INF/neoforge.mods.toml') { expand(versionProperties) } + from("${projectDir}") { include('logo.png') } //Depend on the compile task so that we can map the computer methods as needed - process.dependsOn(compileTask) + dependsOn(compileTask) def files = fileTree(dir: outputs.files.asPath, includes: ['**/*.json', '**/*.mcmeta']) - process.doLast { + doLast { for (def file : files) { file.text = JsonOutput.toJson(new JsonSlurper().parse(file)) } } } - tasks.named(sourceSet.compileJavaTaskName, JavaCompile).configure { setGroup('compile') } + tasks.named(sourceSet.compileJavaTaskName, JavaCompile) { setGroup('compile') } for (String extraType : extraTypes) { def extraSourceSet = getExtraSourceSet(sourceSet, extraType).get() - tasks.named(extraSourceSet.processResourcesTaskName, ProcessResources).configure { + tasks.named(extraSourceSet.processResourcesTaskName, ProcessResources) { setGroup('process resources') dependsOn(compileTask) } - tasks.named(extraSourceSet.compileJavaTaskName, JavaCompile).configure { setGroup('compile') } - } - //Configure specific compile tasks to have the proper annotation processor info - compileTask.configure { JavaCompile task -> - setGroup('compile') - task.options.annotationProcessorPath = configurations.annotationProcessor - task.options.compilerArgs.addAll([ - "-AmekanismModule=mekanism${sourceSet == sourceSets.main ? '' : sourceSet.name}",//annotation processor param - '-parameters' - ]) + tasks.named(extraSourceSet.compileJavaTaskName, JavaCompile) { setGroup('compile') } } } @@ -342,9 +341,9 @@ repositories { RepositoryHandler handler -> exclusiveRepo(handler, 'https://maven.parchmentmc.org/', 'org.parchmentmc.data') } -tasks.named('test').configure { +tasks.named('test') { //Disable builtin test task as we use and build uses testJunit so there is no point in having it also attempt to run an empty test task - enabled(false) + enabled = false } dependencies { @@ -438,31 +437,31 @@ def getManifestAttributes(String title) { ] } -tasks.named('jar', Jar).configure { Jar jar -> - jar.duplicatesStrategy(DuplicatesStrategy.FAIL) - jar.from([sourceSets.api.output, sourceSets.main.output]) - jar.exclude('crafttweaker_parameter_names.json') - jar.manifest.attributes(getManifestAttributes('Mekanism')) +tasks.named('jar', Jar) { + duplicatesStrategy = DuplicatesStrategy.FAIL + from([sourceSets.api.output, sourceSets.main.output]) + exclude('crafttweaker_parameter_names.json') + manifest.attributes(getManifestAttributes('Mekanism')) } -tasks.named('sourcesJar', Jar).configure { Jar jar -> +tasks.named('sourcesJar', Jar) { dependsOn(classes, apiClasses, additionsClasses, generatorsClasses, toolsClasses) - jar.duplicatesStrategy(DuplicatesStrategy.FAIL) + duplicatesStrategy = DuplicatesStrategy.FAIL //Note: Already contains main source set's sources by default - jar.from(sourceSets.api.allJava, sourceSets.additions.allJava, sourceSets.generators.allJava, sourceSets.tools.allJava) - jar.manifest.attributes(getManifestAttributes('Mekanism')) + from(sourceSets.api.allJava, sourceSets.additions.allJava, sourceSets.generators.allJava, sourceSets.tools.allJava) + manifest.attributes(getManifestAttributes('Mekanism')) } def secondaryJar(SourceSet sourceSet, String title) { - return tasks.register(sourceSet.jarTaskName, Jar, { - duplicatesStrategy(DuplicatesStrategy.FAIL) + return tasks.register(sourceSet.jarTaskName, Jar) { + duplicatesStrategy = DuplicatesStrategy.FAIL archiveClassifier.set(sourceSet.name) from(sourceSet.output) if (!title.isEmpty()) { archiveFileName.set("${title}-${project.version}.jar") } manifest.attributes(getManifestAttributes(title.isEmpty() ? 'Mekanism' : title)) - }) + } } def apiJar = secondaryJar(sourceSets.api, '') @@ -470,7 +469,7 @@ def additionsJar = secondaryJar(sourceSets.additions, 'MekanismAdditions') def generatorsJar = secondaryJar(sourceSets.generators, 'MekanismGenerators') def toolsJar = secondaryJar(sourceSets.tools, 'MekanismTools') -def mergeModuleResources = tasks.register('mergeModuleResources', MergeModuleResources, { +def mergeModuleResources = tasks.register('mergeModuleResources', MergeModuleResources) { dependsOn('classes', 'apiClasses', 'additionsClasses', 'generatorsClasses', 'toolsClasses') mustRunAfter('clean') //Note: Get the resources from the output of process resources, so that any expands that need to happen we know have already happened @@ -485,11 +484,11 @@ def mergeModuleResources = tasks.register('mergeModuleResources', MergeModuleRes } //Only look at generated service files as a restriction for our input annotationGenerated = annotationGenerated.asFileTree.matching(serviceFilter) -}) +} -def allJar = tasks.register('allJar', AllJar, { +def allJar = tasks.register('allJar', AllJar) { dependsOn(mergeModuleResources) - duplicatesStrategy(DuplicatesStrategy.FAIL) + duplicatesStrategy = DuplicatesStrategy.FAIL archiveClassifier.set('all') manifest.attributes(getManifestAttributes('MekanismAll')) pathsToExclude.set(mergeModuleResources.flatMap(m -> m.pathsToExclude)) @@ -498,7 +497,7 @@ def allJar = tasks.register('allJar', AllJar, { for (String name : secondaryModules) { secondaryModuleOutputs += sourceSets.named(name).get().output } -}) +} tasks.withType(JavaCompile).configureEach({ options.encoding = 'UTF-8' @@ -603,7 +602,7 @@ outputChangelog.configure { OutputChangelog out -> if (System.getenv('CURSEFORGE_KEY') != null || project.hasProperty('curseforgeKey')) { logger.lifecycle('Enabling Curseforge config') - tasks.register('curseforge', TaskPublishCurseForge, { task -> + tasks.register('curseforge', TaskPublishCurseForge) { task -> dependsOn(outputChangelog) setGroup('publishing') setDescription('Upload Mekanism to CurseForge') @@ -655,7 +654,7 @@ if (System.getenv('CURSEFORGE_KEY') != null || project.hasProperty('curseforgeKe logger.quiet('https://www.curseforge.com/minecraft/mc-mods/mekanism-generators/files/{}', (Object) generatorsCfUpload.curseFileId) logger.quiet('https://www.curseforge.com/minecraft/mc-mods/mekanism-tools/files/{}', (Object) toolsCfUpload.curseFileId) } - }) + } } void setGenericCurseArtifactData(UploadArtifact artifact, Provider changelog) { @@ -679,7 +678,7 @@ if (System.getenv('MODRINTH_TOKEN') != null || project.hasProperty('modrinthToke def additionsModrinth = createSecondaryModrinthUpload('additions', 'a6F3uASn', additionsJar) def generatorsModrinth = createSecondaryModrinthUpload('generators', 'OFVYKsAk', generatorsJar) def toolsModrinth = createSecondaryModrinthUpload('tools', 'tqQpq1lt', toolsJar) - tasks.named('modrinth').configure { + tasks.named('modrinth') { dependsOn(jar, apiJar, outputChangelog) finalizedBy(additionsModrinth, generatorsModrinth, toolsModrinth) notCompatibleWithConfigurationCache('Not yet compatible')//TODO: Remove when possible @@ -725,7 +724,7 @@ if (System.getenv('MODRINTH_TOKEN') != null || project.hasProperty('modrinthToke } def createSecondaryModrinthUpload(String output, String targetProjectId, TaskProvider sourceSetJar) { - return tasks.register("${output}Modrinth", TaskModrinthUpload, { + return tasks.register("${output}Modrinth", TaskModrinthUpload) { setGroup('publishing') setDescription("Upload Mekanism ${output} to Modrinth") dependsOn(tasks.named('modrinth'), sourceSetJar) @@ -747,5 +746,5 @@ def createSecondaryModrinthUpload(String output, String targetProjectId, TaskPro } logger.lifecycle('Updated Modrinth extension') } - }) + } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 04ace16d23c..8d9f9a100ba 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -3,5 +3,5 @@ repositories { } dependencies { - implementation('org.ajoberstar.grgit:grgit-gradle:5.2.2') + implementation('org.ajoberstar.grgit:grgit-gradle:5.3.0') } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 45b79e4ffef..1cdec16a8bb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,8 +24,8 @@ junit_version=5.11.0 jqwik_version=1.9.0 #NeoGradle Settings -neogradle.subsystems.parchment.minecraftVersion=1.21 -neogradle.subsystems.parchment.mappingsVersion=2024.07.28 +neogradle.subsystems.parchment.minecraftVersion=1.21.1 +neogradle.subsystems.parchment.mappingsVersion=2024.11.17 neogradle.subsystems.conventions.sourcesets.enabled=false #misc settings diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 66cd5a0e49b..e0fd02028bc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d6b1..f3b75f3b0d4 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/settings.gradle b/settings.gradle index d70d429cdf4..00427c2a663 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,7 +9,7 @@ pluginManagement { } plugins { - id('org.gradle.toolchains.foojay-resolver-convention') version('0.8.0') + id('org.gradle.toolchains.foojay-resolver-convention') version('0.9.0') } include('annotation-processor') \ No newline at end of file