You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/05/07 16:12:54 UTC

[3/3] incubator-freemarker git commit: Very primitive, work in progress Gradle build script. Note the custom gradlew script, which works without gardlew-wrapper.jar; it's copied from Apache Bigtop (https://github.com/apache/bigtop/blob/master/gradle/wrap

Very primitive, work in progress Gradle build script. Note the custom gradlew script, which works without gardlew-wrapper.jar; it's copied from Apache Bigtop (https://github.com/apache/bigtop/blob/master/gradle/wrapper/gradle-wrapper.properties), but adds Cygwin support to it.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/d373a34d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/d373a34d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/d373a34d

Branch: refs/heads/3
Commit: d373a34d323826900e16ca2c36ad455deeabceb7
Parents: 2995fed
Author: ddekany <dd...@apache.org>
Authored: Sun May 7 18:11:14 2017 +0200
Committer: ddekany <dd...@apache.org>
Committed: Sun May 7 18:12:37 2017 +0200

----------------------------------------------------------------------
 README-gradle.md                         |  13 ++
 build.gradle                             | 131 +++++++++++++++
 gradle/wrapper/gradle-wrapper.jar        | Bin 0 -> 50518 bytes
 gradle/wrapper/gradle-wrapper.properties |   6 +
 gradlew                                  | 233 ++++++++++++++++++++++++++
 gradlew.bat                              |  90 ++++++++++
 settings.gradle                          |  20 +++
 7 files changed, 493 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/README-gradle.md
