Skip to content

Commit

Permalink
fix: don't expose loom to plugin consumers
Browse files Browse the repository at this point in the history
(use the version of loom installed by the buildscript)
  • Loading branch information
marcus8448 committed Sep 7, 2024
1 parent b212a8e commit d21d83b
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
uses: gradle/actions/wrapper-validation@v4

- name: Setup JDK 17
uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pluginManagement {
Then, add the following to your `build.gradle.kts` file:
```kotlin
plugins {
id("dev.galacticraft.mojarn") version("0.2.0+7")
id("dev.galacticraft.mojarn") version("0.4.1+11")
}
```

Expand Down
12 changes: 2 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
plugins {
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish") version("1.2.1")
id("com.gradle.plugin-publish") version("1.2.2")
id("org.cadixdev.licenser") version("0.6.1")
}

Expand All @@ -35,7 +35,6 @@ val pluginVersion = project.property("plugin.version").toString()

val loomVersion = project.property("loom.version").toString()
val mappingIoVersion = project.property("mapping-io.version").toString()
val junitVersion = project.property("junit.version").toString()

group = pluginGroup
version = "$pluginVersion+${System.getenv("GITHUB_RUN_NUMBER") ?: "0"}"
Expand Down Expand Up @@ -65,11 +64,8 @@ repositories {

dependencies {
implementation(gradleApi())
implementation("net.fabricmc:fabric-loom:${loomVersion}") { isTransitive = false }
compileOnly("net.fabricmc:fabric-loom:${loomVersion}")
implementation("net.fabricmc:mapping-io:${mappingIoVersion}")

testImplementation(platform("org.junit:junit-bom:${junitVersion}"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.withType<JavaCompile> {
Expand All @@ -81,10 +77,6 @@ tasks.withType<Jar> {
from("LICENSE")
}

tasks.test {
useJUnitPlatform()
}

tasks.javadoc {
options.encoding = "UTF-8"
}
Expand Down
5 changes: 2 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugin.group=dev.galacticraft
plugin.name=Mojarn
plugin.id=mojarn
plugin.description=Mixes official and yarn mappings for better argument names
plugin.version=0.4.0
plugin.version=0.4.1

loom.version=1.7.2
loom.version=1.7.3
mapping-io.version=0.6.1
junit.version=5.10.2
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionSha256Sum=5b9c5eb3f9fc2c94abaea57d90bd78747ca117ddbbf96c859d3741181a12bf2a
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
188 changes: 94 additions & 94 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
@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
@rem SPDX-License-Identifier: Apache-2.0
@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=.
@rem This is normally unused
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% equ 0 goto execute

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

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

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

: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% equ 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!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

: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
@rem SPDX-License-Identifier: Apache-2.0
@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=.
@rem This is normally unused
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% equ 0 goto execute

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

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

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

: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% equ 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!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
* A builder for a Mojarn mappings spec.
*/
public interface MojarnMappingsSpecBuilder {
/**
* Whether to name synthetic methods.
* @param nameSyntheticMethods whether to name synthetic methods
* @return this builder
* @see net.fabricmc.loom.api.mappings.layered.spec.MojangMappingsSpecBuilder#setNameSyntheticMembers(boolean)
*/
MojarnMappingsSpecBuilder nameSyntheticMethods(boolean nameSyntheticMethods);

/**
* Whether to remap arguments with class types.
* @param remapArguments whether to map arguments with class types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
import dev.galacticraft.mojarn.api.MojarnMappingsSpecBuilder;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.mappings.layered.spec.FileSpec;
import net.fabricmc.loom.configuration.providers.mappings.file.FileMappingsSpec;
import net.fabricmc.loom.configuration.providers.mappings.file.FileMappingsSpecBuilderImpl;
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec;
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec;
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpecBuilderImpl;
import org.gradle.api.Action;
import org.gradle.api.artifacts.Dependency;

Expand All @@ -53,9 +49,6 @@ public Dependency mappings(Object file, Action<? super MojarnMappingsSpecBuilder
FileMappingsSpecBuilderImpl fileBuilder = FileMappingsSpecBuilderImpl.builder(FileSpec.create(file));
if (builder.fileIsEnigma) fileBuilder.enigmaMappings();

FileMappingsSpec fileSpec = fileBuilder.build();
MojangMappingsSpec mojangSpec = MojangMappingsSpecBuilderImpl.builder().build();

return loom.layered(b -> b.addLayer(new MojarnMappingsSpec(new IntermediaryMappingsSpec(), mojangSpec, fileSpec, builder.remapArguments, builder.partialMatch, builder.skipDifferent, builder.skipCI, builder.mapVariables)));
return loom.layered(b -> b.addLayer(builder.build(fileBuilder.build())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
import net.fabricmc.loom.api.mappings.layered.spec.MappingsSpec;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public record MojarnMappingsSpec(@NotNull MappingsSpec<?> intermediary, @NotNull MappingsSpec<?> mojang, @NotNull MappingsSpec<?> yarn, boolean remapArguments, boolean partialMatch, boolean skipDifferent, boolean skipCI, boolean matchVariables) implements MappingsSpec<MojarnMappingsLayer> {
public record MojarnMappingsSpec(@NotNull MappingsSpec<?> intermediary, @NotNull MappingsSpec<?> mojang, @NotNull MappingsSpec<?> yarn, boolean remapArguments, boolean partialMatch, boolean skipDifferent, boolean matchVariables, boolean skipCI) implements MappingsSpec<MojarnMappingsLayer> {
@Override
public MojarnMappingsLayer createLayer(MappingContext context) {
return new MojarnMappingsLayer(this.intermediary.createLayer(context), this.mojang.createLayer(context), this.yarn.createLayer(context), this.remapArguments, this.partialMatch, this.skipDifferent, this.skipCI, this.matchVariables);
return new MojarnMappingsLayer(this.intermediary.createLayer(context), this.mojang.createLayer(context), this.yarn.createLayer(context), this.remapArguments, this.partialMatch, this.skipDifferent, this.matchVariables, this.skipCI);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,25 @@
package dev.galacticraft.mojarn.impl;

import dev.galacticraft.mojarn.api.MojarnMappingsSpecBuilder;
import net.fabricmc.loom.api.mappings.layered.spec.MappingsSpec;
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec;
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpecBuilderImpl;

public class MojarnMappingsSpecBuilderImpl implements MojarnMappingsSpecBuilder {
boolean nameSyntheticMethods = false;
boolean remapArguments = true;
boolean partialMatch = false;
boolean skipDifferent = false;
boolean mapVariables = true;
boolean skipCI = true;
boolean fileIsEnigma = false;

@Override
public MojarnMappingsSpecBuilder nameSyntheticMethods(boolean nameSyntheticMethods) {
this.nameSyntheticMethods = nameSyntheticMethods;
return this;
}

@Override
public MojarnMappingsSpecBuilder remapArguments(boolean remapArguments) {
this.remapArguments = remapArguments;
Expand Down Expand Up @@ -67,4 +77,19 @@ public MojarnMappingsSpecBuilder fileIsEnigma() {
this.fileIsEnigma = true;
return this;
}

public MojarnMappingsSpec build(MappingsSpec<?> intermediary, MappingsSpec<?> mojang, MappingsSpec<?> file) {
return new MojarnMappingsSpec(intermediary, mojang, file, this.remapArguments, this.partialMatch, this.skipDifferent, this.mapVariables, this.skipCI);
}

public MojarnMappingsSpec build(MappingsSpec<?> intermediary, MappingsSpec<?> file) {
MojangMappingsSpecBuilderImpl builder = MojangMappingsSpecBuilderImpl.builder();
builder.setNameSyntheticMembers(this.nameSyntheticMethods);

return this.build(intermediary, builder.build(), file);
}

public MojarnMappingsSpec build(MappingsSpec<?> file) {
return this.build(new IntermediaryMappingsSpec(), file);
}
}
4 changes: 4 additions & 0 deletions src/main/java/dev/galacticraft/mojarn/impl/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ApiStatus.Internal
package dev.galacticraft.mojarn.impl;

import org.jetbrains.annotations.ApiStatus;

0 comments on commit d21d83b

Please sign in to comment.