├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.gradle ├── codenarc.groovy ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lazybones-app ├── .gitignore ├── app.gradle ├── gvm-release-credentials.gpg └── src │ ├── integTest │ ├── groovy │ │ └── uk │ │ │ └── co │ │ │ └── cacoethes │ │ │ └── lazybones │ │ │ ├── AbstractFunctionalSpec.groovy │ │ │ ├── ConfigFunctionalSpec.groovy │ │ │ ├── CreateFunctionalSpec.groovy │ │ │ ├── HelpFunctionalSpec.groovy │ │ │ ├── InfoFunctionalSpec.groovy │ │ │ ├── LazybonesScriptFunctionalSpec.groovy │ │ │ ├── ListFunctionalSpec.groovy │ │ │ ├── MainFunctionalSpec.groovy │ │ │ ├── OfflineFunctionalSpec.groovy │ │ │ ├── ProxyFunctionalSpec.groovy │ │ │ └── SubTemplatesFunctionalSpec.groovy │ ├── resources │ │ ├── BetamaxConfig.groovy │ │ ├── betamax │ │ │ └── tapes │ │ │ │ ├── create_tape.yaml │ │ │ │ ├── info_tape.yaml │ │ │ │ └── list_tape.yaml │ │ ├── dummy-app.zip │ │ ├── managed-config.json │ │ └── test-config.groovy │ └── templates │ │ ├── Oops-stuff │ │ ├── README.md │ │ ├── VERSION │ │ └── src │ │ │ └── groovy │ │ │ └── .retain │ │ ├── subtemplates-tmpl │ │ ├── README.md │ │ ├── VERSION │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── lazybones.groovy │ │ └── src │ │ │ ├── main │ │ │ └── groovy │ │ │ │ └── .retain │ │ │ └── test │ │ │ └── groovy │ │ │ └── .retain │ │ ├── subtmpl-bad │ │ ├── README.md │ │ ├── VERSION │ │ └── lazybones.groovy │ │ ├── subtmpl-controller │ │ ├── Controller.groovy.gtpl │ │ ├── README.md │ │ ├── VERSION │ │ └── lazybones.groovy │ │ ├── subtmpl-entity │ │ ├── Entity.groovy.gtpl │ │ ├── README.md │ │ ├── VERSION │ │ └── lazybones.groovy │ │ ├── test-handlebars-default │ │ ├── GroovyHello.groovy.gtpl │ │ ├── NoSuffixGroovyHello.groovy │ │ ├── PrintHello.groovy.hbs │ │ ├── README.md │ │ ├── VERSION │ │ └── lazybones.groovy │ │ ├── test-handlebars │ │ ├── GroovyHello.groovy.gtpl │ │ ├── NoSuffixGroovyHello.groovy │ │ ├── PrintHello.groovy.hbs │ │ ├── README.md │ │ └── lazybones.groovy │ │ ├── test-no-default-engine │ │ ├── GroovyHello.groovy.gtpl │ │ ├── NoSuffixGroovyHello.groovy │ │ ├── PrintHello.groovy.hbs │ │ ├── README.md │ │ ├── VERSION │ │ └── lazybones.groovy │ │ ├── test-tmpl-subscripts │ │ ├── README.md │ │ ├── VERSION │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── lazybones.groovy │ │ ├── src │ │ │ ├── main │ │ │ │ └── groovy │ │ │ │ │ ├── .retain │ │ │ │ │ ├── PrintGoodbye.groovy │ │ │ │ │ ├── PrintHello.groovy │ │ │ │ │ └── UnfilteredHello.groovy │ │ │ └── test │ │ │ │ └── groovy │ │ │ │ └── .retain │ │ └── sub1.groovy │ │ └── test-tmpl │ │ ├── README.md │ │ ├── VERSION │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── lazybones.groovy │ │ └── src │ │ ├── main │ │ └── groovy │ │ │ ├── .retain │ │ │ ├── PrintGoodbye.groovy │ │ │ ├── PrintHello.groovy │ │ │ └── UnfilteredHello.groovy │ │ └── test │ │ └── groovy │ │ └── .retain │ ├── main │ ├── groovy │ │ └── uk │ │ │ └── co │ │ │ └── cacoethes │ │ │ ├── lazybones │ │ │ ├── LazybonesMain.groovy │ │ │ ├── LazybonesScript.groovy │ │ │ ├── LazybonesScriptException.java │ │ │ ├── NoVersionsFoundException.java │ │ │ ├── OptionParserBuilder.groovy │ │ │ ├── Options.java │ │ │ ├── PackageInfo.groovy │ │ │ ├── PackageNotFoundException.java │ │ │ ├── commands │ │ │ │ ├── AbstractCommand.groovy │ │ │ │ ├── Command.java │ │ │ │ ├── Commands.groovy │ │ │ │ ├── ConfigCommand.groovy │ │ │ │ ├── CreateCommand.groovy │ │ │ │ ├── CreateCommandInfo.groovy │ │ │ │ ├── GenerateCommand.groovy │ │ │ │ ├── HelpCommand.groovy │ │ │ │ ├── InfoCommand.groovy │ │ │ │ ├── InstallationScriptExecuter.groovy │ │ │ │ ├── ListCommand.groovy │ │ │ │ ├── OfflineMode.groovy │ │ │ │ ├── PackageDownloader.groovy │ │ │ │ ├── PackageLocation.groovy │ │ │ │ ├── PackageLocationBuilder.groovy │ │ │ │ └── TemplateArg.groovy │ │ │ ├── config │ │ │ │ ├── BooleanConverter.groovy │ │ │ │ ├── Configuration.groovy │ │ │ │ ├── Converter.java │ │ │ │ ├── Converters.groovy │ │ │ │ ├── IntegerConverter.groovy │ │ │ │ ├── InvalidSettingException.java │ │ │ │ ├── ListConverter.groovy │ │ │ │ ├── MultipleInvalidSettingsException.groovy │ │ │ │ ├── ObjectConverter.groovy │ │ │ │ ├── StringConverter.groovy │ │ │ │ ├── UnknownSettingException.java │ │ │ │ └── UriConverter.groovy │ │ │ ├── packagesources │ │ │ │ ├── BintrayPackageSource.groovy │ │ │ │ ├── PackageSource.groovy │ │ │ │ └── PackageSourceBuilder.groovy │ │ │ ├── scm │ │ │ │ ├── GitAdapter.groovy │ │ │ │ └── ScmAdapter.groovy │ │ │ └── security │ │ │ │ ├── CompositePolicy.groovy │ │ │ │ └── RuntimePolicy.groovy │ │ │ └── util │ │ │ ├── AntPathMatcher.java │ │ │ ├── ArchiveMethods.groovy │ │ │ ├── NameType.groovy │ │ │ ├── Naming.groovy │ │ │ ├── PlainFormatter.groovy │ │ │ └── UrlUtils.groovy │ └── resources │ │ └── uk │ │ └── co │ │ └── cacoethes │ │ └── lazybones │ │ └── config │ │ └── defaultConfig.groovy │ └── test │ └── groovy │ └── uk │ └── co │ └── cacoethes │ ├── lazybones │ ├── LazybonesMainSpec.groovy │ ├── LazybonesScriptSpec.groovy │ ├── commands │ │ ├── CreateCommandSpec.groovy │ │ ├── InstallationScriptExecuterSpec.groovy │ │ └── ListCommandSpec.groovy │ ├── config │ │ └── ConfigurationSpec.groovy │ └── packagesources │ │ ├── BintrayPackageSourceSpec.groovy │ │ └── PackageSourceFactorySpec.groovy │ └── util │ ├── AntPathMatcherTests.java │ ├── NamingSpec.groovy │ ├── PlainFormatterSpec.groovy │ └── UrlUtilsSpec.groovy ├── lazybones-gradle-plugin ├── README.md ├── gradle-plugin.gradle └── src │ ├── main │ ├── groovy │ │ └── uk │ │ │ └── co │ │ │ └── cacoethes │ │ │ └── gradle │ │ │ ├── LazybonesTemplatesPlugin.groovy │ │ │ ├── lazybones │ │ │ ├── LazybonesConventions.groovy │ │ │ └── TemplateConvention.groovy │ │ │ ├── tasks │ │ │ ├── BintrayGenericUpload.groovy │ │ │ ├── InstallTemplateRule.groovy │ │ │ ├── PackageTemplateRule.groovy │ │ │ └── PublishTemplateRule.groovy │ │ │ └── util │ │ │ └── NameConverter.groovy │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── uk.co.cacoethes.lazybones-templates.properties │ └── test │ └── groovy │ └── uk │ └── co │ └── cacoethes │ └── gradle │ ├── tasks │ └── BintrayGenericUploadSpec.groovy │ └── util │ └── NameConverterSpec.groovy ├── lazybones-templates ├── templates.gradle └── templates │ ├── asciidoctor-gradle │ ├── VERSION │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ │ └── asciidoc │ │ └── index.adoc │ ├── groovy-app │ ├── README.md │ ├── VERSION │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── lazybones.groovy │ └── src │ │ ├── main │ │ └── groovy │ │ │ └── .retain │ │ └── test │ │ └── groovy │ │ └── .retain │ ├── lazybones-project │ ├── README.md │ ├── VERSION │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── templates │ │ └── .retain │ └── spring-boot-actuator │ ├── README.md │ ├── VERSION │ ├── build.gradle │ ├── lazybones.groovy │ └── src │ ├── main │ ├── groovy │ │ └── sample │ │ │ └── SampleApplication.groovy │ └── resources │ │ └── application.properties │ └── test │ └── groovy │ └── sample │ └── SampleApplicationTests.groovy ├── media ├── lazybones-logo-64px.png ├── lazybones-logo-hires.png ├── lazybones-logo-readme.txt ├── lazybones-logo.idraw └── lazybones-logo.svg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .gradle/ 3 | .project 4 | .settings/ 5 | bin/ 6 | build/ 7 | /gradle.properties 8 | *.iml 9 | .idea 10 | out 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: groovy 2 | jdk: 3 | - oraclejdk7 4 | - oraclejdk8 5 | script: "./gradlew --no-daemon check" 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contribution Guidelines 2 | ======================= 3 | 4 | We love to see contributions to the project and have tried to make it easy to 5 | do so, for example by keeping its scope small and the code equally so. If you 6 | wish to contribute code, then please keep to the following guidelines to 7 | ensure consistency within the codebase and that we have happy users. 8 | 9 | Philosophy 10 | ---------- 11 | 12 | Our approach to the project is to keep it small and narrowly focused. Expect new 13 | features to be discussed in-depth before being accepted (or rejected). This is 14 | not a framework, but a simple, easy-to-use tool for creating template projects. 15 | It offers useful utility functions to template authors, but nothing more. 16 | 17 | Documentation 18 | ------------- 19 | 20 | If you contribute anything that changes the behaviour of the application, 21 | document it in the README! This includes new features, additional variants 22 | of behaviour and breaking changes. 23 | 24 | Make a note of breaking changes in the pull request because they will need 25 | to go into the release notes. 26 | 27 | Testing 28 | ------- 29 | 30 | This project uses [Spock](http://dosc.spockframework.org/) for its tests. Although 31 | any tests are better than none, Spock tests will be looked on more favourably than 32 | other types (such as JUnit). Plus you'll find writing the tests so much nicer! 33 | 34 | Unit tests are a nice to have, but it's the integration tests that are critical. 35 | These are run via 36 | 37 | ./gradlew integTest 38 | 39 | and launch the lazybones executable as a separate process. The output is captured 40 | so that you can verify the content. The tests reside in the `src/integTest` 41 | directory and extend `AbstractFunctionalSpec`. 42 | 43 | They use [Betamax](http://freeside.co/betamax) to intercept and replay web requests 44 | (such as to the Bintray REST API and download URLs). 45 | 46 | Commit messages 47 | --------------- 48 | 49 | It may seem anal to request a particular format for commit messages, but these 50 | are a historical record of what's happening in the code base and consistency 51 | makes investigating that history much easier. 52 | 53 | Please follow the advice of the [Phonegap guys](https://github.com/phonegap/phonegap/wiki/Git-Commit-Message-Format) 54 | when crafting commit messages. The advice basically comes down to: 55 | 56 | * First line should be maximum 50 characters long 57 | * It should summarise the change and use imperative present tense 58 | * The rest of the commit message should come after a blank line 59 | * We encourage you to use Markdown syntax in the rest of the commit message 60 | * Preferably keep to an 80 character limit on lines in the rest of the message. 61 | 62 | If a commit is related to a particular issue, put the issue number after a 63 | hash (#) somewhere in the detail. You can put the issue number in the first 64 | line summary, but only if you can also fit in a useful summary of what was 65 | changed in the commit. 66 | 67 | Here's an example git message: 68 | 69 | > Make create's version argument optional. 70 | > 71 | > Implements issue #3. If the user doesn't provide an explicit version, 72 | > lazybones retrieves the latest version from Bintray. Integration tests 73 | > added for the `create` command as well. 74 | 75 | Formatting 76 | ---------- 77 | 78 | The rules are simple: use the same formatting as the rest of the code. The 79 | following is a list of the styles we are particularly particular about: 80 | 81 | * 4 space indent, no tabs 82 | * a space between if/elseif/catch/etc. keywords and the parenthesis 83 | * elseif/else/catch on their own lines 84 | 85 | If in doubt, submit the change and mention in the pull request that you're not 86 | sure about a particular style you used. We'd rather have the contribution and 87 | fix any minor problems than not have the contribution at all. 88 | 89 | Ultimately, be aware that the maintainers don't have much time to dedicate to 90 | processing pull requests, so the less work they have to do the more likely and 91 | quickly they can merge those pull requests in. 92 | 93 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | apply plugin: "idea" 3 | apply plugin: "eclipse" 4 | } 5 | -------------------------------------------------------------------------------- /codenarc.groovy: -------------------------------------------------------------------------------- 1 | ruleset { 2 | description 'Lazybones Codenarc Rules' 3 | 4 | ruleset('rulesets/basic.xml') 5 | ruleset('rulesets/braces.xml') { 6 | 'IfStatementBraces' enabled: false 7 | 'ElseBlockBraces' enabled: false 8 | } 9 | ruleset('rulesets/concurrency.xml') 10 | ruleset('rulesets/convention.xml') { 11 | 'NoDef' enabled: false 12 | } 13 | ruleset('rulesets/design.xml') { 14 | 'Instanceof' enabled: false 15 | } 16 | ruleset('rulesets/dry.xml') 17 | ruleset('rulesets/exceptions.xml') 18 | ruleset('rulesets/formatting.xml') { 19 | 'SpaceAroundMapEntryColon' characterAfterColonRegex: /\s/ 20 | } 21 | ruleset('rulesets/generic.xml') 22 | ruleset('rulesets/groovyism.xml') { 23 | 'GetterMethodCouldBeProperty' enabled: false 24 | } 25 | ruleset('rulesets/imports.xml') { 26 | 'MisorderedStaticImports' enabled: false 27 | } 28 | ruleset('rulesets/jdbc.xml') 29 | ruleset('rulesets/junit.xml') 30 | ruleset('rulesets/logging.xml') { 31 | 'Println' enabled: false 32 | 'SystemOutPrint' enabled: false 33 | } 34 | ruleset('rulesets/naming.xml') { 35 | 'VariableName' finalRegex: "[a-z][a-zA-Z0-9]*" 36 | } 37 | ruleset('rulesets/security.xml') { 38 | 'JavaIoPackageAccess' enabled: false 39 | 'SystemExit' enabled: false 40 | 'JavaIoPackageAccess' enabled: false 41 | } 42 | ruleset('rulesets/size.xml') 43 | ruleset('rulesets/unnecessary.xml') { 44 | 45 | // disabling due to code narc bug => http://sourceforge.net/tracker/?func=detail&atid=1126573&aid=3524882&group_id=250145 46 | 'UnnecessaryPackageReference' enabled: false 47 | 48 | 'UnnecessaryGString' enabled: false 49 | 50 | 'UnnecessaryReturnKeyword' enabled: false 51 | 'UnnecessaryElseStatement' enabled: false 52 | } 53 | ruleset('rulesets/unused.xml') 54 | } 55 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Dec 20 23:45:20 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lazybones-app/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /lazybones-app/gvm-release-credentials.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/gvm-release-credentials.gpg -------------------------------------------------------------------------------- /lazybones-app/src/integTest/groovy/uk/co/cacoethes/lazybones/HelpFunctionalSpec.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | class HelpFunctionalSpec extends AbstractFunctionalSpec { 4 | def "A missing command prints the help text"() { 5 | when: "I run lazybones without any arguments" 6 | def exitCode = runCommand([], baseWorkDir) 7 | 8 | then: "It displays the help" 9 | exitCode == 0 10 | outputContainsHelpMessage() 11 | } 12 | 13 | def "The help command displays a list of available commands"() { 14 | when: "I run the help command" 15 | def exitCode = runCommand(["help"], baseWorkDir) 16 | 17 | then: "It displays the help" 18 | exitCode == 0 19 | outputContainsHelpMessage() 20 | } 21 | 22 | def "help option prints out the command specific help"() { 23 | when: "I run lazybones with ${option} for command ${command}" 24 | def exitCode = runCommand([option, command], baseWorkDir) 25 | 26 | then: "It displays the help" 27 | exitCode == 0 28 | output.contains("USAGE") 29 | output =~ /\s+${command}\s+/ 30 | !(output =~ /Exception/) 31 | 32 | where: 33 | option | command 34 | "-h" | "list" 35 | "--help"| "list" 36 | "-h" | "info" 37 | "--help"| "info" 38 | } 39 | 40 | def "a command with the help option prints the command specific help"() { 41 | when: "I run lazybones with command ${command} and option ${option}" 42 | def exitCode = runCommand([command, option], baseWorkDir) 43 | 44 | then: "It displays the help" 45 | exitCode == 0 46 | output.contains("USAGE") 47 | output =~ /\s+${command}\s+/ && 48 | !(output =~ /Exception/) 49 | println output 50 | 51 | where: 52 | option | command 53 | "-h" | "list" 54 | "--help"| "list" 55 | "-h" | "create" 56 | "--help"| "create" 57 | } 58 | 59 | def "help option prints out the help command"() { 60 | when: "I run lazybones with ${option}" 61 | def exitCode = runCommand([option], baseWorkDir) 62 | 63 | then: "It displays the help" 64 | exitCode == 0 65 | outputContainsHelpMessage() 66 | 67 | where: 68 | option << ['-h', '--help'] 69 | 70 | } 71 | 72 | boolean outputContainsHelpMessage() { 73 | output.contains("Available commands") && 74 | output =~ /\s+create\s+/ && 75 | !(output =~ /Exception/) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/groovy/uk/co/cacoethes/lazybones/InfoFunctionalSpec.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import co.freeside.betamax.Betamax 4 | import co.freeside.betamax.Recorder 5 | import org.junit.* 6 | 7 | class InfoFunctionalSpec extends AbstractFunctionalSpec { 8 | @Rule Recorder recorder = new Recorder() 9 | 10 | void setup() { 11 | initProxy(recorder.proxy.address()) 12 | } 13 | 14 | @Betamax(tape='info-tape') 15 | def "Info command prints all available info for a package"() { 16 | when: "I run lazybones with the info command for the ratpack template" 17 | def exitCode = runCommand(["info", "ratpack"], baseWorkDir) 18 | 19 | then: "It displays the ratpack info" 20 | exitCode == 0 21 | output =~ /\bName:\s+ratpack\b/ 22 | output =~ /\bLatest:\s+0.1\b/ 23 | output =~ /\bOwner:\s+pledbrook\b/ 24 | output =~ /\bVersions:\s+0.1\b/ 25 | output =~ /\bDescription:\s+Template for a basic Groovy-based Ratpack application/ 26 | !(output =~ /Exception/) 27 | } 28 | 29 | @Betamax(tape='info-tape') 30 | def "Info command prints only info that is available for a package, when that is just a subset of all info"() { 31 | when: "I run lazybones with the info command for the ratpack-lite template" 32 | def exitCode = runCommand(["info", "ratpack-lite"], baseWorkDir) 33 | 34 | then: "It displays the ratpack info" 35 | exitCode == 0 36 | output =~ /\bName:\s+ratpack-lite\b/ 37 | output =~ /\bLatest:\s+0.1\b/ 38 | output =~ /\bOwner:\s+pledbrook\b/ 39 | output =~ /\bVersions:\s+0.1\b/ 40 | !(output =~ /\bDescription:\s+/) 41 | !(output =~ /Exception/) 42 | } 43 | 44 | @Betamax(tape='info-tape') 45 | def "Info command notifies user when a package can't be found"() { 46 | when: "I run lazybones with the info command for a non-existent template" 47 | def exitCode = runCommand(["info", "dummy"], baseWorkDir) 48 | 49 | then: "It returns a non-zero exit code and displays an error message" 50 | exitCode == 1 51 | output =~ /Cannot find a template named 'dummy'/ 52 | } 53 | 54 | @Betamax(tape='info-tape') 55 | def "Info command prints useful error message if no versions of a template are available"() { 56 | when: "I run lazybones with the info command for a template with no versions" 57 | def exitCode = runCommand(["info", "lazybones-project"], baseWorkDir) 58 | 59 | then: "It returns a non-zero exit code and displays an error message" 60 | exitCode == 1 61 | output =~ /No version of 'lazybones-project' has been published/ 62 | } 63 | 64 | def "Info command displays usage when incorrect number of arguments are provided"() { 65 | when: "I run lazybones with the info command without an extra argument" 66 | def exitCode = runCommand(["info"], baseWorkDir) 67 | 68 | then: "It returns a non-zero exit code and displays an error message" 69 | exitCode == 1 70 | output =~ /Incorrect number of arguments/ 71 | output =~ /USAGE:/ 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/groovy/uk/co/cacoethes/lazybones/MainFunctionalSpec.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import co.freeside.betamax.Betamax 4 | import co.freeside.betamax.Recorder 5 | import org.junit.Rule 6 | 7 | /** 8 | * Functional tests for the code explicitly in LazybonesMain that isn't tested 9 | * implicitly by other functional tests. At the moment, verifies the logging levels. 10 | */ 11 | class MainFunctionalSpec extends AbstractFunctionalSpec { 12 | @Rule Recorder recorder = new Recorder() 13 | 14 | void setup() { 15 | initProxy(recorder.proxy.address()) 16 | } 17 | 18 | def "Error message displayed if command unrecognised"() { 19 | when: "I run lazybones with an unknown command" 20 | def exitCode = runCommand([option, "unknown"], baseWorkDir) 21 | 22 | then: "The exit code is non-zero and a simple message is displayed" 23 | exitCode != 0 24 | output =~ "There is no command 'unknown'" 25 | !(output =~ "Exception") 26 | 27 | where: 28 | option << ["--verbose", "--quiet", "--info", "--logLevel=WARNING"] 29 | } 30 | 31 | @Betamax(tape="create-tape") 32 | def "Verbose command line option displays extra info"() { 33 | when: "I run lazybones with the create command and the 'verbose' option" 34 | runCommand([option, "create", "ratpack", "ratapp"], baseWorkDir) 35 | 36 | then: "I see INFO and FINE messages" 37 | output.contains "Project created in ratapp" 38 | output.contains "Searching for ratpack in " 39 | 40 | where: 41 | option << ["-v", "--verbose", "--logLevel=FINER"] 42 | } 43 | 44 | @Betamax(tape="create-tape") 45 | def "Quiet command line option displays minimal info"() { 46 | when: "I run lazybones with the create command and the 'quiet' option" 47 | runCommand([option, "create", "ratpack", "ratapp"], baseWorkDir) 48 | 49 | then: "I see only WARNING and SEVERE messages" 50 | !output.contains("Project created in ratapp") 51 | !output.contains("Searching for ratpack in ") 52 | 53 | where: 54 | option << ["-q", "--quiet", "--logLevel=WARNING"] 55 | } 56 | 57 | @Betamax(tape="create-tape") 58 | def "Info command line option displays normal level of information"() { 59 | when: "I run lazybones with the create command and the 'info' option" 60 | runCommand([option, "create", "ratpack", "ratapp"], baseWorkDir) 61 | 62 | then: "I see INFO messages" 63 | output.contains "Project created in ratapp" 64 | !output.contains("Searching for ratpack in ") 65 | 66 | where: 67 | option << ["--info", "--logLevel=INFO"] 68 | } 69 | 70 | def "The version option prints Lazybones' version"() { 71 | given: "The version from the lazybones.properties file" 72 | def appVersion = readLazybonesVersion() 73 | 74 | when: "I run lazybones with the version option" 75 | def exitCode = runCommand(["--version"], baseWorkDir) 76 | 77 | then: "I see the app version printed out" 78 | exitCode == 0 79 | output.contains "Lazybones version $appVersion" 80 | } 81 | 82 | def "An unknown option prints out usage"() { 83 | when: "I run lazybones with an unknown option" 84 | def exitCode = runCommand(["--unknown", "help"], baseWorkDir) 85 | 86 | then: "The exit code is non-zero and a usage string is displayed" 87 | exitCode != 0 88 | output =~ /'unknown' is not a recognized option/ 89 | output =~ /USAGE: lazybones \[OPTIONS\] \[COMMAND\]/ 90 | !(output =~ /Exception/) 91 | 92 | and: "The message displayed does not include the log level" 93 | !(output =~ /^SEVERE:\b/) 94 | 95 | where: 96 | option << ["--verbose", "--quiet", "--info", "--logLevel=WARNING"] 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/groovy/uk/co/cacoethes/lazybones/OfflineFunctionalSpec.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import co.freeside.betamax.Betamax 4 | import org.apache.commons.io.FileUtils 5 | import spock.lang.Unroll 6 | 7 | class OfflineFunctionalSpec extends AbstractFunctionalSpec { 8 | 9 | void setup() { 10 | // Create dummy proxy to ensure the app can't access the internet. 11 | initProxy(new InetSocketAddress("localhost", 61431)) 12 | } 13 | 14 | @Betamax(tape="create-tape") 15 | @Unroll 16 | def "list command prints local packages and mappings when offline #showsExceptionLabel#extraOutputLabel"() { 17 | given: "A template in the cache matching a remote one" 18 | def ratpackPackage = new File(cacheDirPath, "ratpack-0.1.zip") 19 | if (!ratpackPackage.exists()) { 20 | FileUtils.touch(ratpackPackage) 21 | filesToDelete << ratpackPackage 22 | } 23 | 24 | when: "I run lazybones with the list command" 25 | def exitCode = runCommand(otherOptions + ["list"], baseWorkDir) 26 | 27 | then: "It displays only the template mappings and cached packages" 28 | exitCode == 0 29 | output =~ /(?m)^Available mappings\s+/ + 30 | /customRatpack -> http:\/\/dl.dropboxusercontent.com\/u\/29802534\/custom-ratpack.zip\s+/ + 31 | /doesNotExist -> file:\/\/\/does\/not\/exist/ 32 | output =~ /(?m)^Cached templates\s+/ + 33 | /Oops-stuff 1.0.4\s+/ + 34 | /ratpack 0.1\s+/ + 35 | /subtemplates-tmpl 0.1\s+/ + 36 | /test-handlebars 0.1.1\s+/ + 37 | /test-handlebars-default 0.1/ 38 | 39 | and: "It displays an offline message, with optional explanation and stacktrace" 40 | output =~ /(?m)\(Offline mode - run with -v or --stacktrace to find out why\)\s+/ + 41 | extraOutput + (hidesException ? "" : /java\.net\.ConnectException.*/) 42 | 43 | where: 44 | otherOptions | hidesException | extraOutput 45 | [] | true | "" 46 | ["-v"] | true | /\(Error message: ConnectException - Connection refused.*\)\s+/ 47 | ["--stacktrace"] | false | "" 48 | 49 | showsExceptionLabel = hidesException ? "without stacktrace" : "with stacktrace" 50 | extraOutputLabel = extraOutput ? " and with the error message" : "" 51 | } 52 | 53 | @Unroll 54 | def "info command displays error when offline #showsExceptionLabel#extraOutputLabel"() { 55 | when: "I run lazybones with the info command" 56 | def exitCode = runCommand(otherOptions + ["info", "afterburnerfx"], baseWorkDir) 57 | 58 | then: "It errors out" 59 | exitCode != 0 60 | 61 | and: "It displays an offline message, with optional explanation and stacktrace" 62 | output =~ /(?m)\(Offline mode - run with -v or --stacktrace to find out why\)\s+/ + 63 | extraOutput + (hidesException ? "" : /.*^java\.net\.ConnectException.*/) 64 | output =~ /(?m)^Cannot fetch package info/ 65 | 66 | where: 67 | otherOptions | hidesException | extraOutput 68 | [] | true | "" 69 | ["-v"] | true | /\(Error message: ConnectException - Connection refused.*\)\s+/ 70 | ["--stacktrace"] | false | "" 71 | 72 | showsExceptionLabel = hidesException ? "without stacktrace" : "with stacktrace" 73 | extraOutputLabel = extraOutput ? " and with the error message" : "" 74 | } 75 | 76 | @Unroll 77 | def "create command fails gracefully when offline and it needs internet #showsExceptionLabel#extraOutputLabel"() { 78 | when: "I run the create command without a package version" 79 | def exitCode = runCommand(otherOptions + ["create", "afterburnerfx", "afxapp"], baseWorkDir) 80 | 81 | then: "It errors out" 82 | exitCode != 0 83 | 84 | and: "It displays an offline message, with optional explanation and stacktrace" 85 | output =~ /(?m)\(Offline mode - run with -v or --stacktrace to find out why\)\s+/ + 86 | extraOutput + (hidesException ? "" : /.*^java\.net\.ConnectException.*/) 87 | output =~ /(?m)^Cannot create a new project when the template isn't locally cached or no version is specified/ 88 | 89 | where: 90 | otherOptions | hidesException | extraOutput 91 | [] | true | "" 92 | ["-v"] | true | /\(Error message: ConnectException - Connection refused.*\)\s+/ 93 | ["--stacktrace"] | false | "" 94 | 95 | showsExceptionLabel = hidesException ? "without stacktrace" : "with stacktrace" 96 | extraOutputLabel = extraOutput ? " and with the error message" : "" 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/groovy/uk/co/cacoethes/lazybones/ProxyFunctionalSpec.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import co.freeside.betamax.Betamax 4 | import co.freeside.betamax.Recorder 5 | import io.netty.handler.codec.http.HttpRequest 6 | import org.junit.Rule 7 | import org.littleshoot.proxy.ChainedProxy 8 | import org.littleshoot.proxy.ChainedProxyAdapter 9 | import org.littleshoot.proxy.ChainedProxyManager 10 | import org.littleshoot.proxy.HttpProxyServer 11 | import org.littleshoot.proxy.ProxyAuthenticator 12 | import org.littleshoot.proxy.impl.DefaultHttpProxyServer 13 | 14 | class ProxyFunctionalSpec extends AbstractFunctionalSpec { 15 | @Rule Recorder recorder = new Recorder() 16 | HttpProxyServer proxy 17 | 18 | void setup() { 19 | proxy = DefaultHttpProxyServer.bootstrap(). 20 | withPort(0). 21 | withProxyAuthenticator(new ProxyAuthenticator() { 22 | @Override 23 | boolean authenticate(String userName, String password) { 24 | return userName == "dummy" && password == "password" 25 | } 26 | }). 27 | withChainProxyManager(new ChainedProxyManager() { 28 | @Override 29 | void lookupChainedProxies(HttpRequest httpRequest, Queue chainedProxies) { 30 | chainedProxies.add(new ChainedProxyAdapter() { 31 | @Override 32 | InetSocketAddress getChainedProxyAddress() { 33 | return new InetSocketAddress(recorder.proxyHost, recorder.proxyPort) 34 | } 35 | }) 36 | } 37 | }).start() 38 | initProxy(proxy.listenAddress) 39 | 40 | filesToDelete << new File(cacheDirPath, "ratpack-0.1.zip") 41 | } 42 | 43 | void cleanup() { 44 | proxy.stop() 45 | } 46 | 47 | @Betamax(tape="create-tape") 48 | def "Create command works with correct proxy credentials"() { 49 | given: "Correct proxy credentials" 50 | env["JAVA_OPTS"] += " -Dlazybones.systemProp.http.proxyUser=dummy" 51 | env["JAVA_OPTS"] += " -Dlazybones.systemProp.http.proxyPassword=password" 52 | 53 | when: "I run lazybones with the create command for the ratpack template" 54 | def exitCode = runCommand(["create", "ratpack", "0.1", "ratapp"], baseWorkDir) 55 | 56 | then: "It unpacks the template, retaining file permissions" 57 | exitCode == 0 58 | def appDir = new File(baseWorkDir, "ratapp") 59 | appDir.exists() 60 | new File(appDir, "gradlew").canExecute() 61 | new File(appDir, "src/main/groovy").isDirectory() 62 | new File(appDir, "src/ratpack/public/index.html").isFile() 63 | 64 | and: "It says that the given version of the package is being installed in the target directory" 65 | output =~ /Creating project from template ratpack 0.1 in 'ratapp'/ 66 | } 67 | 68 | @Betamax(tape="create-tape") 69 | def "Create command triggers 407 if invalid proxy credentials provided"() { 70 | given: "Incorrect proxy credentials" 71 | env["JAVA_OPTS"] += " -Dlazybones.systemProp.http.proxyUser=dilbert" 72 | env["JAVA_OPTS"] += " -Dlazybones.systemProp.http.proxyPassword=password" 73 | 74 | when: "I run lazybones with the create command for the ratpack template" 75 | println "Env $env" 76 | println "Props ${System.properties}" 77 | def exitCode = runCommand(["create", "ratpack", "0.1", "ratapp"], baseWorkDir) 78 | 79 | then: "The command reports a 407 error" 80 | exitCode != 0 81 | output =~ /Unexpected failure: 407 Proxy Authentication Required/ 82 | } 83 | 84 | @Betamax(tape="create-tape") 85 | def "Create command triggers 407 if no proxy credentials provided"() { 86 | when: "I run lazybones with the create command for the ratpack template" 87 | println "Env $env" 88 | println "Props ${System.properties}" 89 | def exitCode = runCommand(["create", "ratpack", "0.1", "ratapp"], baseWorkDir) 90 | 91 | then: "The command reports a 407 error" 92 | exitCode != 0 93 | output =~ /Unexpected failure: 407 Proxy Authentication Required/ 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/resources/BetamaxConfig.groovy: -------------------------------------------------------------------------------- 1 | betamax { 2 | tapeRoot = new File('src/integTest/resources/betamax/tapes') 3 | useProxy = true 4 | proxyPort = 5555 5 | proxyTimeout = 5000 6 | defaultMode = TapeMode.READ_WRITE 7 | ignoreHosts = ['localhost', '127.0.0.1'] 8 | ignoreLocalhost = false 9 | sslSupport = true 10 | } 11 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/resources/betamax/tapes/list_tape.yaml: -------------------------------------------------------------------------------- 1 | !tape 2 | name: list-tape 3 | interactions: 4 | - recorded: 2014-06-17T10:13:52.387Z 5 | request: 6 | method: GET 7 | uri: https://bintray.com/api/v1/repos/pledbrook/lazybones-templates/packages 8 | headers: 9 | Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 10 | Accept-Encoding: gzip 11 | Cache-Control: no-cache 12 | Connection: Close 13 | Host: bintray.com 14 | Pragma: no-cache 15 | User-Agent: Java/1.7.0_45 16 | response: 17 | status: 200 18 | headers: 19 | Content-Encoding: gzip 20 | Content-Type: application/json 21 | Date: Tue, 17 Jun 2014 10:13:52 GMT 22 | Server: nginx/1.4.4 23 | body: !!binary |- 24 | H4sIAAAAAAAAA5XQMQ7CMBAEwL+4xh/gK4hi7Vwik8M253MgQfydAokK0NHPrlZ7uLuMM7m9mwQDk6/cp5S90rkylNzOccozDW6v0umxe/tMoTPsfgLxOlvga8ilpzg3haghI9CKaGsvZVk9p/BHLSclAz9hgQ9oKRrwIKVe0wYZ7KtRqwFjVJLQJZOMN4NnbGsomZqvUk4UPx4+gtvH0A/TqqQ8+VCKekTt0CLfu49P3Nrk54wCAAA= 25 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/resources/dummy-app.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/resources/dummy-app.zip -------------------------------------------------------------------------------- /lazybones-app/src/integTest/resources/managed-config.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/resources/test-config.groovy: -------------------------------------------------------------------------------- 1 | bintrayRepositories = ["pledbrook/lazybones-templates"] 2 | 3 | templates { 4 | mappings { 5 | customRatpack = "http://dl.dropboxusercontent.com/u/29802534/custom-ratpack.zip" 6 | doesNotExist = "file:///does/not/exist" 7 | } 8 | } 9 | 10 | test.option.override = "Just an option" 11 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/Oops-stuff/README.md: -------------------------------------------------------------------------------- 1 | Template project with non-conventional name 2 | ------------------------------------------- 3 | 4 | This template is used to test the Gradle plugin's handling of non-conventional 5 | directory names, i.e. those that don't satisfy the lowercase hyphenated requirement. 6 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/Oops-stuff/VERSION: -------------------------------------------------------------------------------- 1 | 1.0.4 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/Oops-stuff/src/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/Oops-stuff/src/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/README.md: -------------------------------------------------------------------------------- 1 | Gradle Groovy project template 2 | ----------------------------- 3 | 4 | You have just created a basic Groovy application. It provides a standard 5 | project structure, and Spock for writing tests 6 | 7 | 8 | | 9 | +- src 10 | | 11 | | 12 | +- main 13 | | | 14 | | +- groovy 15 | | 16 | +- // App classes in here! 17 | | 18 | +- test 19 | | 20 | +- groovy 21 | | 22 | +- // Spock tests in here! 23 | 24 | That's it! You can build / test the application with gradle 25 | 26 | ./gradlew 27 | 28 | 29 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "groovy" 2 | apply plugin: "maven" 3 | 4 | sourceCompatibility = "1.6" 5 | targetCompatibility = "1.6" 6 | version = "${version}" 7 | <% if (group) { %>group = "${group}"<% } %> 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | compile "org.codehaus.groovy:groovy:2.1.3" 15 | testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' 16 | } 17 | 18 | task wrapper(type: Wrapper) { 19 | gradleVersion = '1.5' 20 | } 21 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/subtemplates-tmpl/gradle.properties -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/subtemplates-tmpl/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 25 08:58:10 BST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip 7 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/lazybones.groovy: -------------------------------------------------------------------------------- 1 | // Specify SCM excludes 2 | scmExclusions "*.iws", "build/", "*.log", ".lazybones/" 3 | 4 | def filterProperties = [:] 5 | filterProperties.group = ask("Define value for 'group': ", null, "group") 6 | filterProperties.version = ask("Define value for 'version' [0.1]: ", "0.1", "version") 7 | 8 | processTemplates("build.gradle", filterProperties) 9 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/src/main/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/subtemplates-tmpl/src/main/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtemplates-tmpl/src/test/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/subtemplates-tmpl/src/test/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-bad/README.md: -------------------------------------------------------------------------------- 1 | You've created a new controller in (somewhere) -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-bad/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-bad/lazybones.groovy: -------------------------------------------------------------------------------- 1 | throw new FileNotFoundException("Just a test error") 2 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-controller/Controller.groovy.gtpl: -------------------------------------------------------------------------------- 1 | package ${pkg} 2 | 3 | class ${cls}Controller { 4 | static scaffold = true 5 | } 6 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-controller/README.md: -------------------------------------------------------------------------------- 1 | You've created a new controller in (somewhere) -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-controller/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-controller/lazybones.groovy: -------------------------------------------------------------------------------- 1 | import org.apache.commons.io.FileUtils 2 | import org.apache.commons.io.FilenameUtils 3 | 4 | import static org.apache.commons.io.FilenameUtils.concat 5 | 6 | def params = [:] 7 | params.pkg = ask("Define value for the package: ", null, "package") 8 | params.cls = ask("Define value for class name: ", null, "class").capitalize() 9 | 10 | processTemplates("Controller.groovy", params) 11 | 12 | if (tmplQualifiers) { 13 | println "Found command qualifiers: ${tmplQualifiers}" 14 | } 15 | 16 | def pkgPath = params.pkg.replace('.' as char, '/' as char) 17 | def filename = params.cls.capitalize() + "Controller.groovy" 18 | def destFile = new File(projectDir, concat(concat("src/main/groovy", pkgPath), filename)) 19 | destFile.parentFile.mkdirs() 20 | 21 | FileUtils.moveFile(new File(templateDir, "Controller.groovy"), destFile) 22 | 23 | println "Created new controller ${FilenameUtils.normalize(destFile.path)}" 24 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-entity/Entity.groovy.gtpl: -------------------------------------------------------------------------------- 1 | package ${pkg} 2 | 3 | import grails.persistence.Entity 4 | 5 | @Entity(group="${parentGroup}", version="${parentVersion}") 6 | class ${cls} { 7 | String name 8 | } 9 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-entity/README.md: -------------------------------------------------------------------------------- 1 | You've created a new controller in (somewhere) -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-entity/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/subtmpl-entity/lazybones.groovy: -------------------------------------------------------------------------------- 1 | import org.apache.commons.io.FileUtils 2 | import org.apache.commons.io.FilenameUtils 3 | 4 | import static org.apache.commons.io.FilenameUtils.concat 5 | 6 | def params = [:] 7 | params.pkg = ask("Define value for the package: ", null, "package") 8 | params.cls = ask("Define value for class name: ", null, "class").capitalize() 9 | 10 | // Pass in parameters from the project template 11 | params.parentGroup = parentParams.group 12 | params.parentVersion = parentParams.version 13 | 14 | processTemplates("Entity.groovy", params) 15 | 16 | def pkgPath = params.pkg.replace('.' as char, '/' as char) 17 | def filename = params.cls.capitalize() + ".groovy" 18 | def destFile = new File(projectDir, concat(concat("src/main/groovy", pkgPath), filename)) 19 | destFile.parentFile.mkdirs() 20 | 21 | FileUtils.moveFile(new File(templateDir, "Entity.groovy"), destFile) 22 | 23 | println "Created new persistence entity ${FilenameUtils.normalize(destFile.path)}" 24 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/GroovyHello.groovy.gtpl: -------------------------------------------------------------------------------- 1 | println "hello ${foo}" 2 | println "\${bar} was unfiltered" 3 | println ${bar} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/NoSuffixGroovyHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello {{foo}}" 2 | println "${bar} was unfiltered" 3 | println {{bar}} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/PrintHello.groovy.hbs: -------------------------------------------------------------------------------- 1 | println "hello {{foo}}" 2 | println "${bar} was unfiltered" 3 | println {{bar}} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/README.md: -------------------------------------------------------------------------------- 1 | ## Template project using Handlbars as the default engine 2 | 3 | This is a simple test project template to verify that users can register the Handlebars template engine as the default. 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars-default/lazybones.groovy: -------------------------------------------------------------------------------- 1 | @Grab(group="uk.co.cacoethes", module="groovy-handlebars-engine", version="0.2") 2 | import uk.co.cacoethes.handlebars.HandlebarsTemplateEngine 3 | 4 | def hbsEngine = new HandlebarsTemplateEngine() 5 | registerEngine "hbs", hbsEngine 6 | registerDefaultEngine hbsEngine 7 | 8 | def model = [foo: "test", bar: 100] 9 | processTemplates "**/*Hello.groovy", model 10 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars/GroovyHello.groovy.gtpl: -------------------------------------------------------------------------------- 1 | println "hello ${foo}" 2 | println "\${bar} was unfiltered" 3 | println ${bar} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars/NoSuffixGroovyHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${foo}" 2 | println "\${bar} was unfiltered" 3 | println ${bar} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars/PrintHello.groovy.hbs: -------------------------------------------------------------------------------- 1 | println "hello {{foo}}" 2 | println "${bar} was unfiltered" 3 | println {{bar}} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars/README.md: -------------------------------------------------------------------------------- 1 | Template project using Handlbars 2 | -------------------------------- 3 | 4 | This is a simple test project template to verify that the Handlebars integration works. 5 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-handlebars/lazybones.groovy: -------------------------------------------------------------------------------- 1 | @Grab(group="uk.co.cacoethes", module="groovy-handlebars-engine", version="0.2") 2 | import uk.co.cacoethes.handlebars.HandlebarsTemplateEngine 3 | 4 | registerEngine "hbs", new HandlebarsTemplateEngine() 5 | 6 | def model = [foo: "test", bar: 100] 7 | processTemplates "**/*Hello.groovy", model 8 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/GroovyHello.groovy.gtpl: -------------------------------------------------------------------------------- 1 | println "hello ${foo}" 2 | println "\${bar} was unfiltered" 3 | println ${bar} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/NoSuffixGroovyHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${foo}" 2 | println "\${bar} was unfiltered" 3 | println ${bar} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/PrintHello.groovy.hbs: -------------------------------------------------------------------------------- 1 | println "hello {{foo}}" 2 | println "${bar} was unfiltered" 3 | println {{bar}} 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/README.md: -------------------------------------------------------------------------------- 1 | ## Template project with no default engine 2 | 3 | This is a simple test project template to verify that template processing still works if no default emplate engine is registered. 4 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-no-default-engine/lazybones.groovy: -------------------------------------------------------------------------------- 1 | @Grab(group="uk.co.cacoethes", module="groovy-handlebars-engine", version="0.2") 2 | import uk.co.cacoethes.handlebars.HandlebarsTemplateEngine 3 | 4 | registerEngine "hbs", new HandlebarsTemplateEngine() 5 | clearDefaultEngine() 6 | 7 | def model = [foo: "test", bar: 100] 8 | processTemplates "**/*Hello.groovy", model 9 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/README.md: -------------------------------------------------------------------------------- 1 | Gradle Groovy project template 2 | ----------------------------- 3 | 4 | You have just created a basic Groovy application. It provides a standard 5 | project structure, and Spock for writing tests 6 | 7 | 8 | | 9 | +- src 10 | | 11 | | 12 | +- main 13 | | | 14 | | +- groovy 15 | | 16 | +- // App classes in here! 17 | | 18 | +- test 19 | | 20 | +- groovy 21 | | 22 | +- // Spock tests in here! 23 | 24 | That's it! You can build / test the application with gradle 25 | 26 | ./gradlew 27 | 28 | 29 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/VERSION: -------------------------------------------------------------------------------- 1 | 0.2 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "groovy" 2 | apply plugin: "maven" 3 | 4 | sourceCompatibility = "1.6" 5 | targetCompatibility = "1.6" 6 | version = "${version}" 7 | <% if (group) { %>group = "${group}"<% } %> 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | compile "org.codehaus.groovy:groovy:2.1.3" 15 | testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' 16 | } 17 | 18 | test.maxParallelForks = ${maxThreads} 19 | 20 | task wrapper(type: Wrapper) { 21 | gradleVersion = '1.5' 22 | } 23 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradle.properties -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 25 08:58:10 BST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip 7 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/lazybones.groovy: -------------------------------------------------------------------------------- 1 | import static uk.co.cacoethes.util.NameType.* 2 | 3 | log.warning "User should see this log message" 4 | 5 | // Specify SCM excludes 6 | scmExclusions "*.iws", "build/", "*.log" 7 | 8 | // Test for regression of #135 - the argument to `ask()` should be coerced to 9 | // a string by default rather than trigger an exception. 10 | def maxThreads = 5 11 | def filterProperties = [:] 12 | filterProperties.group = ask("Define value for 'group': ", null, "group") 13 | filterProperties.version = ask("Define value for 'version' [0.1]: ", "0.1", "version") 14 | filterProperties.maxThreads = ask("Maximum number of threads to use [$maxThreads]: ", "${maxThreads}", "maxThreads") 15 | 16 | processTemplates("build.gradle", filterProperties) 17 | 18 | // subscripts 19 | def subProperties = include("sub1.groovy", ["maxThreads": maxThreads]) 20 | assert subProperties != null 21 | assert subProperties.size() == 3 22 | 23 | def testContent = new StringBuilder() 24 | testContent << "Version: " << lazybonesVersion << '\n' 25 | 26 | // Tests that the versions are provided as integers. 27 | assert lazybonesMajorVersion instanceof Number 28 | assert lazybonesMinorVersion instanceof Number 29 | 30 | if (lazybonesMajorVersion == 0 && lazybonesMinorVersion < 4) { 31 | testContent << "Your Lazybones version is too old\n" 32 | } 33 | else { 34 | testContent << "Your Lazybones version is OK - you're good to go!\n" 35 | } 36 | 37 | testContent << transformText("test-string", from: HYPHENATED, to: CAMEL_CASE) << '\n' 38 | testContent << transformText("ALongName", from: CAMEL_CASE, to: NATURAL) << '\n' 39 | 40 | try { 41 | transformText("test-string", from: HYPHENATED) 42 | } 43 | catch (IllegalArgumentException ex) { 44 | testContent << "Missing 'to' argument for transformText()" 45 | } 46 | 47 | new File(projectDir, "test.txt").text = testContent.toString() 48 | 49 | filterProperties.name = "foo" 50 | processTemplates("**/Print*.groovy", filterProperties) 51 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/main/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/main/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/main/groovy/PrintGoodbye.groovy: -------------------------------------------------------------------------------- 1 | println "goodbye ${name}" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/main/groovy/PrintHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${name}" 2 | println "\${bar} was unfiltered" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/main/groovy/UnfilteredHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${name}" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/test/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl-subscripts/src/test/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl-subscripts/sub1.groovy: -------------------------------------------------------------------------------- 1 | def subProperties = [:] 2 | subProperties.group = ask("Define value for 'group1': ", null, "group1") 3 | subProperties.version = ask("Define value for 'version1' [0.1]: ", "0.1", "version1") 4 | subProperties.maxThreads = ask("Maximum number of threads to use [$maxThreads]: ", "${maxThreads}", "maxThreads1") 5 | subProperties 6 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/README.md: -------------------------------------------------------------------------------- 1 | Gradle Groovy project template 2 | ----------------------------- 3 | 4 | You have just created a basic Groovy application. It provides a standard 5 | project structure, and Spock for writing tests 6 | 7 | 8 | | 9 | +- src 10 | | 11 | | 12 | +- main 13 | | | 14 | | +- groovy 15 | | 16 | +- // App classes in here! 17 | | 18 | +- test 19 | | 20 | +- groovy 21 | | 22 | +- // Spock tests in here! 23 | 24 | That's it! You can build / test the application with gradle 25 | 26 | ./gradlew 27 | 28 | 29 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/VERSION: -------------------------------------------------------------------------------- 1 | 0.2 -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "groovy" 2 | apply plugin: "maven" 3 | 4 | sourceCompatibility = "1.6" 5 | targetCompatibility = "1.6" 6 | version = "${version}" 7 | <% if (group) { %>group = "${group}"<% } %> 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | compile "org.codehaus.groovy:groovy:2.1.3" 15 | testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' 16 | } 17 | 18 | test.maxParallelForks = ${maxThreads} 19 | 20 | task wrapper(type: Wrapper) { 21 | gradleVersion = '1.5' 22 | } 23 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl/gradle.properties -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 25 08:58:10 BST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip 7 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/lazybones.groovy: -------------------------------------------------------------------------------- 1 | import static uk.co.cacoethes.util.NameType.* 2 | 3 | log.warning "User should see this log message" 4 | 5 | // Specify SCM excludes 6 | scmExclusions "*.iws", "build/", "*.log" 7 | 8 | // Test for regression of #135 - the argument to `ask()` should be coerced to 9 | // a string by default rather than trigger an exception. 10 | def maxThreads = 5 11 | def filterProperties = [:] 12 | filterProperties.group = ask("Define value for 'group': ", null, "group") 13 | filterProperties.version = ask("Define value for 'version' [0.1]: ", "0.1", "version") 14 | filterProperties.maxThreads = ask("Maximum number of threads to use [$maxThreads]: ", "${maxThreads}", "maxThreads") 15 | 16 | processTemplates("build.gradle", filterProperties) 17 | 18 | def testContent = new StringBuilder() 19 | testContent << "Version: " << lazybonesVersion << '\n' 20 | 21 | // Tests that the versions are provided as integers. 22 | assert lazybonesMajorVersion instanceof Number 23 | assert lazybonesMinorVersion instanceof Number 24 | 25 | if (lazybonesMajorVersion == 0 && lazybonesMinorVersion < 4) { 26 | testContent << "Your Lazybones version is too old\n" 27 | } 28 | else { 29 | testContent << "Your Lazybones version is OK - you're good to go!\n" 30 | } 31 | 32 | testContent << transformText("test-string", from: HYPHENATED, to: CAMEL_CASE) << '\n' 33 | testContent << transformText("ALongName", from: CAMEL_CASE, to: NATURAL) << '\n' 34 | 35 | try { 36 | transformText("test-string", from: HYPHENATED) 37 | } 38 | catch (IllegalArgumentException ex) { 39 | testContent << "Missing 'to' argument for transformText()" 40 | } 41 | 42 | new File(projectDir, "test.txt").text = testContent.toString() 43 | 44 | filterProperties.name = "foo" 45 | processTemplates("**/Print*.groovy", filterProperties) 46 | -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/src/main/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl/src/main/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/src/main/groovy/PrintGoodbye.groovy: -------------------------------------------------------------------------------- 1 | println "goodbye ${name}" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/src/main/groovy/PrintHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${name}" 2 | println "\${bar} was unfiltered" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/src/main/groovy/UnfilteredHello.groovy: -------------------------------------------------------------------------------- 1 | println "hello ${name}" -------------------------------------------------------------------------------- /lazybones-app/src/integTest/templates/test-tmpl/src/test/groovy/.retain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pledbrook/lazybones/377caef833b067f657170379a306f8be1415167a/lazybones-app/src/integTest/templates/test-tmpl/src/test/groovy/.retain -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/LazybonesScriptException.java: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones; 2 | 3 | /** 4 | * Thrown when the Lazybones post-install script for a template throws an error 5 | * of any sort. 6 | */ 7 | public class LazybonesScriptException extends RuntimeException { 8 | public LazybonesScriptException() { 9 | super(); 10 | } 11 | 12 | public LazybonesScriptException(String message) { 13 | super(message); 14 | } 15 | 16 | public LazybonesScriptException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public LazybonesScriptException(Throwable cause) { 21 | super(cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/NoVersionsFoundException.java: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones; 2 | 3 | /** 4 | * Thrown when a Lazybones template package doesn't have any versions associated 5 | * with it. This can happen if the package is defined in a repository but no 6 | * actual packages have been published. 7 | */ 8 | public class NoVersionsFoundException extends RuntimeException { 9 | private String packageName; 10 | 11 | public NoVersionsFoundException(String packageName) { 12 | super(getDefaultMessage(packageName)); 13 | this.packageName = packageName; 14 | } 15 | 16 | public NoVersionsFoundException(String packageName, Throwable cause) { 17 | super(getDefaultMessage(packageName), cause); 18 | this.packageName = packageName; 19 | } 20 | 21 | public String getPackageName() { return packageName; } 22 | 23 | private static String getDefaultMessage(final String packageName) { 24 | return "No versions of template '" + packageName + "' found"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/OptionParserBuilder.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import static uk.co.cacoethes.lazybones.Options.* 4 | 5 | import joptsimple.OptionParser 6 | 7 | /** 8 | * Simple static factory method class for creating a JOptSimple parser for the 9 | * Lazybones command line application. 10 | */ 11 | @SuppressWarnings("NoWildcardImports") 12 | class OptionParserBuilder { 13 | //TODO: Maybe move these to an enum 14 | 15 | static OptionParser makeOptionParser() { 16 | // These are the global options available for all commands. 17 | def parser = new OptionParser() 18 | parser.accepts(STACKTRACE, "Show stack traces when exceptions are thrown.") 19 | parser.acceptsAll([VERBOSE, VERBOSE_SHORT], "Display extra information when running commands.") 20 | parser.accepts(QUIET, "Show minimal output.") 21 | parser.accepts(INFO, "Show normal amount of output (default).") 22 | parser.accepts(LOG_LEVEL, "Set logging level, e.g. OFF, SEVERE, INFO, FINE, etc.").withRequiredArg() 23 | parser.accepts(VERSION, "Print out the Lazybones version and then end.") 24 | parser.acceptsAll([HELP, HELP_SHORT], "Print out the Lazybones help and then end.") 25 | 26 | // Ensures that only options up to the sub-command ('create, 'list', 27 | // etc.) are parsed. 28 | parser.posixlyCorrect(true) 29 | return parser 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/Options.java: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones; 2 | 3 | /** 4 | * A set of command-line options supported by the Lazybones app. 5 | */ 6 | public final class Options { 7 | public static final String HELP = "help"; 8 | public static final String HELP_SHORT = "h"; 9 | public static final String INFO = "info"; 10 | public static final String LOG_LEVEL = "logLevel"; 11 | public static final String QUIET = "quiet"; 12 | public static final String STACKTRACE = "stacktrace"; 13 | public static final String VERBOSE = "verbose"; 14 | public static final String VERBOSE_SHORT = "v"; 15 | public static final String VERSION = "version"; 16 | 17 | private Options() {} 18 | } 19 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/PackageInfo.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones 2 | 3 | import uk.co.cacoethes.lazybones.packagesources.PackageSource 4 | 5 | /** 6 | * Data class representing metadata about a Lazybones package. 7 | */ 8 | @groovy.transform.Canonical 9 | class PackageInfo { 10 | PackageSource source 11 | String name 12 | String latestVersion 13 | List versions 14 | String owner 15 | String description 16 | String url 17 | 18 | Boolean hasVersion() { 19 | versions as boolean 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/PackageNotFoundException.java: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones; 2 | 3 | /** 4 | * Thrown when a Lazybones template package can't be found in the cache or in 5 | * a remote repository. It may result from the lack of any package with the 6 | * required name or from the lack of a specific version of that package. In 7 | * the former case, the {@link #version} property will be {@code null}. 8 | */ 9 | public class PackageNotFoundException extends RuntimeException { 10 | private String name; 11 | private String version; 12 | 13 | public PackageNotFoundException(String packageName) { 14 | super(getDefaultMessage(packageName)); 15 | this.name = packageName; 16 | } 17 | 18 | public PackageNotFoundException(String packageName, String version) { 19 | super(getDefaultMessage(packageName)); 20 | this.name = packageName; 21 | this.version = version; 22 | } 23 | 24 | public PackageNotFoundException(String packageName, Throwable cause) { 25 | super(getDefaultMessage(packageName), cause); 26 | this.name = packageName; 27 | } 28 | 29 | public PackageNotFoundException(String packageName, String version, Throwable cause) { 30 | super(getDefaultMessage(packageName), cause); 31 | this.name = packageName; 32 | this.version = version; 33 | } 34 | 35 | public String getName() { return name; } 36 | public String getVersion() { return version; } 37 | 38 | private static String getDefaultMessage(final String packageName) { 39 | return "No template found with name '" + packageName + "'"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/commands/AbstractCommand.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones.commands 2 | 3 | import groovy.transform.CompileStatic 4 | import groovy.util.logging.Log 5 | import joptsimple.OptionException 6 | import joptsimple.OptionParser 7 | import joptsimple.OptionSet 8 | import uk.co.cacoethes.lazybones.config.Configuration 9 | import uk.co.cacoethes.lazybones.Options 10 | 11 | /** 12 | * Base class for most command implementations. It mostly provides help with 13 | * parsing extra command-specific options. 14 | */ 15 | @CompileStatic 16 | @Log 17 | @SuppressWarnings('FactoryMethodName') 18 | abstract class AbstractCommand implements Command { 19 | @Override 20 | @SuppressWarnings('UnnecessaryGetter') 21 | int execute(List args, Map globalOptions, Configuration config) { 22 | OptionSet cmdOptions = parseArguments(args, parameterRange) 23 | if (!cmdOptions) return 1 24 | 25 | if (cmdOptions.has(Options.HELP_SHORT)) { 26 | println getHelp(getDescription()) 27 | return 0 28 | } 29 | 30 | return doExecute(cmdOptions, globalOptions, config) 31 | } 32 | 33 | protected abstract int doExecute(OptionSet optionSet, Map globalOptions, Configuration config) 34 | 35 | /** 36 | * Returns the number of arguments this command can accept, on top of the 37 | * default ones handled by this class, such as {@code -h/--help}. 38 | */ 39 | protected abstract IntRange getParameterRange() 40 | 41 | /** 42 | * Returns the USAGE string for this command. 43 | */ 44 | protected abstract String getUsage() 45 | 46 | /** 47 | * Creates a JOptSimple parser. This should return a parser that is already 48 | * configured with the options supported by the command. By default this 49 | * returns an empty parser without any defined options. 50 | */ 51 | protected OptionParser createParser() { 52 | OptionParser parser = new OptionParser() 53 | parser.acceptsAll([Options.HELP_SHORT, Options.HELP], "Displays usage.") 54 | 55 | return doAddToParser(parser) 56 | } 57 | 58 | protected OptionParser doAddToParser(OptionParser parser) { return parser } 59 | 60 | /** 61 | * Uses the parser from {@link AbstractCommand#createParser()} to parse the 62 | * part of the command line specific to this command and returns a JOptSimple 63 | * set of parsed options. 64 | * @param args The command line arguments given to this command. 65 | * @param validArgCount A range specifying how many non-option arguments 66 | * (those that don't begin with '-' or '--') can be provided to the command. 67 | * If the number of non-option arguments falls outside this range, the method 68 | * returns null and prints an error to the console. 69 | * @return The option set, or {@code null} if the arguments can't be parsed 70 | * for whatever reason 71 | * 72 | * TODO This should probably throw exceptions in the case of errors. Too much 73 | * information is lost with a {@code null} return. 74 | */ 75 | @SuppressWarnings('ReturnNullFromCatchBlock') 76 | protected OptionSet parseArguments(List args, IntRange validArgCount) { 77 | try { 78 | def options = createParser().parse(args as String[]) 79 | 80 | if (!(options.nonOptionArguments().size() in validArgCount) && !options.has(Options.HELP_SHORT)) { 81 | log.severe getHelp("Incorrect number of arguments.") 82 | return null 83 | } 84 | 85 | return options 86 | } 87 | catch (OptionException ex) { 88 | log.severe getHelp(ex.message) 89 | return null 90 | } 91 | } 92 | 93 | /** 94 | * Returns a help string to display for usage. It incorporates the given 95 | * message, the command's usage string, and the supported JOptSimple options. 96 | */ 97 | String getHelp(String message) { 98 | def writer = new StringWriter() 99 | createParser().printHelpOn(writer) 100 | 101 | return """\ 102 | ${message} 103 | 104 | ${usage} 105 | ${writer}""" 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/commands/Command.java: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones.commands; 2 | 3 | import uk.co.cacoethes.lazybones.config.Configuration; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * An implementation of a sub-command for Lazybones. 10 | */ 11 | public interface Command { 12 | /** 13 | * The name of the command as given on the command line. It should be all 14 | * lowercase with hyphens between words. 15 | */ 16 | String getName(); 17 | 18 | /** 19 | * A single line description of the command. 20 | */ 21 | String getDescription(); 22 | 23 | /** 24 | * A block of text giving help/usage information for the command. This 25 | * block of text should incorporate the given message. 26 | */ 27 | String getHelp(String message); 28 | 29 | /** 30 | * Executes the command! 31 | * @param args A list of non-option arguments that were passed on the 32 | * command line. 33 | * @param globalOptions The global Lazybones options, such as {@code logLevel}. 34 | * @param config A reference to the Lazybones configuration (from config.groovy). 35 | * @return An exit code. A non-zero value indicates an error. 36 | */ 37 | int execute(List args, Map globalOptions, Configuration config); 38 | } 39 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/commands/Commands.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones.commands 2 | 3 | import uk.co.cacoethes.lazybones.config.Configuration 4 | 5 | /** 6 | * 7 | */ 8 | final class Commands { 9 | final static List getAll(Configuration config) { 10 | return Collections.unmodifiableList([ 11 | new CreateCommand(config), 12 | new ConfigCommand(config), 13 | new GenerateCommand(), 14 | new ListCommand(config), 15 | new InfoCommand(), 16 | new HelpCommand() ]) 17 | } 18 | 19 | private Commands() { } 20 | } 21 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/commands/CreateCommandInfo.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones.commands 2 | 3 | import groovy.transform.Canonical 4 | 5 | /** 6 | * Represents all the input data for the Lazybones create command, such as 7 | * template name, version, etc. 8 | */ 9 | @Canonical 10 | class CreateCommandInfo { 11 | TemplateArg packageArg 12 | String requestedVersion 13 | File targetDir 14 | } 15 | -------------------------------------------------------------------------------- /lazybones-app/src/main/groovy/uk/co/cacoethes/lazybones/commands/GenerateCommand.groovy: -------------------------------------------------------------------------------- 1 | package uk.co.cacoethes.lazybones.commands 2 | 3 | import groovy.util.logging.Log 4 | import joptsimple.OptionParser 5 | import joptsimple.OptionSet 6 | import org.apache.commons.io.FileUtils 7 | import uk.co.cacoethes.lazybones.config.Configuration 8 | import uk.co.cacoethes.lazybones.LazybonesScriptException 9 | import uk.co.cacoethes.lazybones.PackageNotFoundException 10 | import uk.co.cacoethes.util.ArchiveMethods 11 | 12 | import java.util.logging.Level 13 | 14 | /** 15 | * Implements Lazybone's generate command, which processes subtemplates in a 16 | * Lazybones-created project. The command unpacks the subtemplate into the 17 | * project's .lazybones directory and runs the post-install script. It's up 18 | * to that script to create directories and files in main project source tree. 19 | */ 20 | @Log 21 | class GenerateCommand extends AbstractCommand { 22 | static final File LAZYBONES_DIR = new File(".lazybones") 23 | 24 | final Map mappings 25 | 26 | static final String USAGE = """\ 27 | USAGE: generate