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"
123 changes: 53 additions & 70 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,104 +1,87 @@
import org.gradle.api.plugins.jvm.JvmTestSuite
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer

plugins {
id 'java-library'
id 'jvm-test-suite'
id 'idea'
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)'
alias libs.plugins.gradleutils
alias libs.plugins.gitversion
alias libs.plugins.changelog
alias libs.plugins.licenser
alias libs.plugins.shadow
}

gradleutils.displayName = 'Forge Auto Renaming Tool' // 'Renamer'
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()
}

repositories {
mavenCentral()
maven gradleutils.forgeMaven
}

dependencies {
implementation(libs.jopt.simple)
api(libs.srgutils)
implementation(libs.bundles.asm)
testing {
suites.named('test', JvmTestSuite) {
useJUnitJupiter(libs.versions.junit)

testImplementation(libs.junit.api)
testRuntimeOnly(libs.bundles.junit.runtime)
testImplementation(libs.powermock)
dependencies {
implementation libs.junit.api
runtimeOnly.bundle libs.bundles.junit.runtime
implementation libs.powermock
}

compileOnly(libs.nulls)
targets.configureEach {
testTask.configure {
testLogging {
events 'passed', 'skipped', 'failed'
}
}
}
}
}

tasks.named('test', Test).configure {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
}
dependencies {
compileOnly libs.annotations.jetbrains

implementation libs.jopt
api libs.srgutils
implementation libs.bundles.asm
}

tasks.named('jar', Jar).configure {
tasks.named('jar', 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' : gradleutils.vendor.get(),
'Specification-Version' : gitversion.info.tag,
'Implementation-Title' : 'ForgeAutoRenamingTool',
'Implementation-Version': project.version,
'Implementation-Vendor' : gradleutils.vendor.get()
], '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', ShadowJar) {
enableAutoRelocation = true
relocationPrefix = 'net.minecraftforge.fart.relocated'

minimize()

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

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

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

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

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

changelog {
from '0.1'
}
Expand All @@ -110,6 +93,10 @@ license {
}

publishing {
repositories {
maven gradleutils.publishingForgeMaven
}

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

Expand All @@ -118,17 +105,13 @@ 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
}
}
}

repositories {
maven gradleutils.publishingForgeMaven
}
}
10 changes: 10 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true

org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.configuration-cache.problems=warn

net.minecraftforge.gradleutils.ide.automatic.sources=true
net.minecraftforge.gradleutils.compilation.defaults=true
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.3.0-rc-2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
15 changes: 7 additions & 8 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,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

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


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -170,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

JAVACMD=$( cygpath --unix "$JAVACMD" )

Expand Down Expand Up @@ -203,15 +203,14 @@ 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
25 changes: 13 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,21 @@ 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


@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%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
37 changes: 37 additions & 0 deletions renamer-gradle-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import net.minecraftforge.renamer.gradle.RenameJar

plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.renamer'
}

group = 'net.minecraftforge'

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

dependencies {
compileOnly libs.log4j.api
}

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

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

artifact renameJar
}
}

//renamer {
// mappings = files('libs/mappings_test-1.0.tsrg.gz')
// //mappings('test', '1.0')
// //mappings dependencies.variantOf(libs.mappings) { artifactType 'tsrg.gz' }
//}
//
//renamer.classes('renameRemote', jar)
Binary file not shown.
7 changes: 7 additions & 0 deletions renamer-gradle-demo/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-rc-2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading