Skip to content

Commit 4b577e9

Browse files
committed
spotless + update buildscript
1 parent f3b326d commit 4b577e9

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

.gitattributes

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
* text eol=lf
2+
3+
*.jar binary
4+
5+
*.png binary
6+
*.jpg binary
7+
*.jpeg binary
8+
*.gif binary
9+
*.tif binary
10+
*.tiff binary
11+
*.ico binary
12+
*.svg text
13+
*.eps binary
14+
15+
*.kar binary
16+
*.m4a binary
17+
*.mid binary
18+
*.midi binary
19+
*.mp3 binary
20+
*.ogg binary
21+
*.ra binary
22+
23+
*.7z binary
24+
*.gz binary
25+
*.tar binary
26+
*.tgz binary
27+
*.zip binary
28+
29+
*.patch -text
30+
31+
*.bat text eol=crlf
32+
*.cmd text eol=crlf
33+
*.ps1 text eol=crlf
34+
35+
*autogenerated binary

build.gradle

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1660899027
1+
//version: 1660994461
22
/*
33
DO NOT CHANGE THIS FILE!
44
Also, you may replace this file at any time if there is an update available.
@@ -59,7 +59,8 @@ plugins {
5959
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
6060
id 'com.diffplug.spotless' version '6.7.2' apply false
6161
}
62-
verifySettingsGradle()
62+
if(verifySettingsGradle() || verifyGitAttributes())
63+
throw new GradleException("Settings has been updated, please re-run task.")
6364

6465
dependencies {
6566
implementation 'com.diffplug:blowdryer:1.6.0'
@@ -666,28 +667,47 @@ if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAv
666667
}
667668

668669
static URL availableBuildScriptUrl() {
669-
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
670+
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle")
670671
}
671672
static URL exampleSettingsGradleUrl() {
672-
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example")
673+
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example")
674+
}
675+
static URL exampleGitAttributesUrl() {
676+
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes")
673677
}
674678

675679

676-
def verifySettingsGradle() {
680+
boolean verifyGitAttributes() {
681+
def gitattributesFile = getFile(".gitattributes")
682+
if (!gitattributesFile.exists()) {
683+
println("Downloading default .gitattributes")
684+
exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } }
685+
exec {
686+
workingDir '.'
687+
commandLine 'git', 'add', '--renormalize', '.'
688+
}
689+
return true
690+
}
691+
return false
692+
}
693+
694+
boolean verifySettingsGradle() {
677695
def settingsFile = getFile("settings.gradle")
678696
if (!settingsFile.exists()) {
679697
println("Downloading default settings.gradle")
680698
exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } }
681-
throw new GradleException("Settings.gradle has been updated, please re-run task.")
699+
return true
682700
}
701+
return false
683702
}
684703

685704
boolean performBuildScriptUpdate(String projectDir) {
686705
if (isNewBuildScriptVersionAvailable(projectDir)) {
687706
def buildscriptFile = getFile("build.gradle")
688707
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
689708
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
690-
verifySettingsGradle()
709+
if(verifySettingsGradle() || verifyGitAttributes())
710+
throw new GradleException("Settings has been updated, please re-run task.")
691711
return true
692712
}
693713
return false

0 commit comments

Comments
 (0)