Closed
Description
If Spotless has a licenseHeader
specified, it replaces everything between the top of the file and the package
statement with the license. This works for regular classes, but it doesn't work for package-info.java
files.
As a workaround, you can do this:
java {
target project.fileTree(project.rootDir) {
include '**/*.java'
exclude '**/package-info.java'
exclude 'spotless.license.java'
}
... (the rest of the config)
}
Spotless' default settings should play nicely with package-info.java
, but at the moment it's not a big enough problem for me to actually fix. If this is an actual problem for you, reply to this issue and I'll actually fix it.
Activity
opentest4j commentedon Dec 10, 2015
We (the JUnit Lambda team) would love to see some sort of flag to allow
package-info.java
files to contain custom Javadoc (/** ... */
) without having it automatically stripped out by Spotless.nedtwigg commentedon Dec 10, 2015
I'm happy to take a PR for this, or I'll have a bugfix by Monday. In the meantime, you can copy-paste the little "target" snippet above as a workaround.
sbrannen commentedon Dec 10, 2015
Thanks, @nedtwigg!
No rush on the fix. For the time being, I've already used the explicit
exclude
approach as can be seen here: https://github.com/ota4j-team/opentest4j/blob/master/build.gradlenedtwigg commentedon Dec 17, 2015
Fixed in 1.3.2.
sbrannen commentedon Dec 17, 2015
That does the job.
Thanks!
sbrannen commentedon Dec 17, 2015
By the way, JUnit Lambda (a.k.a., JUnit 5) also uses Spotless... in case you want to list it in the README as well.
https://github.com/junit-team/junit-lambda/blob/master/build.gradle
nedtwigg commentedon Dec 17, 2015
The formatter runs in steps - indent, then header, then eclipse, etc. The old workaround disabled all steps in package-info, but in 1.3.2 it disables only the license-header step, so you still get checking for trailing white space, eclipse formatter, etc. Probably one of the other steps is disagreeing with your package-info.
Thanks for junit 5 info, I'll definitely add that!
File
not theString
#1599