Skip to content

Commit

Permalink
GEODE-6395: Use md5 as Spotless cache value. (apache#3186)
Browse files Browse the repository at this point in the history
* This acts as a safeguard against developers forgetting to bump the input to 'bumpThisNumberIfACustomStepChanges'
  • Loading branch information
PurelyApplied authored Feb 13, 2019
1 parent a2d8a98 commit 6bec09f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
* limitations under the License.
*/

// When a custom step changes, we need to bump the value passed to the method
// bumpThisNumberIfACustomStepChanges
// This has been historicaly easy to forget, however, and can cause failures in some rare cases.
// To safeguard against this, we instead use the (partial) md5 of this file as that method input.
def thisFile = file("${scriptDir}/spotless.gradle")
def thisFileMd5 = thisFile.text.md5() as String
def thisFileMd5Piece = thisFileMd5.substring(0, 8)
def thisFileIntegerHash = Integer.parseUnsignedInt(thisFileMd5Piece, 16)
logger.debug("Using partial md5 (${thisFileIntegerHash}) of file ${thisFile} as spotless bump.")

subprojects {
apply plugin: "com.diffplug.gradle.spotless"
spotless {
Expand All @@ -28,7 +38,7 @@ subprojects {

// As the method name suggests, bump this number if any of the below "custom" rules change.
// Spotless will not run on unchanged files unless this number changes.
bumpThisNumberIfACustomStepChanges(3)
bumpThisNumberIfACustomStepChanges(thisFileIntegerHash)

removeUnusedImports()

Expand Down Expand Up @@ -115,7 +125,7 @@ subprojects {

// As the method name suggests, bump this number if any of the below "custom" rules change.
// Spotless will not run on unchanged files unless this number changes.
bumpThisNumberIfACustomStepChanges(0)
bumpThisNumberIfACustomStepChanges(thisFileIntegerHash)

custom 'Use single-quote in project directives.', {
it.replaceAll(/project\(":([^"]*)"\)/, 'project(\':$1\')')
Expand Down

0 comments on commit 6bec09f

Please sign in to comment.