Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitversion.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gradlePlugin]
path = "renamer-gradle"
tag = "gradle"
69 changes: 25 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ plugins {
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'net.minecraftforge.licenser' version '1.0.1'
id 'net.minecraftforge.gradleutils' version '[2.3,2.4)'
id 'net.minecraftforge.gradleutils'
alias libs.plugins.gitversion
alias libs.plugins.changelog
alias libs.plugins.licenser
alias libs.plugins.shadow
}

gradleutils.displayName = 'Forge Auto Renaming Tool'
description = 'A command line tool to rename java class files'
group = 'net.minecraftforge'
version = gradleutils.getTagOffsetBranchVersion(null, 'master', 'HEAD')
version = gitversion.tagOffset
println "Version: $version"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
toolchain.languageVersion = JavaLanguageVersion.of(8)
withSourcesJar()
}

Expand All @@ -38,64 +40,43 @@ dependencies {
compileOnly(libs.nulls)
}

tasks.named('test', Test).configure {
tasks.named('test', Test) {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
}
}

tasks.named('jar', Jar).configure {
tasks.named('jar') {
manifest {
attributes('Main-Class': 'net.minecraftforge.fart.Main')
attributes([
'Specification-Title': 'ForgeAutoRenamingTool',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gradleutils.gitInfo.tag,
'Implementation-Title': 'ForgeAutoRenamingTool',
'Implementation-Version': project.version,
'Implementation-Vendor': 'Forge Development LLC'
'Specification-Title': 'ForgeAutoRenamingTool',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gitversion.info.tag,
'Implementation-Title': 'ForgeAutoRenamingTool',
'Implementation-Version': project.version,
'Implementation-Vendor': 'Forge Development LLC'
], 'net/minecraftforge/fart/')
}
}

tasks.named('shadowJar', ShadowJar).configure {
manifest {
attributes('Main-Class': 'net.minecraftforge.fart.Main')
attributes([
'Specification-Title': 'ForgeAutoRenamingTool',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gradleutils.gitInfo.tag,
'Implementation-Title': 'ForgeAutoRenamingTool',
'Implementation-Version': project.version,
'Implementation-Vendor': 'Forge Development LLC'
], 'net/minecraftforge/fart/')
}

tasks.named('shadowJar') {
minimize()

final List<String> relocations = [
'org.objectweb.asm',
'net.minecraftforge.srgutils',
'joptsimple'
]

relocations.each {
relocate it, "net.minecraftforge.fart.relocated.$it"
}

enableAutoRelocation = true
relocationPrefix = 'net.minecraftforge.fart.relocated'
// Rewrite JOpt's message files, so that help text is displayed nicely.
transform(PropertiesFileTransformer) {
paths = [ 'Messages.properties$' ]
keyTransformer = { key -> "net.minecraftforge.fart.relocated.$key".toString() }
}
}

tasks.named('assemble').configure {
tasks.named('assemble') {
dependsOn 'shadowJar'
}

tasks.named('compileJava', JavaCompile).configure {
tasks.named('compileJava', JavaCompile) {
options.encoding = 'UTF-8'
}

Expand All @@ -118,12 +99,12 @@ publishing {
description = 'A tool that renames java bytecode elements.'
url = 'https://github.com/MinecraftForge/ForgeAutoRenamingTool'

gradleutils.pom.setGitHubDetails(pom, 'ForgeAutoRenamingTool')
gradleutils.pom.addRemoteDetails(pom)

license gradleutils.pom.Licenses.LGPLv2_1
license gradleutils.pom.licenses.LGPLv2_1

developers {
developer gradleutils.pom.Developers.LexManos
developer gradleutils.pom.developers.LexManos
}
}
}
Expand Down
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.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 8 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || 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
Expand Down Expand Up @@ -112,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -203,15 +205,15 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
Expand Down
26 changes: 14 additions & 12 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@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 ##########################################################################
Expand Down Expand Up @@ -43,11 +45,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,22 +59,22 @@ 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

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
33 changes: 33 additions & 0 deletions renamer-gradle-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id 'java'
id 'maven-publish'
id 'net.minecraftforge.renamer'
}

group = 'net.minecraftforge'

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

// I dont know why this needs to be here and not in the settings.gradle
repositories {
mavenCentral()
maven { url = 'https://maven.minecraftforge.net' }
flatDir dirs: './libs'
}

dependencies {
compileOnly libs.log4j.api
}

publishing {
publications.register('mavenJava', MavenPublication) {
from components.java
}
}

renamer.rename(jar) {
map = files('libs/mappings_test-1.0.tsrg.gz')
}

renamer.mappings('test', '1.0')
renamer.rename(jar, 'jarRenameRemote')
2 changes: 2 additions & 0 deletions renamer-gradle-demo/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
../gradlew "$@"
1 change: 1 addition & 0 deletions renamer-gradle-demo/gradlew.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../gradlew.bat %*
Binary file added renamer-gradle-demo/libs/mappings_test-1.0.tsrg.gz
Binary file not shown.
29 changes: 29 additions & 0 deletions renamer-gradle-demo/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pluginManagement {
includeBuild '../renamer-gradle'

repositories {
mavenCentral()
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net' }
//mavenLocal()
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
id 'net.minecraftforge.gradleutils' version '3.3.13'
}

rootProject.name = 'renamer-gradle-demo'

dependencyResolutionManagement {
repositories {
mavenCentral()
maven gradleutils.forgeMaven
}

versionCatalogs.register('libs') {
version 'log4j', '2.19.0'
library 'log4j-api', 'org.apache.logging.log4j', 'log4j-api' versionRef 'log4j'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.minecraftforge.renamer.gradle.demo;

public class TestClass {
public static void main(String[] args) {
System.out.println(TestClass.class.getName());
}
}
Loading