Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the tiny-remapper CLI #6

Merged
merged 44 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d7195b6
Ignore VSCode files
egelja Jun 13, 2021
cc9b54b
Add Picocli
egelja Jun 13, 2021
dbdd278
Start annotating fields
egelja Jun 13, 2021
bf69606
Tabs ---> spaces
egelja Jun 13, 2021
ede339f
Improve version detection
egelja Jun 13, 2021
ac7ca7b
Annotate all switches
egelja Jun 14, 2021
5c6874e
Cleanup
egelja Jun 14, 2021
e543d06
Annotate parameters
egelja Jun 14, 2021
bb3ecec
Fix classpath setter
egelja Jun 14, 2021
338761c
Add validation and runner method
egelja Jun 14, 2021
5fb4b66
Make all instance variables private
egelja Jun 14, 2021
022860f
Add main runner script
egelja Jun 14, 2021
b6bb68f
`javax.validation` is not included by default
egelja Jun 14, 2021
5ad6c47
Fix version detection
egelja Jun 14, 2021
a544f60
Fix thread setter
egelja Jun 14, 2021
702c63c
Version detection again and spec field
egelja Jun 14, 2021
d361616
Remove duplicate stuff
egelja Jun 14, 2021
cb8459c
Make a fat jar
egelja Jun 16, 2021
d7b79bf
Fix typo
egelja Jun 16, 2021
af65219
Fix colors on Windows
egelja Jun 16, 2021
fd6dade
Fat jar replaces application plugin
egelja Jun 16, 2021
583317c
Improve the version field
egelja Jun 16, 2021
e2efe8c
Add a footer and abbreviate the synopsis
egelja Jun 16, 2021
fcce217
Remove the old verification stuff
egelja Jun 16, 2021
096ea79
Add man page generation
egelja Jun 16, 2021
6d88db6
Add some short switches
egelja Jun 16, 2021
a522bc0
Booleans are false by default
egelja Jun 16, 2021
c2e9af1
Add `v` in front of version (i.e. `ASM v9.1`)
egelja Jun 16, 2021
780e182
Use blossom ffor version field
egelja Jun 17, 2021
7528d13
Format build.dependsOn
egelja Jun 17, 2021
49759e6
Debugging pt. 1
egelja Jun 17, 2021
7cf0585
Debugging pt. 2
egelja Jun 17, 2021
58816fc
Couple of Javadocs
egelja Jun 17, 2021
132b78d
Gradle be quiet
egelja Jun 17, 2021
c177c8c
Make class final, use ROOT locale
egelja Jun 17, 2021
fa77911
Spaces ---> tabs
egelja Jun 17, 2021
bd772e4
Spaces --> tabs, fix the version in META-INF
egelja Jun 18, 2021
a2abf87
Single to double quotes
egelja Jun 18, 2021
ee2244f
Add comment back in
egelja Jun 18, 2021
adafc6d
Change description of switches with options
egelja Jun 18, 2021
e68e55e
Add docs for Github pages
egelja Jun 18, 2021
eb30c85
Add javadoc folder
egelja Jun 18, 2021
008dee4
Add Github Action for docs
egelja Jun 18, 2021
64e621b
Add gitattributes
egelja Jun 18, 2021
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
/.settings/
/.classpath
/.project
/.factorypath
/.gradle
*.jar
*.tiny
.idea/
.settings/
.vscode/
!src/test/resources/**
67 changes: 59 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,48 @@ plugins {
id "java"
id "maven-publish"
id "com.diffplug.spotless" version "5.10.2"
id "com.github.johnrengelman.shadow" version "7.0.0" // Make a fat jar
id "org.asciidoctor.jvm.convert" version "3.1.0" // Make man pages
id "net.kyori.blossom" version "1.2.0" // Better version (again)
// TODO: Apply checkstyle
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = '0.4.1'
version = "0.4.1"

def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")

group = "org.quiltmc"
archivesBaseName = 'tiny-remapper'
archivesBaseName = "tiny-remapper"

repositories {
mavenCentral()
}

dependencies {
def asmVersion = "9.1"

// ASM
implementation "org.ow2.asm:asm:$asmVersion"
implementation "org.ow2.asm:asm-commons:$asmVersion"
implementation "org.ow2.asm:asm-tree:$asmVersion"
implementation "org.ow2.asm:asm-util:$asmVersion"
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'

// Testing
testImplementation "org.junit.jupiter:junit-jupiter:5.6.2"

// CLI tool
implementation "info.picocli:picocli:$picocliVersion"
annotationProcessor "info.picocli:picocli-codegen:$picocliVersion"

implementation group: "org.fusesource.jansi", name: "jansi", version: "2.3.3"
egelja marked this conversation as resolved.
Show resolved Hide resolved
implementation "info.picocli:picocli-jansi-graalvm:1.2.0"
egelja marked this conversation as resolved.
Show resolved Hide resolved
}

compileJava {
// For PicoCLI annotation processor
options.compilerArgs += ["-Aproject=${project.group}/${project.name}"]
}

java {
Expand All @@ -52,25 +68,40 @@ spotless {
}
}

blossom {
replaceToken("__TINY_VERSION", project.version)
replaceToken("__ASM_VERSION", asmVersion)
}

test {
useJUnitPlatform()
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
events = ['passed', 'failed', 'skipped']
exceptionFormat = "full"
i509VCB marked this conversation as resolved.
Show resolved Hide resolved
events = ["passed", "failed", "skipped"]
}
}

jar {
manifest {
attributes "Implementation-Title": "TinyRemapper",
"Implementation-Version": archiveVersion,
"Implementation-Version": version,
// TODO: Move to application plugin instead of placing this in the manifest directly
egelja marked this conversation as resolved.
Show resolved Hide resolved
"Main-Class": "net.fabricmc.tinyremapper.Main",
"Automatic-Module-Name": "org.quiltmc.tinyremapper"
}
}

shadowJar {
archiveClassifier.set("fat")
}

build {
dependsOn {
shadowJar
}
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand All @@ -90,3 +121,23 @@ publishing {
}
}
}

// Manpage generator (included with PicoCLI)
task generateManpageAsciiDoc(type: JavaExec) {
dependsOn(classes)
group = "Documentation"
description = "Generate AsciiDoc manpage"
classpath(configurations.runtimeClasspath, configurations.annotationProcessor, sourceSets.main.runtimeClasspath)
mainClass = "picocli.codegen.docgen.manpage.ManPageGenerator"
args "net.fabricmc.tinyremapper.Main", "--outdir=${project.buildDir}/generated-picocli-docs", "-v" //, "--template-dir=src/docs/mantemplates"
}

asciidoctor {
dependsOn(generateManpageAsciiDoc)
sourceDir = file("${project.buildDir}/generated-picocli-docs")
outputDir = file("${project.buildDir}/docs")
logDocuments = true
outputOptions {
backends = ["manpage", "html5"]
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asmVersion = 9.1
picocliVersion = 4.6.1
178 changes: 89 additions & 89 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
@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

@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=.
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%" == "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.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
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.

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%"=="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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

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

:omega
@rem
i509VCB marked this conversation as resolved.
Show resolved Hide resolved
@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

@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=.
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%" == "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.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
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.

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%"=="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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

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

:omega
Loading