Skip to content

Instantly share code, notes, and snippets.

@vicly
Created December 20, 2018 21:01
Show Gist options
  • Save vicly/22880830a1b5181fce32a786d62c24b6 to your computer and use it in GitHub Desktop.
Save vicly/22880830a1b5181fce32a786d62c24b6 to your computer and use it in GitHub Desktop.
[Gradle code check] #Gradle

$root/config

  • checkstyle.xml
  • suppression.ml
plugins {
  id 'checkstyle'
}

// config
checkstyle {
  toolVersion = "6.5"
  maxErrors = 0
  maxWarnings = 0
}

$root/config/spotless

  • importorder
4=
3=com
2=org
1=javax
0=java
  • eclipse-formatting.xml (Sample)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="XyzStandard" version="1">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
.....
</profile>
</profiles>

apply plugin: 'com.diffplug.gradle.spotless'

spotless {
  java {
    target project.fileTree(project.rootDir) {
      include 'src/**/*.java'
      exclude generatedSourcePath + '/**'
    }
    importOrderFile 'config/spotless/importorder'
    eclipseFormatFile 'config/spotless/eclipse-formatting.xml'
  }
}

test.shouldRunAfter 'spotlessCheck'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment