ErickErickson commented on a change in pull request #1199: LUCENE-9134: Port ant-regenerate tasks to Gradle build URL: https://github.com/apache/lucene-solr/pull/1199#discussion_r370970749
########## File path: lucene/queryparser/build.gradle ########## @@ -7,3 +7,305 @@ dependencies { testImplementation project(':lucene:test-framework') } + +configure(":lucene:queryparser") { + configurations { + javaCCDeps + + dependencies { + javaCCDeps "net.java.dev.javacc:javacc:5.0" + } + } +} +def conf = [ + "queryParser": ["inputFile": file('src/java/org/apache/lucene/queryparser/classic/QueryParser.jj'), "outputDir": file('src/java/org/apache/lucene/queryparser/classic')], + "surround" : ["inputFile": file('src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj'), "outputDir": file('src/java/org/apache/lucene/queryparser/surround/parser/')], + "flexible" : ["inputFile": file('src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj'), "outputDir": file('src/java/org/apache/lucene/queryparser/flexible/standard/parser')] +] + +String javaCCClasspath +String javaCCHome + +task installJavacc { + doLast { + javaCCClasspath = project.project(":lucene:queryparser").configurations.javaCCDeps.asPath + javaCCHome = javaCCClasspath.substring(0, javaCCClasspath.lastIndexOf("/")) + + String hacky = javaCCHome + "/" + "javacc.jar" + File hackyFile = new File(hacky) + println hackyFile + println hackyFile.exists() + if (hackyFile.exists() == false) { + hackyFile.bytes = new File(javaCCClasspath).bytes + hackyFile.setExecutable(true) + } + } +} +String lineSeparator = System.lineSeparator() + +task cleanOldGeneratedFiles { + doLast { + println "Removing old generated files" + conf.each { key, val -> + val["outputDir"].eachFileMatch ~/.*\.java/, { f -> + if (f.text =~ /Generated.*By.*JavaCC/) { + f.delete() + } + } + } + } +} + +task runJavaccQueryParser(dependsOn: installJavacc) { Review comment: Gah, it's worse than that. The common bits _are_ in one place, see cleanUpAfter. I missed taking it out of a place or two. Fixing it up. So there's only one small bit that's repeated now, I don't think it's worth a new class now. And many thanks for your review! I'll get the hang of this yet. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org