Skip to content

Commit

Permalink
[CALCITE-4184] Update Gradle: 6.3 -> 6.6, make fmpp and javacc tasks …
Browse files Browse the repository at this point in the history
…cacheable
  • Loading branch information
vlsi committed Aug 20, 2020
1 parent 9ca61f0 commit 6cc8aa1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 44 deletions.
4 changes: 2 additions & 2 deletions babel/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ val javaCCMain by tasks.registering(org.apache.calcite.buildtools.javacc.JavaCCT
dependsOn(fmppMain)
lookAhead.set(2)
val parserFile = fmppMain.map {
it.output.asFileTree.matching { include("**/Parser.jj") }.singleFile
it.output.asFileTree.matching { include("**/Parser.jj") }
}
inputFile.set(parserFile)
inputFile.from(parserFile)
packageName.set("org.apache.calcite.sql.parser.babel")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.withGroovyBuilder

@CacheableTask
open class FmppTask @Inject constructor(
objectFactory: ObjectFactory
) : DefaultTask() {
Expand All @@ -37,9 +41,11 @@ open class FmppTask @Inject constructor(
.convention(project.configurations.named(FmppPlugin.FMPP_CLASSPATH_CONFIGURATION_NAME))

@InputFile
@PathSensitive(PathSensitivity.NONE)
val config = objectFactory.fileProperty()

@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
val templates = objectFactory.directoryProperty()

@OutputDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,32 @@

package org.apache.calcite.buildtools.javacc

import java.io.File
import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.property

@CacheableTask
open class JavaCCTask @Inject constructor(
objectFactory: ObjectFactory
) : DefaultTask() {
@Classpath
val javaCCClasspath = objectFactory.property<Configuration>()
.convention(project.configurations.named(JavaCCPlugin.JAVACC_CLASSPATH_CONFIGURATION_NAME))

@Internal
val inputFile = objectFactory.property<File>()

// See https://github.com/gradle/gradle/issues/12627
@get:InputFile
val actualInputFile: File? get() = try {
inputFile.get()
} catch (e: IllegalStateException) {
// This means Gradle queries property too early
null
}
@InputFiles
@PathSensitive(PathSensitivity.NONE)
// We expect one file only, however there's https://github.com/gradle/gradle/issues/12627
val inputFile = objectFactory.fileCollection()

@Input
val lookAhead = objectFactory.property<Int>().convention(1)
Expand All @@ -72,7 +67,7 @@ open class JavaCCTask @Inject constructor(
args("-STATIC=${static.get()}")
args("-LOOKAHEAD:${lookAhead.get()}")
args("-OUTPUT_DIRECTORY:${output.get()}/${packageName.get().replace('.', '/')}")
args(inputFile.get())
args(inputFile.singleFile)
}
}
}
8 changes: 4 additions & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ val fmppMain by tasks.registering(org.apache.calcite.buildtools.fmpp.FmppTask::c
val javaCCMain by tasks.registering(org.apache.calcite.buildtools.javacc.JavaCCTask::class) {
dependsOn(fmppMain)
val parserFile = fmppMain.map {
it.output.asFileTree.matching { include("**/Parser.jj") }.singleFile
it.output.asFileTree.matching { include("**/Parser.jj") }
}
inputFile.set(parserFile)
inputFile.from(parserFile)
packageName.set("org.apache.calcite.sql.parser.impl")
}

Expand All @@ -173,9 +173,9 @@ val fmppTest by tasks.registering(org.apache.calcite.buildtools.fmpp.FmppTask::c
val javaCCTest by tasks.registering(org.apache.calcite.buildtools.javacc.JavaCCTask::class) {
dependsOn(fmppTest)
val parserFile = fmppTest.map {
it.output.asFileTree.matching { include("**/Parser.jj") }.singleFile
it.output.asFileTree.matching { include("**/Parser.jj") }
}
inputFile.set(parserFile)
inputFile.from(parserFile)
packageName.set("org.apache.calcite.sql.parser.parserextensiontesting")
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=0f316a67b971b7b571dac7215dcf2591a30994b3450e0629925ffcfe2c68cc5c
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionSha256Sum=e6f83508f0970452f56197f610d13c5f593baaf43c0e3c6a571e5967be754025
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

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
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@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%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
2 changes: 1 addition & 1 deletion piglet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
}

val javaCCMain by tasks.registering(org.apache.calcite.buildtools.javacc.JavaCCTask::class) {
inputFile.set(file("src/main/javacc/PigletParser.jj"))
inputFile.from(file("src/main/javacc/PigletParser.jj"))
packageName.set("org.apache.calcite.piglet.parser")
}

Expand Down
4 changes: 2 additions & 2 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ val fmppMain by tasks.registering(org.apache.calcite.buildtools.fmpp.FmppTask::c
val javaCCMain by tasks.registering(org.apache.calcite.buildtools.javacc.JavaCCTask::class) {
dependsOn(fmppMain)
val parserFile = fmppMain.map {
it.output.asFileTree.matching { include("**/Parser.jj") }.singleFile
it.output.asFileTree.matching { include("**/Parser.jj") }
}
inputFile.set(parserFile)
inputFile.from(parserFile)
packageName.set("org.apache.calcite.sql.parser.ddl")
}

Expand Down

0 comments on commit 6cc8aa1

Please sign in to comment.