Skip to content

Commit

Permalink
chore(deps): gradle 8.7
Browse files Browse the repository at this point in the history
resolve deprecation warnings and handle added methods
  • Loading branch information
zml2008 committed Apr 7, 2024
1 parent 3c5ba61 commit 430fbaa
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 24 deletions.
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ subprojects {

withType(JavaCompile::class).configureEach {
options.compilerArgs.add("-Xlint:-processing")

doFirst {
if (javaCompiler.get().metadata.languageVersion >= JavaLanguageVersion.of(21)) {
options.compilerArgs.add("-Xlint:-this-escape")
}
}
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 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.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ 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.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
*/
package org.spongepowered.gradle.vanilla.internal.worker;

import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;

import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -102,7 +100,8 @@ private FileSystem zipFile(final String external) throws IOException {
};
}

public interface VanillaGradleBytecodeProvider extends IBytecodeProvider, AutoCloseable {
@SuppressWarnings("deprecation")
public interface VanillaGradleBytecodeProvider extends org.jetbrains.java.decompiler.main.extern.IBytecodeProvider, AutoCloseable {

void setBytecode(final String external, final String internal, final byte[] bytes) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void execute() {
// Decompile
final File input = params.getInputJar().get().getAsFile();
try (final Decompilation.VanillaGradleBytecodeProvider bytecode = Decompilation.bytecodeFromJar()) {
@SuppressWarnings("deprecation")
final Fernflower decompiler = new Fernflower(
bytecode,
new LineMappingResultSaver(input.getAbsolutePath(), params.getOutputJar().get().getAsFile(), bytecode),
Expand All @@ -106,8 +107,8 @@ public void execute() {
decompiler.clearContext();
System.gc();
}
} catch (final IOException e) {
e.printStackTrace();
} catch (final IOException ex) {
JarDecompileWorker.LOGGER.error("Failed to decompile {}:", params.getInputJar().get().getAsFile(), ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.util.ConfigureUtil;
import org.spongepowered.gradle.vanilla.MinecraftExtension;
import org.spongepowered.gradle.vanilla.internal.model.VersionClassifier;
import org.spongepowered.gradle.vanilla.internal.model.VersionDescriptor;
Expand Down Expand Up @@ -263,7 +262,7 @@ public RunConfigurationContainer getRuns() {
@Override
@SuppressWarnings("rawtypes")
public void runs(@DelegatesTo(value = RunConfigurationContainer.class, strategy = Closure.DELEGATE_FIRST) final Closure run) {
ConfigureUtil.configure(run, this.runConfigurations);
this.runConfigurations.configure(run);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.ProjectEvaluationListener;
import org.gradle.api.ProjectState;
import org.gradle.api.Task;
import org.gradle.api.artifacts.ModuleVersionSelector;
import org.gradle.api.artifacts.ResolutionStrategy;
Expand All @@ -44,6 +46,7 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.build.event.BuildEventsListenerRegistry;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.gradle.vanilla.MinecraftExtension;
import org.spongepowered.gradle.vanilla.internal.Constants;
import org.spongepowered.gradle.vanilla.internal.MinecraftExtensionImpl;
Expand Down Expand Up @@ -281,10 +284,22 @@ private void applyToSettings(final Settings settings) {
// Common handling //

private void registerPostTaskListener(final Provider<MinecraftProviderService> service, final Gradle gradle) {
gradle.getTaskGraph().afterTask(new Action<Task>() {
gradle.addProjectEvaluationListener(new ProjectEvaluationListener() {
@Override
public void execute(final Task task) {
service.get().dropState();
public void beforeEvaluate(final @NotNull Project project) {}

@Override
public void afterEvaluate(final Project project, final ProjectState state) {
if (state.getFailure() != null) return;
project.getTasks().configureEach(task -> {
task.doLast(new Action<Task>() {
@Override
public void execute(final Task task) {
task.getLogger().info("Dropping VG resolver state on thread '{}' (task doLast action)", Thread.currentThread().getName());
service.get().dropState();
}
});
});
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of VanillaGradle, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.gradle.vanilla.internal.util;

import groovy.lang.Closure;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.internal.NamedDomainObjectContainerConfigureDelegate;

public final class GradleCompat {

private static final boolean HAS_ORG_GRADLE_UTIL_INTERNAL_CONFIGUREUTIL;
static {
boolean hasNewConfigureUtil;
try {
Class.forName("org.gradle.util.internal.ConfigureUtil");
hasNewConfigureUtil = true;
} catch (final ClassNotFoundException ex) {
hasNewConfigureUtil = false;
}
HAS_ORG_GRADLE_UTIL_INTERNAL_CONFIGUREUTIL = hasNewConfigureUtil;
}

private GradleCompat() {
}

@SuppressWarnings({"rawtypes", "deprecation"})
public static <T extends NamedDomainObjectContainer<?>> T configureSelf(final T configureTarget, final Closure configureClosure) {
// TODO: This uses internal API, see if there's a more 'public' way to do this
if (HAS_ORG_GRADLE_UTIL_INTERNAL_CONFIGUREUTIL) {
return org.gradle.util.internal.ConfigureUtil.configureSelf(configureClosure, configureTarget, new NamedDomainObjectContainerConfigureDelegate(configureClosure, configureTarget));
} else {
return org.gradle.util.ConfigureUtil.configureSelf(configureClosure, configureTarget, new NamedDomainObjectContainerConfigureDelegate(configureClosure, configureTarget));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.Spec;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.util.ConfigureUtil;
import org.spongepowered.gradle.vanilla.internal.MinecraftExtensionImpl;
import org.spongepowered.gradle.vanilla.internal.model.Argument;
import org.spongepowered.gradle.vanilla.internal.model.Arguments;
import org.spongepowered.gradle.vanilla.internal.model.JavaRuntimeVersion;
import org.spongepowered.gradle.vanilla.internal.model.VersionDescriptor;
import org.spongepowered.gradle.vanilla.internal.model.rule.RuleContext;
import org.spongepowered.gradle.vanilla.internal.util.GradleCompat;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -63,6 +63,7 @@
import javax.inject.Inject;

public class RunConfigurationContainer implements NamedDomainObjectContainer<RunConfiguration> {

private final NamedDomainObjectContainer<RunConfiguration> delegate;
private final MinecraftExtensionImpl extension;

Expand Down Expand Up @@ -245,8 +246,7 @@ public RunConfiguration create(final String name, final Action<? super RunConfig
@Override
@SuppressWarnings("rawtypes")
public NamedDomainObjectContainer<RunConfiguration> configure(final Closure configureClosure) {
// TODO: This uses internal API, see if there's a more 'public' way to do this
return ConfigureUtil.configureSelf(configureClosure, this, new NamedDomainObjectContainerConfigureDelegate(configureClosure, this));
return GradleCompat.configureSelf(this, configureClosure);
}

@Override
Expand Down Expand Up @@ -403,6 +403,11 @@ public <S extends RunConfiguration> NamedDomainObjectSet<S> withType(final Class
return this.delegate.withType(type);
}

@Override
public NamedDomainObjectSet<RunConfiguration> named(Spec<String> nameFilter) {
return this.delegate.named(nameFilter);
}

@Override
public <S extends RunConfiguration> DomainObjectCollection<S> withType(final Class<S> type, final Action<? super S> configureAction) {
return this.delegate.withType(type, configureAction);
Expand Down

0 comments on commit 430fbaa

Please sign in to comment.