It's failing because the first line of your generated file does not match the license header (the first line is "Generated from ....").
Interestingly, when I look at my generated files, the first line _is_ the license file, which is why spotless doesn't fail for me. What's more, I assume the same is true on Jenkins, otherwise this would be failing on Jenkins. However, I think this does show that we're running spotless on generated code, which is a bug in our spotless setup. It's fragile, and it probably slows down our spotless runs a lot. I'll take a look right now at excluding all generated code from spotless. Reuven On Fri, Jan 18, 2019 at 8:13 AM Reuven Lax <re...@google.com> wrote: > Does this only happen on fresh clones? I created a fresh branch synced to > origin/master, and I can't reproduce this still. > > If spotless is running against generated code, that seems like a bug in > our spotless setup. Should be trivial to fix by creating a target block in > our spotless config. > > Reuven > > On Fri, Jan 18, 2019 at 8:07 AM Ismaël Mejía <ieme...@gmail.com> wrote: > >> Just make a fresh clone and run `./gradlew check -p sdks/java/core` it >> should break. If you add 'spotlessApply' the build passes but this >> should not be the default, no?, the default is 'spotlessCheck' >> >> On Fri, Jan 18, 2019 at 5:02 PM Reuven Lax <re...@google.com> wrote: >> > >> > I don't get those errors when I run spotlessApply, and I don't see >> those errors happening on Jenkins. Are you doing anything special to run >> spotless? In general, I don't think spotless was running on generated code >> before. >> > >> > On Fri, Jan 18, 2019 at 6:06 AM Ismaël Mejía <ieme...@gmail.com> wrote: >> >> >> >> When running the build on master we got an error message. >> >> Looks related to the recent inclusion/generation of stuff with ANTLR. >> >> Can Reuven or someone else involved in this specific changes please >> >> take a look? >> >> >> >> > Task :beam-sdks-java-core:spotlessJava FAILED >> >> >> >> FAILURE: Build failed with an exception. >> >> >> >> * What went wrong: >> >> Execution failed for task ':beam-sdks-java-core:spotlessJava'. >> >> > The following files had format violations: >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationParser.java >> >> @@ -1,5 +1,3 @@ >> >> >> >> -//·Generated·from·java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotation.g4·by·ANTLR·4.7 >> >> - >> >> /* >> >> >> ·*·Licensed·to·the·Apache·Software·Foundation·(ASF)·under·one >> >> >> ·*·or·more·contributor·license·agreements.··See·the·NOTICE·file >> >> @@ -19,609 +17,737 @@ >> >> ·*/ >> >> package·org.apache.beam.sdk.schemas.parser.generated; >> >> >> >> +import·java.util.List; >> >> +import·org.antlr.v4.runtime.*; >> >> import·org.antlr.v4.runtime.atn.*; >> >> import·org.antlr.v4.runtime.dfa.DFA; >> >> -import·org.antlr.v4.runtime.*; >> >> import·org.antlr.v4.runtime.misc.*; >> >> import·org.antlr.v4.runtime.tree.*; >> >> -import·java.util.List; >> >> -import·java.util.Iterator; >> >> -import·java.util.ArrayList; >> >> >> >> >> @SuppressWarnings({"all",·"warnings",·"unchecked",·"unused",·"cast"}) >> >> public·class·FieldSpecifierNotationParser·extends·Parser·{ >> >> >> -\tstatic·{·RuntimeMetaData.checkVersion("4.7",·RuntimeMetaData.VERSION);·} >> >> +··static·{ >> >> >> +····RuntimeMetaData.checkVersion("4.7",·RuntimeMetaData.VERSION); >> >> +··} >> >> >> >> -\tprotected·static·final·DFA[]·_decisionToDFA; >> >> >> -\tprotected·static·final·PredictionContextCache·_sharedContextCache·= >> >> -\t\tnew·PredictionContextCache(); >> >> -\tpublic·static·final·int >> >> >> -\t\tT__0=1,·T__1=2,·T__2=3,·T__3=4,·T__4=5,·IDENTIFIER=6,·WILDCARD=7,·WS=8; >> >> -\tpublic·static·final·int >> >> >> >> -\t\tRULE_fieldSpecifier·=·0,·RULE_dotExpression·=·1,·RULE_dotExpressionComponent·=·2,· >> >> >> >> -\t\tRULE_qualifiedComponent·=·3,·RULE_qualifierList·=·4,·RULE_arrayQualifier·=·5,· >> >> -\t\tRULE_mapQualifier·=·6; >> >> -\tpublic·static·final·String[]·ruleNames·=·{ >> >> >> >> -\t\t"fieldSpecifier",·"dotExpression",·"dotExpressionComponent",·"qualifiedComponent",· >> >> -\t\t"qualifierList",·"arrayQualifier",·"mapQualifier" >> >> -\t}; >> >> +··protected·static·final·DFA[]·_decisionToDFA; >> >> >> >> +··protected·static·final·PredictionContextCache·_sharedContextCache·=·new·PredictionContextCache(); >> >> +··public·static·final·int·T__0·=·1, >> >> +······T__1·=·2, >> >> +······T__2·=·3, >> >> +······T__3·=·4, >> >> +······T__4·=·5, >> >> +······IDENTIFIER·=·6, >> >> ... (1268 more lines that didn't fit) >> >> Violations also present in: >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationVisitor.java >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationBaseListener.java >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationBaseVisitor.java >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationLexer.java >> >> >> >> sdks/java/core/build/generated-src/antlr/main/java/org/apache/beam/sdk/schemas/parser/generated/FieldSpecifierNotationListener.java >> >> Run 'gradlew spotlessApply' to fix these violations. >> >