License check breaks if file has no package declaration
See original GitHub issueI got the following exception:
Step 'licenseHeader' found problem in 'src/main/java/me/banes/chris/tivi/extensions/PreferenceExtensions.kt':
Unable to find delimiter regex ^package
java.lang.IllegalArgumentException: Unable to find delimiter regex ^package
at com.diffplug.spotless.generic.LicenseHeaderStep.format(LicenseHeaderStep.java:88)
at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:78)
at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
at com.diffplug.spotless.Formatter.isClean(Formatter.java:167)
at com.diffplug.gradle.spotless.SpotlessTask.check(SpotlessTask.java:216)
at com.diffplug.gradle.spotless.SpotlessTask.performAction(SpotlessTask.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How to access a class whose .java file has no package ...
It is a compile time error to import a type from the unnamed package. Which means that if you're not in the unnamed...
Read more >FMCSA Regulations and Interpretations – 49 CFR Parts 300 ...
To view the latest eCFR version of FMCSA's Regulations in 49 CFR Parts 300-399, click the link in the first column. To search...
Read more >R Packages (2e) - 10 DESCRIPTION
Learn how to create a package, the fundamental unit of shareable, reusable, and reproducible R code.
Read more >Google Java Style Guide
If license or copyright information belongs in a file, it belongs here. 3.2 Package statement. The package statement is not line-wrapped. The column...
Read more >Check for Recalls: Vehicle, Car Seat, Tire, Equipment | NHTSA
What this VIN search tool will not show. A vehicle with a repaired safety recall. If your vehicle has no unrepaired recalls, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oops, I missed that. Thanks for correcting me @nedtwigg. 😜
We do provide a way to specify the start of the file manually. The easiest workaround is to avoid the default package. If you don’t want to change that, then you have to provide the regex yourself, e.g. something like
licenseHeaderFile('license.txt', '^(package|//startfile)')
if you want to use the//startfile
comment to signify the start of the file. Without a package declaration, it’s very difficult to find a regex that will work in the general case. Files might start with imports, comments, a class declaration, etc.