First small round of changes to Gradle/Groovy.
* Update to Gradle Wrapper 3.3 * Remove something unnecessary in the PC Facade Gradle that now caused an outright error (PC doesn't at present need to resolve snapshot dependencies) * Add in new Groovy Wrapper at the same level as the Gradle Wrapper - https://github.com/MovingBlocks/groovy-wrapper * Add in a new module script for easier retrieval of modules (including all dependencies as source if desired!)develop
parent
b624af4b78
commit
ae8af6ac09
|
@ -253,12 +253,6 @@ task distApp (type: Sync) {
|
|||
}
|
||||
}
|
||||
|
||||
// This is a TEMPORARY tweak to make "changing" dependencies always ('0') check for newer snapshots available
|
||||
// TODO: Remove this when versioning and promotion works fully, then we shouldn't care about snapshots normally anyway
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
}
|
||||
|
||||
// Distribute modules - only grabs Core in Jenkins but locally will grab any present. "Distros" now handle Jenkins packs
|
||||
task distModules (type: Sync) {
|
||||
description = "Prepares local modules for distribution"
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
#Thu Dec 31 10:21:27 CET 2015
|
||||
#Fri Jan 27 18:22:28 EST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
|
@ -6,12 +6,30 @@
|
|||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
|
@ -30,6 +48,7 @@ die ( ) {
|
|||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
|
@ -40,26 +59,11 @@ case "`uname`" in
|
|||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
|
@ -85,7 +89,7 @@ location of your Java installation."
|
|||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
|
@ -150,11 +154,19 @@ if $cygwin ; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
# Escape application args
|
||||
save ( ) {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
# 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.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@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=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@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=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
|
@ -46,10 +46,9 @@ echo location of your Java installation.
|
|||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
|
@ -60,11 +59,6 @@ set _SKIP=2
|
|||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar:$APP_HOME/gradle/wrapper/groovy-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save ( ) {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
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 "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Groovy Wrapper version of the Gradle Wrapper
|
||||
@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 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=
|
||||
|
||||
@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 init
|
||||
|
||||
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 init
|
||||
|
||||
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
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar;%APP_HOME%\gradle\wrapper\groovy-wrapper.jar;
|
||||
|
||||
@rem Execute Groovy via the Gradle Wrapper
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GroovyWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
: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
|
|
@ -0,0 +1,189 @@
|
|||
// We use GrGit for interacting with Git. This gets a hold of it as a dependency like Gradle would
|
||||
// TODO: Consider if we should do something to fix/suppress the SLF4J warning that gets logged on first usage?
|
||||
@GrabResolver(name = 'jcenter', root = 'http://jcenter.bintray.com/')
|
||||
@Grab(group='org.ajoberstar', module='grgit', version='1.9.3')
|
||||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
// Grab override properties from the gradle.properties file (shared with various Gradle commands)
|
||||
Properties properties = new Properties()
|
||||
new File("gradle.properties").withInputStream {
|
||||
properties.load(it)
|
||||
}
|
||||
//println "Properties: " + properties
|
||||
|
||||
// Groovy Elvis operator woo! Defaults to "Terasology" if an override isn't set
|
||||
githubHome = properties.alternativeGithubHome ?: "Terasology"
|
||||
|
||||
//println "githubHome is: $githubHome"
|
||||
|
||||
// For keeping a list of modules retrieved so far
|
||||
modulesRetrieved = []
|
||||
|
||||
// Module dependencies we don't want to retrieve as they live in the main Terasology repo
|
||||
excludedDependencies = ["engine", "Core", "CoreSampleGameplay", "BuilderSampleGameplay"]
|
||||
|
||||
/**
|
||||
* Primary entry point for retrieving modules, kicks off recursively if needed.
|
||||
* @param modules the modules we want to retrieve
|
||||
* @param recurse whether to also retrieve dependencies of the desired modules
|
||||
*/
|
||||
def retrieve(String[] modules, boolean recurse) {
|
||||
println "Now inside retrieve, user (recursively? $recurse) wants: $modules"
|
||||
for (String module : modules) {
|
||||
println "Starting loop for module $module, are we recursing? $recurse"
|
||||
println "Modules retrieved so far: $modulesRetrieved"
|
||||
retrieveModule(module, recurse)
|
||||
//println "Modules retrieved after recent addition(s): modulesRetrieved"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a single module via Git Clone. Considers whether it exists locally first or if it has already been retrieved this execution.
|
||||
* @param module the target module to retrieve
|
||||
* @param recurse whether to also retrieve its dependencies (if so then recurse back into retrieve)
|
||||
*/
|
||||
def retrieveModule(String module, boolean recurse) {
|
||||
File targetDir = new File("modules/$module")
|
||||
println "Request to retrieve module $module would store it at $targetDir - exists? " + targetDir.exists()
|
||||
|
||||
if (targetDir.exists()) {
|
||||
println "That module already had an existing directory locally. If something is wrong with it please delete and try again"
|
||||
modulesRetrieved << module
|
||||
} else if (modulesRetrieved.contains(module)) {
|
||||
println "We already retrieved $module - skipping"
|
||||
} else {
|
||||
println "Retrieving module $module - if it doesn't appear to exist (typo for instance) you'll get an auth prompt (in case it is private)"
|
||||
//noinspection GroovyAssignabilityCheck - GrGit has its own .clone but a warning gets issued for Object.clone
|
||||
Grgit.clone dir: targetDir, uri: "https://github.com/$githubHome/${module}.git"
|
||||
modulesRetrieved << module
|
||||
|
||||
// TODO: Temporary until build.gradle gets removed from module directories (pending Cervator work)
|
||||
File targetBuildGradle = new File(targetDir, 'build.gradle')
|
||||
targetBuildGradle.delete()
|
||||
targetBuildGradle << new File('modules/Core/build.gradle').text
|
||||
|
||||
File moduleManifest = new File(targetDir, 'module.txt')
|
||||
if (!moduleManifest.exists()) {
|
||||
def moduleText = new File("templates/module.txt").text
|
||||
moduleManifest << moduleText.replaceAll('MODULENAME', module)
|
||||
println "WARNING: Module $module did not have a module.txt! One was created, please review and submit to GitHub"
|
||||
}
|
||||
|
||||
// Recurse deeper if we are retrieving dependencies as well
|
||||
if (recurse) {
|
||||
def foundDependencies = readModuleDependencies(new File(targetDir, "module.txt"))
|
||||
if (foundDependencies.length == 0) {
|
||||
println "Module $module did not appear to have any dependencies we need to worry about"
|
||||
} else {
|
||||
println "Module $module has the following module dependencies we care about: $foundDependencies"
|
||||
String[] uniqueDependencies = foundDependencies - modulesRetrieved
|
||||
println "After removing dupes already retrieved we have the remaining dependencies left: $uniqueDependencies"
|
||||
if (uniqueDependencies.length > 0) {
|
||||
retrieve(uniqueDependencies, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a given module info file to figure out which if any dependencies it has. Filters out any already retrieved.
|
||||
* @param targetModuleInfo the target file to check (a module.txt file or similar)
|
||||
* @return a String[] containing the next level of dependencies, if any
|
||||
*/
|
||||
String[] readModuleDependencies(File targetModuleInfo) {
|
||||
def qualifiedDependencies = []
|
||||
if (!targetModuleInfo.exists()) {
|
||||
println "The module info file did not appear to exist - can't calculate dependencies"
|
||||
return qualifiedDependencies
|
||||
}
|
||||
|
||||
def slurper = new JsonSlurper()
|
||||
def moduleConfig = slurper.parseText(targetModuleInfo.text)
|
||||
for (dependency in moduleConfig.dependencies) {
|
||||
if (excludedDependencies.contains(dependency.id)) {
|
||||
println "Skipping listed dependency $dependency as it is in the exclude list (shipped with primary project)"
|
||||
} else {
|
||||
println "Accepting listed dependency $dependency"
|
||||
qualifiedDependencies << dependency.id
|
||||
}
|
||||
}
|
||||
return qualifiedDependencies
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts input from the user, showing a descriptive prompt.
|
||||
* @param prompt the prompt to show the user
|
||||
*/
|
||||
def getUserString (String prompt) {
|
||||
println ('\n*** ' + prompt + '\n')
|
||||
|
||||
def reader = new BufferedReader(new InputStreamReader(System.in)) // Note: Do not close reader, it will close System.in (Big no-no)
|
||||
|
||||
return reader.readLine()
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply prints usage information.
|
||||
*/
|
||||
def printUsage() {
|
||||
println ""
|
||||
println "Utility script for interacting with modules. Available sub commands:"
|
||||
println "- 'get' - retrieves one or more modules in source form (separate with spaces)"
|
||||
println "- 'recurse' - retrieves the given module(s) *and* their dependencies in source form"
|
||||
println ""
|
||||
println "Example: 'groovyw module recurse GooeysQuests Sample' - would retrieve those modules plus their dependencies"
|
||||
println "*NOTE*: Module names are case sensitive"
|
||||
println ""
|
||||
println "If you omit further arguments beyond the sub command you'll be prompted for details"
|
||||
println "After changing modules available in your workspace rerun 'gradlew idea' and/or refresh your IDE"
|
||||
println ""
|
||||
println "For advanced usage see project documentation. For instance you can provide an alternative GitHub home"
|
||||
println "A gradle.properties file (one exists under '/templates' in an engine workspace) can provide such overrides"
|
||||
println ""
|
||||
}
|
||||
|
||||
// Main bit of logic handling the entry points to this script - defers actual work to dedicated methods
|
||||
//println "Args: $args"
|
||||
if (args.length == 0) {
|
||||
printUsage()
|
||||
} else {
|
||||
def recurse = false
|
||||
switch (args[0]) {
|
||||
case 'usage':
|
||||
printUsage()
|
||||
break
|
||||
case "recurse":
|
||||
recurse = true
|
||||
println "We're retrieving recursively (all the things depended on too)"
|
||||
// We just fall through here to the get logic after setting a boolean
|
||||
//noinspection GroovyFallthrough
|
||||
case "get":
|
||||
println "Preparing to get one or more modules"
|
||||
if (args.length == 1) {
|
||||
// User hasn't supplied any module names, so ask
|
||||
def moduleString = getUserString('Enter Module Name(s - separate multiple with spaces, CapiTaliZation MatterS): ')
|
||||
println "User wants: $moduleString"
|
||||
// Split it on whitespace
|
||||
String[] moduleList = moduleString.split("\\s+")
|
||||
println "Now in an array: $moduleList"
|
||||
retrieve moduleList, recurse
|
||||
} else {
|
||||
// User has supplied one or more module names, so pass them forward (skipping the "get" arg)
|
||||
def adjustedArgs = args.drop(1)
|
||||
println "Adjusted args: $adjustedArgs"
|
||||
retrieve adjustedArgs, recurse
|
||||
}
|
||||
println "All done retrieving requested modules: $modulesRetrieved"
|
||||
break
|
||||
case "create":
|
||||
println "We're doing a create"
|
||||
String someParam = getUserString("Please enter a thing")
|
||||
println "User return was: $someParam"
|
||||
break
|
||||
default:
|
||||
println "UNRECOGNIZED COMMAND - please try again or use 'groovyw module usage' for help"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue