Skip to content
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

Kotlin file could start with @file:... instead of package ... #136

Closed
JLLeitschuh opened this issue Aug 30, 2017 · 6 comments
Closed

Kotlin file could start with @file:... instead of package ... #136

JLLeitschuh opened this issue Aug 30, 2017 · 6 comments
Labels

Comments

@JLLeitschuh
Copy link
Member

The regex for finding the top of the file (where the license should go) doesn't work when you start your file with:

@file:JvmName("SomeFileName")
package ... // ect...

The default header regex for kotlin should support starting the file with the @file annotation.
As a note, the compiler will only let you legally put @file:... annotations above the package statement.

@jbduncan
Copy link
Member

This sounds like a very good reason to me to amend the default header regex for Kotlin files.

I probably won't have the time and energy to make this change myself, but I'm sure we're open to PRs if @nedtwigg isn't already addressing this. But regardless, I would make a reasonable guess that he can direct you if you'd be happy to submit a PR yourself. as I think he knows the code base better than I do. :)

@nedtwigg
Copy link
Member

You can workaround with something like this: licenseHeaderFile('license.txt', '^(package|@file)'). Can you find a battle-tested regex that works for your codebase? If so, we can change the default regex.

Issue #135 is about this same issue but for the default package.

@jbduncan
Copy link
Member

jbduncan commented Aug 30, 2017

@nedtwigg The regex would be for JUnit 5 I believe (please correct me if I'm wrong @JLLeitschuh), as I think @JLLeitschuh is submitting this issue in response to junit-team/junit5#1001.

Not sure if the regex that would ultimately come out of this would count as "battle-tested", as AFAIK JUnit 5 doesn't use Kotlin much at this point in time.

@JLLeitschuh
Copy link
Member Author

Well, I only discovered the bug because of my work on Junit5. I'd be more than happy to open an PR with a simple unit test for the regex.

@nedtwigg
Copy link
Member

The @file issue that @JLLeitschuh brings up is more battle-tested than what we have now. We don't need the perfect regex, not even sure that we need a unit test. Just a licenseFile() incantation that works better on Kotlin codebases than what we have now.

@nedtwigg
Copy link
Member

nedtwigg commented Sep 5, 2017

Released in 3.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants