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 and Asciidoctor #418

Closed
5 of 6 tasks
t-buss opened this issue Jul 15, 2019 · 2 comments
Closed
5 of 6 tasks

Spotless and Asciidoctor #418

t-buss opened this issue Jul 15, 2019 · 2 comments
Labels

Comments

@t-buss
Copy link
Contributor

t-buss commented Jul 15, 2019

Hello, we are trying to use Spotless and AsciiDoctor simulatiously in a project. When we run ./gradlew spotlessApply, the Asciidoc-formatted comments are manipulated (<p>tags are added in places where there should not).

Is there a way to disable spotless for JavaDoc or (even better) set the format for Javadoc to Asciidoc?

Gradle 5.4.1
Spotless 3.23.1
Ubuntu 19.04 Disco Dingo

spotless {
    java {
        target 'src/main/java/**/*.java', 'src/test/java/**/*.java'
        googleJavaFormat()
        trimTrailingWhitespace()
        indentWithSpaces()
        removeUnusedImports()
    }
    groovyGradle {
        target '*.gradle', 'gradle/*.gradle'
        greclipse()
        trimTrailingWhitespace()
        indentWithSpaces()
    }
}

If you are submitting a bug, please include the following:

  • summary of problem
  • gradle or maven version
  • spotless version
  • operating system and version
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

If you're just submitting a feature request or question, no need for the above.

@nedtwigg
Copy link
Member

You are using googleJavaFormat() which doesn't have many options. If you instead use eclipse(), you can provide a config file where you can set a bunch of options, including options about javadoc formatting.

We don't have an asciidoctor formatter, but if we had one, and you wanted to apply it only to the comments, we would also need to implement #412, which no one is currently working on.

@t-buss
Copy link
Contributor Author

t-buss commented Jul 16, 2019

Thanks, using the eclipse formatter worked. Here's the solution (if anyone stumbles across this):

spotless {
    java {
        target 'src/main/java/**/*.java', 'src/test/java/**/*.java'
        eclipse().configFile 'gradle/eclipse.formatter.xml'
        trimTrailingWhitespace()
        indentWithSpaces()
        removeUnusedImports()
    }
    groovyGradle {
        target '*.gradle', 'gradle/*.gradle'
        greclipse()
        trimTrailingWhitespace()
        indentWithSpaces()
    }
}

We used the Quarkus Formatting configuration: https://raw.githubusercontent.com/quarkusio/quarkus/master/ide-config/eclipse-format.xml
There, you can simply set org.eclipse.jdt.core.formatter.comment.format_javadoc_comments to false.
Now, javadoc comments are not processed by Spotless and can remain in Asciidoc format.

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

2 participants