Skip to content

Commit

Permalink
build: add Gradle formatting rules
Browse files Browse the repository at this point in the history
ING-4375
  • Loading branch information
stempler committed Aug 16, 2024
1 parent 3b02f4a commit 8f8f0d4
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 3 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
plugins {
id 'hale.base'
}

repositories {
mavenCentral()
}

allprojects {
group = 'eu.esdihumboldt.hale'
}
Expand Down
17 changes: 17 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
plugins {
id 'groovy-gradle-plugin'

id("com.diffplug.spotless") version "6.25.0"
}

repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section

mavenCentral()
}

dependencies {
implementation 'to.wetransform:gradle-semantic-release-version:2.1.1'
implementation 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.3.0'
implementation 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
}

spotless {
// try to reflect .editorconfig settings for .gradle

groovyGradle {
target '*.gradle'

greclipse().configFile('../gradle-format.properties')

trimTrailingWhitespace()
endWithNewline()
}
}
26 changes: 26 additions & 0 deletions buildSrc/src/main/groovy/hale.base.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
id 'com.diffplug.spotless'
}

spotless {
// try to reflect .editorconfig settings

// generic steps described in https://github.com/diffplug/spotless/tree/main/plugin-gradle#generic-steps
// custom steps described in https://github.com/diffplug/spotless/tree/main/plugin-gradle#custom-steps

groovyGradle {
target '*.gradle'

greclipse().configFile(rootProject.file('gradle-format.properties'))

trimTrailingWhitespace()
endWithNewline()
}

format 'other', {
target '*.md', '.gitignore'

trimTrailingWhitespace()
endWithNewline()
}
}
2 changes: 2 additions & 0 deletions buildSrc/src/main/groovy/hale.common.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id 'to.wetransform.semantic-release-version'

id 'hale.base'
}

repositories {
Expand Down
34 changes: 34 additions & 0 deletions gradle-format.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#Whether to use 'space', 'tab' or 'mixed' (both) characters for indentation.
#The default value is 'tab'.
org.eclipse.jdt.core.formatter.tabulation.char=space

#Number of spaces used for indentation in case 'space' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.tabulation.size=2

#Number of spaces used for indentation in case 'mixed' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.indentation.size=2

#Whether or not indentation characters are inserted into empty lines.
#The default value is 'true'.
org.eclipse.jdt.core.formatter.indent_empty_lines=false

#Number of spaces used for multiline indentation.
#The default value is 2.
groovy.formatter.multiline.indentation=1

#Length after which list are considered too long. These will be wrapped.
#The default value is 30.
groovy.formatter.longListLength=30

#Whether opening braces position shall be the next line.
#The default value is 'same'.
groovy.formatter.braces.start=same

#Whether closing braces position shall be the next line.
#The default value is 'next'.
groovy.formatter.braces.end=next

#Remove unnecessary semicolons. The default value is 'false'.
groovy.formatter.remove.unnecessary.semicolons=true
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.gradle.jvmargs=-Xmx1g
org.gradle.jvmargs=-Xmx2g
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void includeProjects(relativeDirPath = null, filter = null) {
def projectDirs = []

dir.eachDir { subDir ->
searchDir(projectDirs, subDir, filter)
if (subDir.name != 'build') {
searchDir(projectDirs, subDir, filter)
}
}

projectDirs.each { File subdir ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ hale {
}

tasks.test {
jvmArgs = ['--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED']
jvmArgs = [
'--add-exports',
'java.base/sun.nio.ch=ALL-UNNAMED'
]
}

dependencies {
Expand Down

0 comments on commit 8f8f0d4

Please sign in to comment.