Skip to content

Commit

Permalink
add sourceset for cli config
Browse files Browse the repository at this point in the history
  • Loading branch information
pollend authored and Cervator committed Jul 11, 2020
1 parent d9e2e18 commit fc46d27
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 25 deletions.
25 changes: 25 additions & 0 deletions config/cli/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
apply plugin: 'groovy'


group 'org.terasology'

repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.5.4'
compile 'org.apache.ivy:ivy:2.4.0'
}

sourceSets {
main {
groovy {
srcDir 'groovy'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli

import picocli.CommandLine.Command

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
import picocli.CommandLine.ParentCommand
import picocli.CommandLine.Command
// Actually in use, annotation below may show syntax error due to Groovy's annotation by the same name. Works fine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
import picocli.CommandLine.Option

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import picocli.CommandLine.HelpCommand

// If using local groovy files the subcommands section may highlight as bad syntax in IntelliJ - that's OK
@Command(name = "gw",
synopsisSubcommandLabel = "COMMAND", // Default is [COMMAND] indicating optional, but sub command here is required
subcommands = [
HelpCommand.class, // Adds standard help options (help as a subcommand, -h, and --help)
Module.class,
Init.class], // Note that these Groovy classes *must* start with a capital letter for some reason
description = "Utility system for interacting with a Terasology developer workspace")
// synopsisSubcommandLabel = "COMMAND", // Default is [COMMAND] indicating optional, but sub command here is required
subcommands = [
HelpCommand.class, // Adds standard help options (help as a subcommand, -h, and --help)
Module.class,
Init.class], // Note that these Groovy classes *must* start with a capital letter for some reason
description = "Utility system for interacting with a Terasology developer workspace")
class GooeyCLI extends BaseCommand {
static void main(String[] args) {
AnsiConsole.systemInstall() // enable colors on Windows - TODO: Test on not-so-Windows systems, should those not run this?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
import picocli.CommandLine.Command
import picocli.CommandLine.Help.Ansi
// Is in use, IDE may think the Groovy-supplied is in use below and mark this unused
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
/**
* Simple command type class that indicates the command deals with "items" - nested Git roots representing application elements
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
class ManagedModule extends ManagedItem {
ManagedModule() {
super()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli

import picocli.CommandLine.Command
import picocli.CommandLine.HelpCommand

// If using local groovy files the subcommands section may highlight as bad syntax in IntelliJ - that's OK
@Command(name = "module",
synopsisSubcommandLabel = "COMMAND", // Default is [COMMAND] indicating optional, but sub command here is required
// synopsisSubcommandLabel = "COMMAND", // Default is [COMMAND] indicating optional, but sub command here is required
subcommands = [
HelpCommand.class, // Adds standard help options (help as a subcommand, -h, and --help)
Recurse.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
/**
* Convenience class for pulling properties out of a 'gradle.properties' if present, for various overrides
* // TODO: YAML variant that can be added for more complex use cases?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
import picocli.CommandLine.ParentCommand
import picocli.CommandLine.Command
import picocli.CommandLine.Mixin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.cli;
package org.terasology.cli
import picocli.CommandLine.ParentCommand
import picocli.CommandLine.Command
import picocli.CommandLine.Mixin
Expand Down
4 changes: 2 additions & 2 deletions gw
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ case "`uname`" in
;;
esac

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


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -180,6 +180,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/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 config/cli/groovy/org/terasology/cli/GooeyCLI.groovy "$APP_ARGS"

exec "$JAVACMD" "$@"
5 changes: 2 additions & 3 deletions gw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +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\groovy\;
set CLASSPATH=%APP_HOME%gradle\wrapper\gradle-wrapper.jar;%APP_HOME%gradle\wrapper\groovy-wrapper.jar;%APP_HOME%config\cli\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/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 config/cli/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'
include 'engine', 'engine-tests', 'facades', 'metas', 'libs', 'modules', ':config:cli'

// 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 fc46d27

Please sign in to comment.