diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh new file mode 100644 index 000000000..c67e342c0 --- /dev/null +++ b/.github/scripts/test-no-crash-reports.sh @@ -0,0 +1,9 @@ +directory="run/crash-reports" +if [ -d $directory ]; then + echo "Crash reports detected:" + cat $directory/* + exit 1 +else + echo "No crash reports detected" + exit 0 +fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..a60a2b646 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Run server for 1 minute + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 60 ./gradlew runServer || true + + - name: Test no crashes happend + run: | + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 000000000..25c354b22 --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release tagged build + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Release under current tag + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.RELEASE_VERSION }}" + prerelease: false + title: "${{ env.RELEASE_VERSION }}" + files: build/libs/*.jar diff --git a/.gitignore b/.gitignore index 7242c75c8..558ad12d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,62 +1,28 @@ -## Windows -Thumbs.db - -## gradle -/.gradle -/build - -## ForgeGradle -/run - -## eclipse -/.settings -/.metadata -/.classpath -/.project -/eclipse -/bin - -## intellij -/out -/.idea -/atlassian-ide-plugin.xml -/*.ipr -/*.iws -/*.iml - -## Private Stuffs -/private.properties - -## Jars -*.jar -!/gradle/wrapper/gradle-wrapper.jar -!GardenOfGlass.jar - -### OSX (adds a lot of garbage)### -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -*.bat +.gradle +.settings +/.idea/ +/run/ +/build/ +/eclipse/ +.classpath +.project +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +/out/ +*.iml +*.ipr +*.iws +src/main/resources/mixins.*.json diff --git a/build.bat b/build.bat deleted file mode 100644 index 646a0cb1f..000000000 --- a/build.bat +++ /dev/null @@ -1 +0,0 @@ -gradlew build \ No newline at end of file diff --git a/build.gradle b/build.gradle index f77470da7..18fedd355 100644 --- a/build.gradle +++ b/build.gradle @@ -1,220 +1,529 @@ +//version: 928ecf7feb33a1149538b0e2cd17e3bc5f281428 +/* +DO NOT CHANGE THIS FILE! + +Also, you may replace this file at any time if there is an update available. +Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ + + +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +import java.util.concurrent.TimeUnit + buildscript { repositories { - mavenCentral() maven { name = "forge" - url = "http://files.minecraftforge.net/maven" + url = "https://maven.minecraftforge.net" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { + name = "Scala CI dependencies" + url = "https://repo1.maven.org/maven2/" + } + maven { + name = "jitpack" + url = "https://jitpack.io" + } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4' } } -repositories { - maven { - name = "chickenbones" - url = "http://chickenbones.net/maven/" - } +plugins { + id 'idea' + id 'scala' + id("org.ajoberstar.grgit") version("3.1.1") + id("com.github.johnrengelman.shadow") version("4.0.4") + id("com.palantir.git-version") version("0.12.3") } apply plugin: 'forge' -apply plugin: 'curseforge' -ext.configFile = file('build.properties') +def projectJavaVersion = JavaLanguageVersion.of(8) -ext.config = parseConfig(configFile) -ext.priv = parseConfig(file('private.properties')) +java { + toolchain { + languageVersion.set(projectJavaVersion) + } +} -version = "${config.version}-${config.build_number}" -group = "vazkii.botania" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = config.mod_name +idea { + module { + inheritOutputDirs = true + downloadJavadoc = true + downloadSources = true + } +} + +if(JavaVersion.current() != JavaVersion.VERSION_1_8) { + throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) +} + +checkPropertyExists("modName") +checkPropertyExists("modId") +checkPropertyExists("modGroup") +checkPropertyExists("autoUpdateBuildScript") +checkPropertyExists("minecraftVersion") +checkPropertyExists("forgeVersion") +checkPropertyExists("replaceGradleTokenInFile") +checkPropertyExists("gradleTokenModId") +checkPropertyExists("gradleTokenModName") +checkPropertyExists("gradleTokenVersion") +checkPropertyExists("gradleTokenGroupName") +checkPropertyExists("apiPackage") +checkPropertyExists("accessTransformersFile") +checkPropertyExists("usesMixins") +checkPropertyExists("mixinPlugin") +checkPropertyExists("mixinsPackage") +checkPropertyExists("coreModClass") +checkPropertyExists("containsMixinsAndOrCoreModOnly") +checkPropertyExists("usesShadowedDependencies") +checkPropertyExists("developmentEnvironmentUserName") + + +String javaSourceDir = "src/main/java/" +String scalaSourceDir = "src/main/scala/" + +String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") +String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") +if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala) +} + +if(apiPackage) { + targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + } +} + +if(accessTransformersFile) { + String targetFile = "src/main/resources/META-INF/" + accessTransformersFile + if(getFile(targetFile).exists() == false) { + throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) + } +} + +if(usesMixins.toBoolean()) { + if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { + throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") + } + + targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + } + + String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) { + throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + } +} + +if(coreModClass) { + String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" + String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" + if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) { + throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + } +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) + + // Make sure GregTech build won't time out + System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String) + System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String) +} + +// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version +'git config core.fileMode false'.execute() +// Pulls version from git tag +try { + version = minecraftVersion + "-" + gitVersion() +} +catch (Exception e) { + throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!"); +} + +group = modGroup +if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { + archivesBaseName = customArchiveBaseName +} +else { + archivesBaseName = modId +} minecraft { - version = "${config.mc_version}-${config.forge_version}" - assetDir = "eclipse/assets" + version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion + runDir = "run" - //This, does the token replacement. - //Though, I reccomend this to be replaced with a token such as @VERSION@ - replace 'GRADLE:BUILD', config.build_number - replace 'GRADLE:VERSION', config.version - - replaceIn 'LibMisc.java' //I may have missed another file, though I can only find it in here. -} - -//This here is for SCP -repositories { - mavenCentral() -} -configurations { - sshAntTask -} - -//End of the SCP config - -dependencies { - compile files( - 'Baubles-deobf.jar' - ) - compile "codechicken:CodeChickenLib:1.7.10-1.1.1.109:dev" - compile "codechicken:CodeChickenCore:1.7.10-1.0.2.9:dev" - compile "codechicken:NotEnoughItems:1.7.10-1.0.2.15:dev" - compile "codechicken:ForgeMultipart:1.7.10-1.1.1.320:dev" - - //and a bit more for SCP - sshAntTask "org.apache.ant:ant-jsch:1.7.1", "jsch:jsch:0.1.29" -} - -processResources { - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version': project.version, 'mcversion': project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info', '**/psd/**' - } -} - -/** - * These, go outside of the processResources {}* Though, this was added with the NEI intergation commit (8bf4680) - */ -task deobfJar(type: Jar) { - from(sourceSets.main.output) - archiveName = "${baseName} ${version}-deobf.${extension}" -} - -artifacts { - archives deobfJar -} -/** - * Increments the buildnumber in your config file, and saves it - */ -task incrementBuildNumber(dependsOn: 'reobf') << { - config.build_number = (config.build_number.toString().toInteger()) + 1 - configFile.withWriter { - config.toProperties().store(it, "") - } - - file('web/versions.ini').append("\n${version}=${minecraft.version}") - file("${config.dir_repo}/version/${minecraft.version}.txt").write("${version}") -} - -// I have no idea what I'm doing -task wtfGradle2(type: Copy) { - from(jar.destinationDir) - into file("${config.dir_output}/wtf") -} - -// Seriously, I'm desperate to make this work -task wtfGradle1(type: Delete) { - dependsOn "wtfGradle2" - delete "${config.dir_output}/wtf/${deobfJar.archiveName}" -} - -task output(type: Copy) { - dependsOn "wtfGradle1" - from(jar.destinationDir) - into file(config.dir_output) -} - -task outputDeobf(type: Copy) { - dependsOn "output" - from(config.dir_output) { - include deobfJar.archiveName - } - into file("${config.dir_output}/deobf") -} - -task forgecraft(type: Copy) { - dependsOn "outputDeobf" - from "${config.dir_output}/wtf" - into file(priv.dir_forgecraft) -} - -task sort(type: Delete) { - dependsOn "forgecraft" - delete "${config.dir_output}/${deobfJar.archiveName}", "${config.dir_output}/wtf" -} - -/** - * This is the upload task from the build.xml - */ -task upload() << { - scp('/files') { - fileset(file: jar.archivePath) - } - - scp('/files/deobf') { - fileset(file: deobfJar.archivePath) - } - - scp('/') { - fileset(file: 'web/changelog.txt') - fileset(file: 'web/versions.ini') - } -} - -/** - * This is deply_web task - */ -task deployWeb << { - scp('/') { - fileset(dir: 'web') //everything from the web directory - } -} - -def scp(String dir, Closure antFileset = {}) { - ant { - taskdef( - name: 'scp', - classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', - classpath: configurations.sshAntTask.asPath) - - String dirstr = priv.scp_dir + dir - Map scpArgs = [ - todir : dirstr, - password : priv.scp_pass, - sftp: true, - trust: 'yes' - ] - - delegate.scp(scpArgs) { - antFileset.delegate = delegate - antFileset() + if (replaceGradleTokenInFile) { + replaceIn replaceGradleTokenInFile + if(gradleTokenModId) { + replace gradleTokenModId, modId + } + if(gradleTokenModName) { + replace gradleTokenModName, modName + } + if(gradleTokenVersion) { + replace gradleTokenVersion, versionDetails().lastTag + } + if(gradleTokenGroupName) { + replace gradleTokenGroupName, modGroup } } } -def parseConfig(File config) { - config.withReader { - def prop = new Properties() - prop.load(it) - return (new ConfigSlurper().parse(prop)) +if(file("addon.gradle").exists()) { + apply from: "addon.gradle" +} + +apply from: 'repositories.gradle' + +configurations { + implementation.extendsFrom(shadowImplementation) +} + +repositories { + maven { + name = "Overmind forge repo mirror" + url = "https://gregtech.overminddl1.com/" + } + if(usesMixins.toBoolean()) { + maven { + name = "sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + maven { + url = "https://jitpack.io" + } } } +dependencies { + if(usesMixins.toBoolean()) { + annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") + annotationProcessor("com.google.guava:guava:24.1.1-jre") + annotationProcessor("com.google.code.gson:gson:2.8.6") + annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT") + // using 0.8 to workaround a issue in 0.7 which fails mixin application + compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + // Mixin includes a lot of dependencies that are too up-to-date + exclude module: "launchwrapper" + exclude module: "guava" + exclude module: "gson" + exclude module: "commons-io" + exclude module: "log4j-core" + } + compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev") + } +} + +apply from: 'dependencies.gradle' + +def mixingConfigRefMap = "mixins." + modId + ".refmap.json" +def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap +def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" + +task generateAssets { + if(usesMixins.toBoolean()) { + getFile("/src/main/resources/mixins." + modId + ".json").text = """{ + "required": true, + "minVersion": "0.7.11", + "package": "${modGroup}.${mixinsPackage}", + "plugin": "${modGroup}.${mixinPlugin}", + "refmap": "${mixingConfigRefMap}", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8" +} + +""" + } +} + +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = modGroup + ".shadow" +} + +shadowJar { + manifest { + attributes(getManifestAttributes()) + } + + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] + dependsOn(relocateShadowJar) +} + jar { - //rename the default output, for some better... sanity with scipts - archiveName = "${baseName} ${version}.${extension}" + manifest { + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(shadowJar) + enabled = false + } } -curse { - apiKey = priv.cfkey - projectId = "225643" - changelog = """ - See http://botaniamod.net/changelog.php#${version} - """ - releaseType = "release" - relatedProject 'baubles': 'requiredLibrary' +reobf { + if(usesMixins.toBoolean()) { + addExtraSrgFile mixinSrg + } } -defaultTasks 'clean', 'build', 'sort', 'forgecraft', 'incrementBuildNumber', 'curse', 'upload' +afterEvaluate { + if(usesMixins.toBoolean()) { + tasks.compileJava { + options.compilerArgs += [ + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" + ] + } + } +} + +runClient { + def arguments = [] + + if(usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + if(developmentEnvironmentUserName) { + arguments += [ + "--username", + developmentEnvironmentUserName + ] + } + + args(arguments) +} + +runServer { + def arguments = [] + + if (usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + args(arguments) +} + +tasks.withType(JavaExec).configureEach { + javaLauncher.set( + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } + ) +} + +processResources + { + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + // replace version and mcversion + expand "minecraftVersion": project.minecraft.version, + "modVersion": versionDetails().lastTag, + "modId": modId, + "modName": modName + } + + if(usesMixins.toBoolean()) { + from refMap + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + } + +def getManifestAttributes() { + def manifestAttributes = [:] + if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { + manifestAttributes += ["FMLCorePluginContainsFMLMod": true] + } + + if(accessTransformersFile) { + manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + } + + if(coreModClass) { + manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass] + } + + if(usesMixins.toBoolean()) { + manifestAttributes += [ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false + ] + } + return manifestAttributes +} + +task sourcesJar(type: Jar) { + from (sourceSets.main.allJava) + from (file("$projectDir/LICENSE")) + getArchiveClassifier().set('sources') +} + +task shadowDevJar(type: ShadowJar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] +} + +task relocateShadowDevJar(type: ConfigureShadowRelocation) { + target = tasks.shadowDevJar + prefix = modGroup + ".shadow" +} + +task circularResolverJar(type: Jar) { + dependsOn(relocateShadowDevJar) + dependsOn(shadowDevJar) + enabled = false +} + +task devJar(type: Jar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(circularResolverJar) + enabled = false + } +} + +task apiJar(type: Jar) { + from (sourceSets.main.allJava) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + } + + from (sourceSets.main.output) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + } + + from (sourceSets.main.resources.srcDirs) { + include("LICENSE") + } + + getArchiveClassifier().set('api') +} + +artifacts { + archives sourcesJar + archives devJar + if(apiPackage) { + archives apiJar + } +} + +// Updating +task updateBuildScript { + doLast { + if (performBuildScriptUpdate(projectDir.toString())) return + + print("Build script already up-to-date!") + } +} + +if (isNewBuildScriptVersionAvailable(projectDir.toString())) { + if (autoUpdateBuildScript.toBoolean()) { + performBuildScriptUpdate(projectDir.toString()) + } else { + println("Build script update available! Run 'gradle updateBuildScript'") + } +} + +static URL availableBuildScriptUrl() { + new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle") +} + +boolean performBuildScriptUpdate(String projectDir) { + if (isNewBuildScriptVersionAvailable(projectDir)) { + def buildscriptFile = getFile("build.gradle") + availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } + print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + return true + } + return false +} + +boolean isNewBuildScriptVersionAvailable(String projectDir) { + Map parameters = ["connectTimeout": 2000, "readTimeout": 2000] + + String currentBuildScript = getFile("build.gradle").getText() + String currentBuildScriptHash = getVersionHash(currentBuildScript) + String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() + String availableBuildScriptHash = getVersionHash(availableBuildScript) + + boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash + return !isUpToDate +} + +static String getVersionHash(String buildScriptContent) { + String versionLine = buildScriptContent.find("^//version: [a-z0-9]*") + if(versionLine != null) { + return versionLine.split(": ").last() + } + return "" +} + +configure(updateBuildScript) { + group = 'forgegradle' + description = 'Updates the build script to the latest version' +} + +// Helper methods + +def checkPropertyExists(String propertyName) { + if (project.hasProperty(propertyName) == false) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties") + } +} + +def getFile(String relativePath) { + return new File(projectDir, relativePath) +} diff --git a/build.properties b/build.properties deleted file mode 100644 index cecdd944a..000000000 --- a/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -# -#Thu Feb 25 19:50:43 GMT 2016 -version=r1.8 -dir_output=../Build Output/Botania/ -dir_repo=./ -forge_version=10.13.4.1614-1.7.10 -mc_version=1.7.10 -build_number=250 -mod_name=Botania diff --git a/contributors.properties b/contributors.properties deleted file mode 100644 index b2eeb8e39..000000000 --- a/contributors.properties +++ /dev/null @@ -1,63 +0,0 @@ -# Devs -#vazkii=6 -wiiv=marimorphosis -dylangk=munchdew - -# Cool People -sl1pg8r=endoflame -direwolf20=thermalily -#wayofflowingtime=fallenKanade -wtfgeeks=daybloom -spitefulfox=tainthistle -gideonseymour=arcaneRose -#pahimar=medumone - -# Flower Designers -jadedcat=jadedAmaranthus -pokefenn=hydroangeas -finvaara=bubbell -flaxbeard=kekimurus - -# Patrons -devinpath=9 -cheriekeks=6 -orangeninja1=1 -disbedan015=14 -djcosmic2=3 -utoxin=2 -evrlost=10 -belathus=1 -vicceyr=0 -superfortress=3 -nematrec=15 -pika_craft=3 -lanman14444=13 -noclassdeffound=9 -emba=0 -jordsta95=6 -kei_kouma=15 -megatronp=15 -thorantin=6 -fletchstudios=6 -donaber=4 -agamemnom=15 -dqmhose=13 -fma_winry=2 -luckylucyf=14 -epiczeus=7 -fredfrog1234=15 -pjfranke=5 -_bloop=0 -kgevans=15 -l0nekitsune=14 -swiftlileagle=14 -gryphonn=11 -loraanicus=10 -samerater=8 -coolcabbage16=13 -eladkay=3 -tobiasling=9 -hysting=10 -tyra_oa=6 -rai6996=6 -saintsquiggle=0 diff --git a/dependencies.gradle b/dependencies.gradle new file mode 100644 index 000000000..b6456d02b --- /dev/null +++ b/dependencies.gradle @@ -0,0 +1,5 @@ +// Add your dependencies here + +dependencies { + +} diff --git a/deploy-website.bat b/deploy-website.bat deleted file mode 100644 index fd266adc9..000000000 --- a/deploy-website.bat +++ /dev/null @@ -1 +0,0 @@ -sh gradlew deployWeb \ No newline at end of file diff --git a/eclipse/Cleanup Profile.xml b/eclipse/Cleanup Profile.xml deleted file mode 100644 index 6942d97c5..000000000 --- a/eclipse/Cleanup Profile.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/eclipse/Code Template.xml b/eclipse/Code Template.xml deleted file mode 100644 index df985846f..000000000 --- a/eclipse/Code Template.xml +++ /dev/null @@ -1,20 +0,0 @@ -