Remove Gradle Wrapper files from generator-polygene sources Add a Gradle task to copy the currently in-use Gradle Wrapper files into generator-polygene sources. This also means that you have to run it before running npm commands out of our Gradle build:
./gradlew :tools:generator-polygene:prepareTemplateGradleWrapper Or in short: ./gradlew :to:g:prepTGW The build will also automatically run this task prior to running the generator tests. See tools/generator-polygene/build.gradle Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/e996ce2e Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/e996ce2e Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/e996ce2e Branch: refs/heads/develop Commit: e996ce2e78b69b5591fe25ed32c58ba473134622 Parents: fb88c73 Author: Paul Merlin <[email protected]> Authored: Sun May 21 13:16:42 2017 +0200 Committer: Paul Merlin <[email protected]> Committed: Sun May 21 13:16:42 2017 +0200 ---------------------------------------------------------------------- .../distributions/DistributionsPlugin.groovy | 11 +- .../docs/tutorials/howto-releasing-apache.txt | 4 +- tools/generator-polygene/.gitignore | 1 + .../app/templates/buildtool/build.js | 8 +- .../app/templates/buildtool/gradle-wrapper.jar_ | Bin 51348 -> 0 bytes .../buildtool/gradle-wrapper.properties_ | 24 --- .../app/templates/buildtool/gradlew-bat.tmpl | 109 ----------- .../app/templates/buildtool/gradlew.tmpl | 183 ------------------- tools/generator-polygene/build.gradle | 24 ++- tools/generator-polygene/test/generator_test.js | 2 +- 10 files changed, 42 insertions(+), 324 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy index 2a1ea16..1dfd88b 100644 --- a/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/polygene/gradle/structure/distributions/DistributionsPlugin.groovy @@ -19,7 +19,6 @@ package org.apache.polygene.gradle.structure.distributions import groovy.transform.CompileStatic import groovy.transform.TypeCheckingMode -import org.apache.commons.io.FileUtils import org.apache.polygene.gradle.BasePlugin import org.apache.polygene.gradle.TaskGroups import org.apache.polygene.gradle.code.PublishedCodePlugin @@ -150,6 +149,7 @@ class DistributionsPlugin implements Plugin<Project> spec.exclude '**/build/**' // Build output spec.exclude 'gradlew*' // Gradle wrapper scripts spec.exclude 'gradle/wrapper/**' // Gradle wrapper + spec.exclude 'tools/generator-polygene/app/templates/buildtool/wrapper' // Project Generator Gradle wrapper spec.exclude '**/.gradle/**' // Gradle caches spec.exclude '**/.gradletasknamecache' // Gradle shell completion cache spec.exclude '**/node_modules/**' // Node's node_module dir @@ -307,6 +307,15 @@ class DistributionsPlugin implements Plugin<Project> assertFileAbsent 'gradle/wrapper/gradle-wrapper.jar' assertFileAbsent 'gradle/wrapper/gradle-wrapper.properties' assertFilePresent 'gradle/wrapper-install/build.gradle' + + def wrapperFiles = [] + unpackedSrcDistDir.traverse { File file -> + if(file.file && + (file.name.contains( 'gradle-wrapper' ) || file.name.contains('gradlew'))) { + wrapperFiles << file + } + } + assert wrapperFiles.empty } } project.tasks.create( TaskNames.BUILD_SOURCE_DIST, ExecLogged, { ExecLogged task -> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/manual/src/docs/tutorials/howto-releasing-apache.txt ---------------------------------------------------------------------- diff --git a/manual/src/docs/tutorials/howto-releasing-apache.txt b/manual/src/docs/tutorials/howto-releasing-apache.txt index 58b3873..9c2ae62 100644 --- a/manual/src/docs/tutorials/howto-releasing-apache.txt +++ b/manual/src/docs/tutorials/howto-releasing-apache.txt @@ -342,7 +342,9 @@ Publish the new version of the `generator-polygene` NPM package tagged as `beta` [source,shell] ---- -cd polygene-java/tools/generator-polygene +cd polygene-java +./gradlew tools:generator-polygene:prepareTemplateGradleWrapper +cd tools/generator-polygene npm publish --tag beta ---- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/.gitignore ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/.gitignore b/tools/generator-polygene/.gitignore new file mode 100644 index 0000000..dbd0a40 --- /dev/null +++ b/tools/generator-polygene/.gitignore @@ -0,0 +1 @@ +app/templates/buildtool/wrapper \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/app/templates/buildtool/build.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/build.js b/tools/generator-polygene/app/templates/buildtool/build.js index 630908f..17c0a68 100644 --- a/tools/generator-polygene/app/templates/buildtool/build.js +++ b/tools/generator-polygene/app/templates/buildtool/build.js @@ -27,11 +27,11 @@ module.exports = { } p.copyTemplate(p.ctx, 'buildtool/gradle-root.tmpl', 'build.gradle'); p.copyTemplate(p.ctx, 'buildtool/settings.tmpl', 'settings.gradle'); - p.copyTemplate(p.ctx, 'buildtool/gradlew.tmpl', 'gradlew'); - p.copyTemplate(p.ctx, 'buildtool/gradlew-bat.tmpl', 'gradlew.bat'); + p.copyTemplate(p.ctx, 'buildtool/wrapper/gradlew.tmpl', 'gradlew'); + p.copyTemplate(p.ctx, 'buildtool/wrapper/gradlew-bat.tmpl', 'gradlew.bat'); - p.ctx.fs.copy(p.ctx.templatePath('buildtool/gradle-wrapper.jar_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.jar')); - p.ctx.fs.copy(p.ctx.templatePath('buildtool/gradle-wrapper.properties_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.properties')); + p.ctx.fs.copy(p.ctx.templatePath('buildtool/wrapper/gradle-wrapper.jar_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.jar')); + p.ctx.fs.copy(p.ctx.templatePath('buildtool/wrapper/gradle-wrapper.properties_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.properties')); } }; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.jar_ ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.jar_ b/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.jar_ deleted file mode 100644 index 0087cd3..0000000 Binary files a/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.jar_ and /dev/null differ http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.properties_ ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.properties_ b/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.properties_ deleted file mode 100644 index 63a2f23..0000000 --- a/tools/generator-polygene/app/templates/buildtool/gradle-wrapper.properties_ +++ /dev/null @@ -1,24 +0,0 @@ -<%# - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * --%> -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/app/templates/buildtool/gradlew-bat.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradlew-bat.tmpl b/tools/generator-polygene/app/templates/buildtool/gradlew-bat.tmpl deleted file mode 100644 index 3d06f18..0000000 --- a/tools/generator-polygene/app/templates/buildtool/gradlew-bat.tmpl +++ /dev/null @@ -1,109 +0,0 @@ -<%# - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * --%> -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/app/templates/buildtool/gradlew.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/gradlew.tmpl b/tools/generator-polygene/app/templates/buildtool/gradlew.tmpl deleted file mode 100755 index 11c35cc..0000000 --- a/tools/generator-polygene/app/templates/buildtool/gradlew.tmpl +++ /dev/null @@ -1,183 +0,0 @@ -<%# - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * --%> -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/build.gradle ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/build.gradle b/tools/generator-polygene/build.gradle index 06eaa0e..c4589b7 100644 --- a/tools/generator-polygene/build.gradle +++ b/tools/generator-polygene/build.gradle @@ -36,6 +36,28 @@ def setsCurrentVersionToPackageJson = task( 'setsCurrentVersionToPackageJson' ) } /** + * Copy current Gradle Wrapper into generator templates. + * + * This is because we don't store the Gradle Wrapper in this project in order to + * - keep it in synch with the Gradle Wrapper used to build the whole Polygene SDK + * - don't include the Gradle Wrapper in the source distribution + */ +def prepareTemplateGradleWrapper = task( 'prepareTemplateGradleWrapper', type: Copy ) { + from( rootProject.rootDir ) { + include( 'gradlew' ) + rename { 'gradlew.tmpl' } + } + from( rootProject.rootDir ) { + include( 'gradlew.bat' ) + rename { 'gradlew-bat.tmpl' } + } + from( rootProject.file( 'gradle/wrapper/' ) ) { + rename { "${ it }_" } + } + into( 'app/templates/buildtool/wrapper' ) +} + +/** * Generate a Gradle init script that registers a maven repository with the currently built artifacts. * Used by the generator tests. */ @@ -61,7 +83,7 @@ def generateStageMavenRepositoryInitScript = task( 'generateStageMavenRepository * Runs the generator tests. */ def npmTest = task( 'npmTest', type: NpmTask ) { - dependsOn 'npmInstall', setsCurrentVersionToPackageJson, generateStageMavenRepositoryInitScript + dependsOn 'npmInstall', setsCurrentVersionToPackageJson, generateStageMavenRepositoryInitScript, prepareTemplateGradleWrapper description = 'Runs Polygene generator tests' args = [ 'run', 'test' ] inputs.file file( 'package.json' ) http://git-wip-us.apache.org/repos/asf/polygene-java/blob/e996ce2e/tools/generator-polygene/test/generator_test.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/test/generator_test.js b/tools/generator-polygene/test/generator_test.js index d4ee454..6589ef4 100644 --- a/tools/generator-polygene/test/generator_test.js +++ b/tools/generator-polygene/test/generator_test.js @@ -148,7 +148,7 @@ function test(appType, entityStore, indexing, serialization, caching, metrics, f var testDirName = testName.replace(new RegExp('[, ]','g'), '_'); it(testName, function () { - this.timeout(10000); + this.timeout(15000); return helpers.run(path.join(__dirname, '../app')) .inDir(path.join(__dirname, '../build/npm-test/'+testDirName)) .withPrompts({
