From 8fe7635e4278b32bd71c92d23324ce521794641f Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Sat, 20 Aug 2022 01:28:46 +0200 Subject: [PATCH 1/4] Create .gitattributes --- .gitattributes | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..9917fc4a --- /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 From b16ac91dee55964cdc40179105d99cfcb8677d58 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Sat, 20 Aug 2022 12:44:33 +0200 Subject: [PATCH 2/4] Auto download and repo renormalization --- build.gradle | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 1f363c02..07c2f2a9 100644 --- a/build.gradle +++ b/build.gradle @@ -666,12 +666,28 @@ 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 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', '.' + } + throw new GradleException(".gitattributes has been updated, please re-run task.") + } +} def verifySettingsGradle() { def settingsFile = getFile("settings.gradle") @@ -688,6 +704,7 @@ boolean performBuildScriptUpdate(String projectDir) { availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") verifySettingsGradle() + verifyGitAttributes() return true } return false From a5f6303d1e78926956965c7206654b71a7fda403 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Sat, 20 Aug 2022 12:56:37 +0200 Subject: [PATCH 3/4] Ensure to run both --- build.gradle | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 07c2f2a9..658973d2 100644 --- a/build.gradle +++ b/build.gradle @@ -676,7 +676,7 @@ static URL exampleGitAttributesUrl() { } -def verifyGitAttributes() { +boolean verifyGitAttributes() { def gitattributesFile = getFile(".gitattributes") if (!gitattributesFile.exists()) { println("Downloading default .gitattributes") @@ -685,17 +685,19 @@ def verifyGitAttributes() { workingDir '.' commandLine 'git', 'add', '--renormalize', '.' } - throw new GradleException(".gitattributes has been updated, please re-run task.") + return true } + return false } -def verifySettingsGradle() { +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) { @@ -703,8 +705,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() - verifyGitAttributes() + if(verifySettingsGradle() || verifyGitAttributes()) + throw new GradleException("Settings has been updated, please re-run task.") return true } return false From 23add8e93261bed6e912ccd7b7f55ad82b19ba97 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Sat, 20 Aug 2022 13:00:26 +0200 Subject: [PATCH 4/4] And here --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 658973d2..5c6eee6d 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'