First small round of changes to Gradle/Groovy. #2979
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contains
This is a small chunk of work split out of my local Gradle overhaul to start at least getting some functional pieces online and reviewable. Rather than wait for the complete removal of
build.gradle
for modules, a switch to IDE Gradle imports instead ofgradlew idea
, and so on. Some of those bits are working fine but I'm not happy with it all yet.This helps speed up
gradlew
in general because it upgrades from Gradle 2.10 to 3.3. I have an additional speed-up that avoids some early (and possibly repetitive) dependency resolution, but it causes quirky failures withgradlew idea
I didn't see earlier as I removed that whole thing in my main overhaul. It especially matters for Gradle commands with a nested target (likegradlew engine-tests:test
) which at present are nearly unusable with a large amount of modules present (seems like Gradle almost reruns for every module)It also introduces my shiny new Groovy Wrapper which provides a
groovyw
script that does exactly whatgradlew
does but for Groovy scripts, using the Groovy bundled with Gradle (it is there already anyway so use it!). Run Groovy scripts without ever having to worry about downloading or setting up Groovy! There is an initialmodule.groovy
with two sub functions implemented so far:get
- retrieves one or more modules in source form (separate with spaces)recurse
- retrieves the given module(s) and their dependencies in source formThe
get
function effectively replacesgradlew fetchModuleX
and is run with something likegroovyw module get GooeysQuests
instead. I haven't removedfetchModule
in Gradle land yet, but will consider it deprecated for removal later. I named it "get" instead of "fetch" to reduce confusion vs Git commands (I hope) while in code it mostly uses "retrieve"The
recurse
variant is more fun.groovyw module recurse GooeysQuests
will retrieve that module and all its dependencies as source modules - finally! It'll skip any dependencies already found locally as source. Both functions support multiple module names and then process all of them (such asgroovyw module recurse GooeysQuests JoshariasSurvival NeoTTA LightAndShadow
which will grab a lot of stuff - yet is super fast!)Groovy itself isn't particularly speedy, but using this approach we skip all the extras Gradle wraps around simple things we don't really need Gradle for. At present you would still run
gradlew idea
after changing your local module lineup - later my goal is to make it so you could simply click a refresh button in the IDE (or even enable auto-refresh) and the structure will update, nogradlew idea
needed. I have that working locally. It is neat.Expanding the module script base should be super easy. Breaking it down:
groovyw
- invokes the Groovy Wrapper I prepared. It is just a minimally hacked Gradle Wrapper that executes Groovy instead - but it uses all the Gradle distribution magic to set up anything needed automagically. Whichever one you run first will download Gradle then use that dist to execute either Gradle or Groovy scriptsmodule
- targets the scriptmodule.groovy
- so later we could have other scripts for targeting other things, like libs or meta module repos.recurse
- instructs the script to run therecurse
sub function, passing further variables in there. You can actually stop here - the script will prompt the user for module names! Thanks @mbrotz (Made createModule interactive and support multiple CSV arguments #2634) and @smsunarto (Added Interactive Capability for fetchModule Gradle command. #2657) :-)GooeysQuests
... - accepts a space separated list of modules (casing matters). Plainget
just retrieves those modules whilerecurse
as the name indicates recursively resolves all dependencies in the tree and retrieves all of themHow to test
gradlew
runs without error - you should get Gradle 3.3 dist files downloaded, could take a few minutes depending on bandwithgradlew idea
runs without error (orgradlew eclipse
etc) and that the project still opens normally in an IDEgradlew game
groovyw module get
orgroovyw module recurse
commands to retrieve some modules! Visually verify that the newly downloaded module source dirs look right and/or usegradlew idea
or whatever to test that they workgroovyw module
like feeding it the same module multiple times or attempting to trigger a circular dependency. I put some decent effort into hardening it but maybe there are still edge casesgroovyw module usage
or gibberish sub function names to see what happensOutstanding before merging
gradlew fetchModuleX
is now deprecated, although we'll keep it around a while