Skip to content

Commit

Permalink
Merge all gradle files (#4732)
Browse files Browse the repository at this point in the history
* Merge all gradle files

The specific build files are now much smaller, so a single one is mostly acceptable now.
Also updates Gradle to 5.6.3

* Disable the Mixin annotation processor when importing this project into IntelliJ since it should only be needed to generate refmaps on an actual build.

* Removed Sonarqube and JaCoCo plugins.

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
  • Loading branch information
yueh and shartte authored Sep 14, 2020
1 parent 3824400 commit 5b3ccf2
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 218 deletions.
179 changes: 156 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -45,7 +44,31 @@ 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 {
Expand All @@ -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') ?: ""
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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) {
Expand Down Expand Up @@ -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()
}
}
}
81 changes: 0 additions & 81 deletions gradle/scripts/artifacts.gradle

This file was deleted.

39 changes: 0 additions & 39 deletions gradle/scripts/curseforge.gradle

This file was deleted.

Loading

0 comments on commit 5b3ccf2

Please sign in to comment.