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

license headers for java files #118

Closed
jitsni opened this issue Aug 31, 2016 · 6 comments
Closed

license headers for java files #118

jitsni opened this issue Aug 31, 2016 · 6 comments
Assignees
Labels
is:enhancement Enhancement to an existing feature
Milestone

Comments

@jitsni
Copy link

jitsni commented Aug 31, 2016

The plugin uses /** ... */ instead of /* ... */ for license headers in java files.
Some of the IDEs (like intellij) marks them as "Dangling javadoc comment" (rightly so).

@jfallows
Copy link

jfallows commented Sep 1, 2016

+1 👍

@manoelcampos
Copy link

manoelcampos commented Jan 12, 2017

You can change this behaviour easily, just by adding the following lines to the configuration tag of the plugin inside the pom.xml:

<mapping>
    <java>SLASHSTAR_STYLE</java>
</mapping>

The comment styles are documented at the README.md file.

@buckett
Copy link

buckett commented Aug 25, 2017

An alternative way to mark these comments is with /*- ... */ which indicates that they shouldn't be reformatted which is normally the case for license headers:

http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#350

This is supported by another license plugin through a property:

http://www.mojohaus.org/license-maven-plugin/update-file-header-mojo.html#useJavaNoReformatCommentStartTag

would it make sense for this plugin to have a standard format for this style?

@buckett
Copy link

buckett commented Aug 25, 2017

And there's already a PR for this (/*- .. */): #115

@ctubbsii
Copy link
Contributor

ctubbsii commented Dec 7, 2018

SLASHSTAR_STYLE should be default for *.java

The current default /** for Java isn't just "not preferred". It is outright incorrect. Javadocs are HTML markup, so they should be subject to formatting as HTML by build tooling (for example, to remove redundant whitespace in HTML source). Obviously, we don't want licenses to be interpreted as HTML markup and to be reformatted accordingly.

Additionally, Javadocs are also supposed to document specific language elements which they precede. A javadoc comment prefacing a package statement is invalid javadoc, because it cannot be rendered in any meaningful way into the generated javadoc pages. As such, this can really mess with some IDEs and Java parsers, which expect valid syntax for javadoc comments and (like the OP said) report this as a dangling comment.

The default behavior can be overridden, yes, but there are at least two problems with this:

  1. Most people don't override the defaults, and don't realize the problems above, so this default encourages very bad style, and
  2. As far as I can tell, the mapping cannot be overridden when running the tool manually from the Maven command-line (e.g. outside a Maven project, or without a Maven pom.xml).

@mathieucarbou
Copy link
Owner

Fixed in #109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:enhancement Enhancement to an existing feature
Projects
None yet
Development

No branches or pull requests

6 participants