diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9917fc4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,35 @@ +* text eol=lf + +*.jar binary + +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +*.svg text +*.eps binary + +*.kar binary +*.m4a binary +*.mid binary +*.midi binary +*.mp3 binary +*.ogg binary +*.ra binary + +*.7z binary +*.gz binary +*.tar binary +*.tgz binary +*.zip binary + +*.patch -text + +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +*autogenerated binary \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1f363c0..5c6eee6 100644 --- a/build.gradle +++ b/build.gradle @@ -59,7 +59,8 @@ plugins { id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false id 'com.diffplug.spotless' version '6.7.2' apply false } -verifySettingsGradle() +if(verifySettingsGradle() || verifyGitAttributes()) + throw new GradleException("Settings has been updated, please re-run task.") dependencies { implementation 'com.diffplug:blowdryer:1.6.0' @@ -666,20 +667,38 @@ if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAv } static URL availableBuildScriptUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle") + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle") } static URL exampleSettingsGradleUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example") + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example") +} +static URL exampleGitAttributesUrl() { + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes") } -def verifySettingsGradle() { +boolean verifyGitAttributes() { + def gitattributesFile = getFile(".gitattributes") + if (!gitattributesFile.exists()) { + println("Downloading default .gitattributes") + exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } } + exec { + workingDir '.' + commandLine 'git', 'add', '--renormalize', '.' + } + return true + } + return false +} + +boolean verifySettingsGradle() { def settingsFile = getFile("settings.gradle") if (!settingsFile.exists()) { println("Downloading default settings.gradle") exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } - throw new GradleException("Settings.gradle has been updated, please re-run task.") + return true } + return false } boolean performBuildScriptUpdate(String projectDir) { @@ -687,7 +706,8 @@ boolean performBuildScriptUpdate(String projectDir) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") - verifySettingsGradle() + if(verifySettingsGradle() || verifyGitAttributes()) + throw new GradleException("Settings has been updated, please re-run task.") return true } return false