-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Merge generated-src and generated #117899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,8 +69,6 @@ def projectDirectory = project.layout.projectDirectory | |
| def generatedSourceDir = projectDirectory.dir(generatedPath) | ||
| tasks.named("compileJava").configure { | ||
| options.compilerArgumentProviders.add(new SourceDirectoryCommandLineArgumentProvider(generatedSourceDir)) | ||
| // IntelliJ sticks generated files here and we can't stop it.... | ||
| exclude { normalize(it.file.toString()).contains("src/main/generated-src/generated") } | ||
| } | ||
|
|
||
| idea.module { | ||
|
|
@@ -177,8 +175,7 @@ pluginManager.withPlugin('com.diffplug.spotless') { | |
| // for some reason "${outputPath}/EsqlBaseParser*.java" does not match the same files... | ||
| targetExclude "src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer*.java", | ||
| "src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser*.java", | ||
| "src/main/generated/**/*.java", | ||
| "src/main/generated-src/generated/**/*.java" | ||
| "src/main/generated/**/*.java" | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -227,7 +224,7 @@ tasks.register("regenParser", JavaExec) { | |
| } | ||
|
|
||
| tasks.register("regen") { | ||
| dependsOn "regenParser" | ||
| dependsOn "regenParser", "stringTemplates" | ||
| doLast { | ||
| // moves token files to grammar directory for use with IDE's | ||
| ant.move(file: "${outputPath}/EsqlBaseLexer.tokens", toDir: grammarPath) | ||
|
|
@@ -276,10 +273,8 @@ tasks.register("regen") { | |
| } | ||
| } | ||
|
|
||
| tasks.named("spotlessJava") { dependsOn stringTemplates } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we remove this dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I was explaining above I had to remove it from here as spotlessJava is executed rather late. Instead I moved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot have multiple tasks share an output directory. If we want to have a "single" generated source directory for the purposes of the IDE then we'll need to have another task aggregate them. This should actually be a Gradle deprecation warning if you attempt to do this. I'm surprised the build didn't complain. The issue with having to strictly order tasks because they clean their output folder is one reason why this is generally bad practice. It's very easy to have tasks clobber eachothers output. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any other task writing into I don't understand your explanation here why this change is needed. To me it looks like spotless is configured to ignore everything that is generated so we should be just safe to remove this task dependency as you did |
||
| tasks.named('checkstyleMain').configure { | ||
| excludes = [ "**/*.java.st" ] | ||
| exclude { normalize(it.file.toString()).contains("src/main/generated-src/generated") } | ||
| exclude { normalize(it.file.toString()).contains("src/main/generated") } | ||
| } | ||
|
|
||
|
|
@@ -306,6 +301,8 @@ tasks.named('stringTemplates').configure { | |
| var bytesRefProperties = prop("BytesRef", "BytesRef", "BYTES_REF", "org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF", "") | ||
| var booleanProperties = prop("Boolean", "boolean", "BOOLEAN", "Byte.BYTES", "BitArray") | ||
|
|
||
| it.outputFolder = file(generatedPath) | ||
|
|
||
| File inInputFile = file("src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st") | ||
| template { | ||
| it.properties = booleanProperties | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to ensure
stringTemplatesruns before other code generation.This has to be done as
stringTemplatestask cleans the entire generated directory before execution (see StringTemplateTask) while other generation not.This means that before this change
/generateddir was not cleaned before generating new files, keeping files with corresponding templates deleted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is needed? The
regentask uses a different mechanism and doesn't put the output in the same dir. It makes Antlr stuff everything intox-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser.I just removed the
stringTemplatesdependency locally and made a small change to our grammar - the diff looked very sane and contained; whereas with the dependency onstringTemplatesin place, making changes to the grammar and runningregendeletes a bunch of unrelated files, which one must not commit. I think that'll make making changes to the grammar a bit painful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to group it with other
genstuff I noticed, but may be it is worth to update thestringTemplatesnot to clear files unconditionally and instead have dedicated clear generated files tasks. What gradle task do we use to generate other files inmain/gnerated?Antlr generated code goes into
main/java, I do not think this is intended as well. I will check If I can move it to generated in a separate pr.