----------------------------------------------------------------------
diff --git a/README-gradle.md b/README-gradle.md
new file mode 100644
index 0000000..8b0fe67
--- /dev/null
+++ b/README-gradle.md
@@ -0,0 +1,13 @@
+The current gradle build is work in progress, so use the Ant build, as
+described in README.md!
+
+To build the project, go to the project home directory, and issue:
+
+    ./gradlew jar test
+  
+On Windows this won't work if you are using an Apache source release (as
+opposed to checking the project out from Git), as due to Apache policy
+restricton `gradle\wrapper\gradle-wrapper.jar` is missing from that. So you
+have to download that very common artifact from somewhere manually. On
+UN*X-like systems (and from under Cygwin shell) you don't need that jar, as
+our custom `gradlew` shell script does everything itself.

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..1a86c94
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id "ca.coglinc.javacc" version "2.4.0"
+}
+
+apply plugin: "java"
+
+version = "3.0.0-nightly"
+
+repositories {
+    // mavenLocal()
+    mavenCentral()
+}
+
+configurations.all {
+    // We use SLF4J with Logback binding, so exclude any other SLF4J bindings:
+    exclude group: "org.slf4j", module: "slf4j-log4j12"
+    exclude group: "org.slf4j", module: "slf4j-jdk14"
+
+    // We use xxx-over-slf4j to substitute logging libraries, so exclude them:
+    exclude group: "log4j", module: "log4j"
+    exclude group: "commons-logging", module: "commons-logging"
+
+    // xml-apis is part of the Java SE version for a good while; prevent old libraries pulling it in:
+    exclude group: "xml-apis", module: "xml-apis"
+}
+
+configurations.testCompile {
+    // Jetty pulls in its own version of Servlet/JSP classes, so don't inherit these from the "compile" configuration:
+    exclude group: "javax.servlet.jsp", module: "jsp-api"
+    exclude group: "javax.servlet.jsp", module: "servlet-api"
+}
+
+dependencies {
+    def jettyVersion = "7.6.16.v20140903"
+    def slf4jVersion = "1.7.22"
+    def springVersion = "2.5.6.SEC03"
+
+    compile "com.google.guava:guava:20.0"
+
+    compile "jaxen:jaxen:1.0-FCS"
+    compile "saxpath:saxpath:1.0-FCS"
+    compile "xalan:xalan:2.7.0"
+
+    compile "org.slf4j:slf4j-api:$slf4jVersion"
+
+    compile "org.zeroturnaround:javarebel-sdk:1.2.2"
+
+    // TODO @SuppressFBWarnings-s should be removed before build, then this dependency is only needed for the IDE
+    compile "com.google.code.findbugs:annotations:3.0.0"
+
+    // TODO These will be moved to the freemarker-serlvet module:
+    compile "javax.servlet.jsp:jsp-api:2.1"
+    compile "javax.servlet:servlet-api:2.5"
+
+    // Test:
+
+    testCompile "junit:junit:4.12"
+    testCompile "org.hamcrest:hamcrest-library:1.3"
+
+    testCompile "ch.qos.logback:logback-classic:1.1.8"
+    testCompile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
+
+    testCompile "commons-io:commons-io:2.2"
+    testCompile "com.google.guava:guava-jdk5:17.0"
+
+    testCompile "org.eclipse.jetty:jetty-server:$jettyVersion"
+    testCompile "org.eclipse.jetty:jetty-webapp:$jettyVersion"
+    testCompile "org.eclipse.jetty:jetty-jsp:$jettyVersion"
+    testCompile "org.eclipse.jetty:jetty-util:$jettyVersion"
+
+    testCompile("displaytag:displaytag:1.2") {
+        exclude group: "com.lowagie", module: "itext"
+    }
+
+    testCompile "org.springframework:spring-core:$springVersion"
+    testCompile "org.springframework:spring-test:$springVersion"
+}
+
+compileJava {
+    // TODO This will be 1.7 when freemarker-core-java8 is separated
+    sourceCompatibility = "1.8"
+    targetCompatibility = "1.8"
+
+    options.encoding = "UTF-8"
+}
+
+compileTestJava {
+    sourceCompatibility = "1.8"
+    targetCompatibility = "1.8"
+
+    options.encoding = "UTF-8"
+}
+
+compileJavacc {
+    arguments = [ grammar_encoding: "UTF-8" ]
+    doLast {
+        // TODO Some filtering is needed on the output - see in the original Ant build
+
+        // Note: The Gradle JavaCC plugin automatically removes generated java files that are already in
+        // src/main/java, so we don't need to get rid of ParseException.java and TokenMgrError.java (unlike in Ant)
+    }
+}
+
+jar {
+    // TODO Use bnd - see in the Ant build
+    manifest {
+        attributes(
+                // TODO There were more here in the Ant build
+                "Implementation-Title": "Apache FreeMarker",
+                "Implementation-Version": project.version)
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/gradle/wrapper/gradle-wrapper.jar
----------------------------------------------------------------------
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..b979729
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/gradle/wrapper/gradle-wrapper.properties
----------------------------------------------------------------------
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..561a5b0
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed May 03 11:59:02 CEST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/gradlew
----------------------------------------------------------------------
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..e53f798
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,233 @@
+#!/usr/bin/env bash
+
+# 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.
+
+##
+## Tries to recreate Gradle's gradlew command in pure bash.
+## This way you don't have to worry about binaries in your build.
+##
+## Depdencies
+## unzip
+##
+
+set -e
+set -o pipefail
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+    MAX_FD="maximum"
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+bin=`dirname "$0"`
+bin=`cd "$bin">/dev/null; pwd`
+
+if [ -e "$bin/gradle/wrapper/gradle-wrapper.properties" ]; then
+  . "$bin/gradle/wrapper/gradle-wrapper.properties"
+else
+  # the location that the wrapper is at doesn't have a properties
+  # check PWD, gradlew may be shared
+  if [ -e "$PWD/gradle/wrapper/gradle-wrapper.properties" ]; then
+    . "$PWD/gradle/wrapper/gradle-wrapper.properties"
+  else
+    echo "Unable to locate gradle-wrapper.properties.  Not at $PWD/gradle/wrapper/gradle-wrapper.properties or $bin/gradle/wrapper/gradle-wrapper.properties" 1>&2
+    exit 1
+  fi
+fi
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+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 [ "$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
+
+# does not match gradle's hash
+# waiting for http://stackoverflow.com/questions/26642077/java-biginteger-in-bash-rewrite-gradlew
+hash() {
+  local input="$1"
+  if $darwin; then
+    md5 -q -s "$1"
+  else
+    echo -n "$1" | md5sum  | cut -d" " -f1
+  fi
+}
+
+dist_path() {
+  local dir=$(basename $distributionUrl | sed 's;.zip;;g')
+  local id=$(hash "$distributionUrl")
+
+  echo "$HOME/.gradle/${distributionPath:-wrapper/dists}/$dir/$id"
+}
+
+zip_path() {
+  local dir=$(basename $distributionUrl | sed 's;.zip;;g')
+  local id=$(hash "$distributionUrl")
+
+  echo "$HOME/.gradle/${zipStorePath:-wrapper/dists}/$dir/$id"
+}
+
+download() {
+  local base_path=$(dist_path)
+  local file_name=$(basename $distributionUrl)
+  local dir_name=$(echo "$file_name" | sed 's;-bin.zip;;g' | sed 's;-src.zip;;g' |sed 's;-all.zip;;g')
+
+  if [ ! -d "$base_path" ]; then
+    mkdir -p "$base_path"
+  else
+    # if data already exists, it means we failed to do this before
+    # so cleanup last run and try again
+    rm -rf $base_path/*
+  fi
+
+  # download dist. curl on mac doesn't like the cert provided...
+  local zip_path=$(zip_path)
+  curl --insecure -L -o "$zip_path/$file_name" "$distributionUrl"
+
+  pushd "$base_path"
+    touch "$file_name.lck"
+    unzip "$zip_path/$file_name" 1> /dev/null
+    touch "$file_name.ok"
+  popd
+}
+
+is_cached() {
+  local file_name=$(basename $distributionUrl)
+
+  [ -e "$(dist_path)/$file_name.ok" ]
+}
+
+lib_path() {
+  local base_path=$(dist_path)
+  local file_name=$(basename $distributionUrl | sed 's;-bin.zip;;g' | sed 's;-src.zip;;g' |sed 's;-all.zip;;g')
+
+  echo "$base_path/$file_name/lib"
+}
+
+classpath() {
+  local dir=$(lib_path)
+  local cp=$(ls -1 $dir/*.jar | tr '\n' ':')
+  echo "$dir:$cp"
+}
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+
+main() {
+  if ! is_cached; then
+    download
+  fi
+
+  eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+  JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+  dynclasspath="$(classpath)"
+  if [ "$cygwin" = "true" ]; then
+    JAVACMD=$(cygpath --unix "$JAVACMD")
+    if [ -n "$dynclasspath" ]; then
+      # We assume that JAVACMD points to the Windows native java
+      dynclasspath=$(cygpath --path --windows "$dynclasspath")
+    fi
+  fi
+  
+  "$JAVACMD" "${JVM_OPTS[@]}" -cp "$dynclasspath" org.gradle.launcher.GradleMain "$@"
+}
+
+main "$@"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/d373a34d/gradlew.bat
----------------------------------------------------------------------
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@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/incubator-freemarker/blob/d373a34d/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..4c372f2
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+rootProject.name = 'freemarker'