You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/01/28 21:37:08 UTC
[GitHub] [lucene-solr] dweiss commented on a change in pull request #1219:
LUCENE-9134: Javacc skeleton for Gradle regenerate
dweiss commented on a change in pull request #1219: LUCENE-9134: Javacc skeleton for Gradle regenerate
URL: https://github.com/apache/lucene-solr/pull/1219#discussion_r372071747
##########
File path: gradle/generation/javacc.gradle
##########
@@ -0,0 +1,102 @@
+// Add a top-level pseudo-task to which we will attach individual regenerate tasks.
+import static groovy.io.FileType.*
+
+configure(rootProject) {
+ configurations {
+ javacc
+ }
+
+ dependencies {
+ javacc "net.java.dev.javacc:javacc:${scriptDepVersions['javacc']}"
+ }
+
+ task javacc() {
+ description "Regenerate sources for corresponding javacc grammar files."
+ group "generation"
+
+ dependsOn ":lucene:queryparser:javaccParserClassic"
+ dependsOn ":lucene:queryparser:javaccParserSurround"
+ dependsOn ":lucene:queryparser:javaccParserFlexible"
+ }
+}
+
+// We always regenerate, no need to declare outputs.
+class JavaCCTask extends DefaultTask {
+ @Input
+ File javaccFile
+
+ JavaCCTask() {
+ dependsOn(project.rootProject.configurations.javacc)
+ }
+
+ @TaskAction
+ def generate() {
+ if (!javaccFile || !javaccFile.exists()) {
+ throw new RuntimeException("JavaCC input file does not exist: ${javaccFile}")
+ }
+ // Remove old files so we can regenerate them
+ def parentDir = javaccFile.parentFile
+ parentDir.eachFileMatch FILES, ~/.*\.java/, { file ->
+ if (file.text.contains("Generated By:JavaCC")) {
+ file.delete()
+ }
+ }
+ logger.lifecycle("Regenerating JavaCC:\n from: ${javaccFile}\n to: ${parentDir}")
+
+ project.javaexec {
+ classpath {
+ project.rootProject.configurations.javacc
+ }
+ main = "org.javacc.parser.Main"
+ args += "-OUTPUT_DIRECTORY=${parentDir}"
+ args += [javaccFile]
Review comment:
it is correct but unnecessary
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org