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

Spotless replaces package-info.java's javadoc with the license #1

Closed
nedtwigg opened this issue May 30, 2015 · 7 comments
Closed

Spotless replaces package-info.java's javadoc with the license #1

nedtwigg opened this issue May 30, 2015 · 7 comments

Comments

@nedtwigg
Copy link
Member

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.

@opentest4j
Copy link

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
Copy link
Member Author

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
Copy link

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.gradle

@nedtwigg
Copy link
Member Author

Fixed in 1.3.2.

@sbrannen
Copy link

That does the job.

Thanks!

@sbrannen
Copy link

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
Copy link
Member Author

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!

On Dec 17, 2015, at 5:27 AM, Sam Brannen notifications@github.com wrote:

I removed the "target" configuration and upgraded to 1.3.2, but it is failing as follows.

Download https://plugins.gradle.org/m2/com/diffplug/gradle/spotless/spotless/1.3.2/spotless-1.3.2.pom
Download https://plugins.gradle.org/m2/com/diffplug/gradle/spotless/spotless/1.3.2/spotless-1.3.2.jar

...

:spotlessJavaCheck FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':spotlessJavaCheck'.

    Format violations were found. Run 'gradlew spotlessApply' to fix them.
    src/main/java/org/opentest4j/package-info.java
    What am I missing?


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

3 participants