How can I apply the licenseHeader for scala?
My configuration:
spotless {
scala {
scalafmt()
licenseHeader = '// TMA IOT'
}
}
fails with:
Could not set unknown property 'licenseHeader' for object of type com.diffplug.gradle.spotless.ScalaExtension.
Drop the equals sign.
HTH, reopen if it didn't.
spotless {
scala {
scalafmt()
licenseHeader '// <<m<_value>>'
}
}
same problem for me > Could not find method licenseHeader() for arguments [// <<m<_value>>] on object of type com.diffplug.gradle.spotless.ScalaExtension.
@nedtwigg I can't reopen / do not have permissions.
@geoHeil Have you tried removing the = sign? :)
yes. ;)
Aha - the license header actually takes two arguments. The first one is a regex that finds the first line in the code - everything above that gets replaced with the license header.
For java, we've got a good regex hardcoded in:
But we don't have one for Scala:
So you'll have to do licenseHeader('someRegex', 'the license that I want'). If you're able to find the regex, we'd love a PR to make it part of ScalaExtension.
Ah, @nedtwigg got there before me! I was going to say more or less what he said, other than I think that actually the license header method is licenseHeader('the license that I want', 'someRegex'), so the two arguments are swapped. :)
cools. In general package sounds great. 麓
However both ways of calling fail with:
Unable to find delimiter regex ^someRegex
I.e.
licenseHeader('// my license', 'package ')
fails with
> Unable to find delimiter regex ^package
I think that means there's a file that you're trying to format where the license regex is never matching.
Hmm, that's strange. Does not the word package exist near the top of the Scala source file(s) you're trying to format? :thinking:
No @nedtwigg was correct. Thx.
Cool! I hope this has helped.
Feel free to continue the conversation on Gitter or open a new issue if you still encounter problems. :)
If you care about license headers, you should checkout our new ratchetFrom 'origin/master' feature.