diff --git a/.gitignore b/.gitignore index 4e67f6477..fef9088c8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ .gradle_home *~ build +gradle.properties /dist /javadoc diff --git a/build.gradle b/build.gradle index f91a8c53b..502727c3a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { - id 'application' + id 'application' + id 'com.diffplug.spotless' version '6.22.0' } group = 'org.contikios.cooja' @@ -12,6 +13,31 @@ java { } } +spotless { + java { + toggleOffOn() + // Removing unused imports fails with unterminated string literal in + // GUI.java. The line is a switch statement with a string case, so + // possibly something to do with Java 17. + // removeUnusedImports() + importOrder() + // trimTrailingWhitespace() + // cleanthat() + // formatAnnotations() + + // Use a different clang-format binary with -PclangFormat=clang-format-15. + def clangFormatBinary = (String) project.findProperty('clangFormat') ?: 'clang-format' + def clangOutput = new ByteArrayOutputStream() + exec { + commandLine clangFormatBinary, '--version' + standardOutput = clangOutput + } + def clangVersion = (String) (clangOutput.toString() =~ /\d+\.\d+\.\d+/)[0] + // FIXME: enable clangFormat in the future. +// clangFormat(clangVersion).pathToExe(clangFormatBinary).style('file') + } +} + repositories { mavenCentral() }