Handles auto downloading a default settings.gradle if one doesn't exist

This commit is contained in:
Jason Mitchell authored and Jason Mitchell committed 2022-07-22 12:14:23 -07:00
1 parent 777fd9070f
commit dfeea0102f
2 files changed
+25 -1

No files matched your search

+15 -1
View File
@@ -43,7 +43,6 @@ buildscript {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
}
}
plugins {
id 'java-library'
id 'idea'
@@ -60,6 +59,7 @@ plugins {
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id "com.diffplug.spotless" version "6.7.2"
}
verifySettingsGradle()
dependencies {
implementation 'com.diffplug:blowdryer:1.6.0'
@@ -664,12 +664,26 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
static URL exampleSettingsGradleUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example")
}
def 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.")
}
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(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()
return true
}
return false
+10
View File
@@ -0,0 +1,10 @@
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
}
apply plugin: 'com.diffplug.blowdryerSetup'
blowdryerSetup {
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4')
//devLocal '.' // Use this when testing config updates locally
}