question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

License check breaks if file has no package declaration

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jbduncancommented, Aug 24, 2017

We do provide a way to specify the start of the file manually.

Oops, I missed that. Thanks for correcting me @nedtwigg. 😜

1reaction
nedtwiggcommented, Aug 24, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found