Skip to content

Commit

Permalink
chore: adjust the Gradle-based GooeyCLI setup
Browse files Browse the repository at this point in the history
* Moves it to a maybe more sensible place in the gradle directory where the wrapper lives, this seems kinda related
* Standardizes the source path so we don't need to explicitly configure it
* Drops the Groovy dependency (in Gradle) down to match what's currently in the Gradle Wrapper (although it would still get fetched and used separately for any sort of GooeyCLI *build* process)
  • Loading branch information
Cervator committed Jul 11, 2020
1 parent c5ed6d3 commit 53662ac
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 33 deletions.
26 changes: 0 additions & 26 deletions config/cli/build.gradle

This file was deleted.

35 changes: 35 additions & 0 deletions gradle/gooeycli/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
apply plugin: 'groovy'

group 'org.terasology.cli'

repositories {
jcenter()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.5.10'
compile 'info.picocli:picocli-groovy:4.3.2'
compile 'org.fusesource.jansi:jansi:1.18'
compile 'org.ajoberstar:grgit:1.9.3'
}

// Ugly hack to allow Gradle and @Grab to get along. See https://github.com/gradle/gradle/issues/1031 - not sure if worth it?
compileGroovy {
// Create temp file.
File temp = File.createTempFile("config", ".groovy");

// Delete temp file when program exits.
temp.deleteOnExit();

// Write to temp file
BufferedWriter out = new BufferedWriter(new FileWriter(temp));
out.write("""\
withConfig(configuration) {
configuration.setDisabledGlobalASTTransformations(['groovy.grape.GrabAnnotationTransformation'] as Set)
}
""".stripIndent());
out.close();
groovyOptions.configurationScript = temp
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package org.terasology.cli
@GrabResolver(name = 'jcenter', root = 'http://jcenter.bintray.com/')
@Grab(group = 'org.ajoberstar', module = 'grgit', version = '1.9.3')

import org.ajoberstar.grgit.Grgit

/**
* Utility class for dealing with items managed in a developer workspace.
Expand Down
5 changes: 2 additions & 3 deletions gw
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ case "`uname`" in
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar:$APP_HOME/gradle/wrapper/groovy-wrapper.jar:$APP_HOME/config/cli/groovy

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar:$APP_HOME/gradle/wrapper/groovy-wrapper.jar:$APP_HOME/gradle/gooeycli/src/main/groovy

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
Expand Down Expand Up @@ -180,6 +179,6 @@ save () {
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GroovyWrapperMain config/cli/groovy/org/terasology/cli/GooeyCLI.groovy "$APP_ARGS"
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GroovyWrapperMain gradle/gooeycli/src/main/groovy/org/terasology/cli/GooeyCLI.groovy "$APP_ARGS"

exec "$JAVACMD" "$@"
4 changes: 2 additions & 2 deletions gw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ SET CMD_LINE_ARGS=%CMD_LINE_ARGS:~1%

:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%gradle\wrapper\gradle-wrapper.jar;%APP_HOME%gradle\wrapper\groovy-wrapper.jar;%APP_HOME%config\cli\groovy\;
set CLASSPATH=%APP_HOME%gradle\wrapper\gradle-wrapper.jar;%APP_HOME%gradle\wrapper\groovy-wrapper.jar;%APP_HOME%gradle\gooeycli\src\main\groovy;


@rem Execute Groovy via the Gradle Wrapper
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -cp "%CLASSPATH%" org.gradle.wrapper.GroovyWrapperMain config/cli/groovy/org/terasology/cli/GooeyCLI.groovy %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -cp "%CLASSPATH%" org.gradle.wrapper.GroovyWrapperMain gradle/gooeycli/src/main/groovy/org/terasology/cli/GooeyCLI.groovy %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import groovy.io.FileType

rootProject.name = 'Terasology'

include 'engine', 'engine-tests', 'facades', 'metas', 'libs', 'modules', ':config:cli'
include 'engine', 'engine-tests', 'facades', 'metas', 'libs', 'modules', ':gradle:gooeycli'

// Handy little snippet found online that'll "fake" having nested settings.gradle files under /modules, /libs, etc
rootDir.eachDir { possibleSubprojectDir ->
Expand Down

0 comments on commit 53662ac

Please sign in to comment.