diff --git a/build.gradle b/build.gradle index ead856fad..624b47371 100644 --- a/build.gradle +++ b/build.gradle @@ -30,11 +30,10 @@ buildscript { } plugins { - id "maven-publish" - id "com.diffplug.gradle.spotless" version "4.3.0" - id "com.matthewprenger.cursegradle" version "1.4.0" - id "org.sonarqube" version "2.8" - id "jacoco" + id "maven-publish" + id "com.diffplug.gradle.spotless" version "4.3.0" + id "com.matthewprenger.cursegradle" version "1.4.0" + id "idea" } apply plugin: 'net.minecraftforge.gradle' @@ -45,8 +44,32 @@ repositories { mavenLocal() jcenter() mavenCentral() + maven { // modmaven, maven proxy + name 'modmaven' + url "https://modmaven.k-4u.nl/" + } } +dependencies { + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + + // compile against provided APIs + compileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api" + compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api" + + // Runtime, Mods + runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") + runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}") + + // unit test dependencies + testCompile "junit:junit:4.13" + + // Annotation Processors + annotationProcessor 'org.spongepowered:mixin:0.8:processor' +} +group = artifact_group +archivesBaseName = artifact_basename + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 compileJava { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 @@ -58,7 +81,8 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } -// Create version number +/////////////////// +// Version Number version = version_major + "." + version_minor + "." + version_patch ext.pr = System.getenv('PR_NUMBER') ?: "" @@ -76,10 +100,8 @@ if (ext.release) { version = ext.release } - -// Maven group and artifact name -group = artifact_group -archivesBaseName = artifact_basename +ext.isAlpha = project.version.contains("alpha") +ext.isBeta = project.version.contains("beta") sourceSets { api @@ -103,9 +125,8 @@ configurations { apiCompile.extendsFrom(compile) } -apply from: 'gradle/scripts/dependencies.gradle' -apply from: 'gradle/scripts/spotless.gradle' - +//////////////////// +// Forge/Minecraft minecraft { mappings channel: "snapshot", version: project.mcp_mappings @@ -147,18 +168,14 @@ minecraft { } } +/////////// +// Mixins mixin { add sourceSets.main, "appliedenergistics2.mixins.refmap.json" } -jar { - manifest { - attributes([ - "MixinConfigs": "appliedenergistics2.mixins.json" - ]) - } -} - +//////////////// +// Jar Signing def signProps = [:] if (System.getenv("KEY_STORE_FILE")) { signProps['keyStore'] = System.getenv("KEY_STORE_FILE") @@ -181,9 +198,75 @@ task signJar(type: net.minecraftforge.gradle.common.task.SignJar, dependsOn: 're } } -apply from: 'gradle/scripts/artifacts.gradle' -apply from: 'gradle/scripts/curseforge.gradle' +////////////// +// Aritfacts +processResources { + exclude '.cache' +} +jar { + finalizedBy 'reobfJar' + finalizedBy 'signJar' + + from sourceSets.main.output.classesDirs + from sourceSets.api.output.classesDirs + from sourceSets.main.output.resourcesDir + from sourceSets.api.output.resourcesDir + + manifest { + attributes([ + "Specification-Title": "Applied Energistics 2", + "Specification-Vendor": "TeamAppliedEnergistics", + "Specification-Version": "${project.version}", + "Implementation-Title": "${project.name}", + "Implementation-Version": "${project.version}", + "Implementation-Vendor" :"TeamAppliedEnergistics", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs": "appliedenergistics2.mixins.json" + ]) + } +} + +task javadocs(type: Javadoc) { + classpath = sourceSets.main.compileClasspath + source = sourceSets.api.java + include "appeng/api/**" + + options.addStringOption('Xdoclint:none', '-quiet') + options.encoding = 'UTF-8' + options.charSet = 'UTF-8' +} + +task javadocJar(type: Jar, dependsOn: javadocs) { + classifier = "javadoc" + from javadoc.destinationDir +} + +task sourcesJar(type: Jar) { + classifier = "sources" + from sourceSets.main.allJava + from sourceSets.api.allJava +} + +task apiJar(type: Jar) { + classifier = "api" + from sourceSets.api.output + include "appeng/api/**" + + // TODO: when FG bug is fixed, remove allJava from the api jar. + // https://github.com/MinecraftForge/ForgeGradle/issues/369 + // Gradle should be able to pull them from the -sources jar. + from sourceSets.api.allJava +} + +artifacts { + archives javadocJar + archives sourcesJar + archives apiJar +} + +////////////////// +// Maven publish publishing { publications { maven(MavenPublication) { @@ -222,3 +305,53 @@ publishing { } } } + +///////////// +// Spotless +spotless { + java { + target 'src/*/java/appeng/**/*.java' + + indentWithSpaces() + eclipse().configFile 'codeformat/codeformat.xml' + importOrderFile 'codeformat/ae2.importorder' + } + format 'json', { + target 'src/*/resources/**/*.json' + targetExclude 'src/generated/resources/**' + prettier().config(['parser': 'json']) + } +} + +//////////////// +// Curse Forge +if (System.getenv("CURSEFORGE")) { + def cfReleaseType = "release" + if (ext.isAlpha) { + cfReleaseType = "alpha" + } else if (ext.isBeta) { + cfReleaseType = "beta" + } + + curseforge { + apiKey = System.getenv("CURSEFORGE") + project { + id = project.curseforge_project + changelogType = "markdown" + changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) for a changelog" + releaseType = cfReleaseType + } + } +} + +//////////////// +// IntelliJ Project Import +// The Mixin annotation process does not have an obfuscation source when running through the IntelliJ compiler, +// thus we have to prevent it from being activated as part of importing this Gradle project into IntelliJ. +if (System.getProperty("idea.sync.active") == "true") { + afterEvaluate { + tasks.withType(JavaCompile).all { + it.options.annotationProcessorPath = files() + } + } +} diff --git a/gradle/scripts/artifacts.gradle b/gradle/scripts/artifacts.gradle deleted file mode 100644 index f9503ff9b..000000000 --- a/gradle/scripts/artifacts.gradle +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -processResources { - exclude '.cache' -} - -jar { - finalizedBy 'reobfJar' - finalizedBy 'signJar' - - from sourceSets.main.output.classesDirs - from sourceSets.api.output.classesDirs - from sourceSets.main.output.resourcesDir - from sourceSets.api.output.resourcesDir - - manifest { - attributes([ - "Specification-Title": "Applied Energistics 2", - "Specification-Vendor": "TeamAppliedEnergistics", - "Specification-Version": "${project.version}", - "Implementation-Title": "${project.name}", - "Implementation-Version": "${project.version}", - "Implementation-Vendor" :"TeamAppliedEnergistics", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - ]) - } -} - -task javadocs(type: Javadoc) { - classpath = sourceSets.main.compileClasspath - source = sourceSets.api.java - include "appeng/api/**" - - options.addStringOption('Xdoclint:none', '-quiet') - options.encoding = 'UTF-8' - options.charSet = 'UTF-8' -} - -task javadocJar(type: Jar, dependsOn: javadocs) { - classifier = "javadoc" - from javadoc.destinationDir -} - -task sourcesJar(type: Jar) { - classifier = "sources" - from sourceSets.main.allJava - from sourceSets.api.allJava -} - -task apiJar(type: Jar) { - classifier = "api" - from sourceSets.api.output - include "appeng/api/**" - - // TODO: when FG bug is fixed, remove allJava from the api jar. - // https://github.com/MinecraftForge/ForgeGradle/issues/369 - // Gradle should be able to pull them from the -sources jar. - from sourceSets.api.allJava -} - -artifacts { - archives javadocJar - archives sourcesJar - archives apiJar -} \ No newline at end of file diff --git a/gradle/scripts/curseforge.gradle b/gradle/scripts/curseforge.gradle deleted file mode 100644 index a925a4506..000000000 --- a/gradle/scripts/curseforge.gradle +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2020, TeamAppliedEnergistics, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *g GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -def isAlpha = project.version.contains("alpha") -def isBeta = project.version.contains("beta") - -def cfReleaseType = "release" -if (isAlpha) { - cfReleaseType = "alpha" -} else if (isBeta) { - cfReleaseType = "beta" -} - -if (System.getenv("CURSEFORGE")) { - curseforge { - apiKey = System.getenv("CURSEFORGE") - project { - id = project.curseforge_project - changelogType = "markdown" - changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) for a changelog" - releaseType = cfReleaseType - } - } -} \ No newline at end of file diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle deleted file mode 100644 index 064d84dde..000000000 --- a/gradle/scripts/dependencies.gradle +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -repositories { - mavenLocal() - - maven { // modmaven, maven proxy - name 'modmaven' - url "https://modmaven.k-4u.nl/" - } -} - -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - - // compile against provided APIs - compileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api" - compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api" - - // Runtime, Mods - runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") - runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}") - //runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}") - - // unit test dependencies - testCompile "junit:junit:4.13" -} diff --git a/gradle/scripts/spotless.gradle b/gradle/scripts/spotless.gradle deleted file mode 100644 index ef51ef3cf..000000000 --- a/gradle/scripts/spotless.gradle +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *g GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -spotless { - java { - target 'src/*/java/appeng/**/*.java' - - indentWithSpaces() - eclipse().configFile 'codeformat/codeformat.xml' - importOrderFile 'codeformat/ae2.importorder' - } - format 'json', { - target 'src/*/resources/**/*.json' - targetExclude 'src/generated/resources/**' - prettier().config(['parser': 'json']) - } -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 0d4a95168..94336fcae 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 290541c73..f04d6a20a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists