mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Start documenting some of the bradle scripts.
Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
This commit is contained in:
		@@ -1,6 +1,15 @@
 | 
			
		||||
import net.minecraftforge.gradle.user.UserBaseExtension
 | 
			
		||||
import Config.Libs.Sponge.API7 as API7
 | 
			
		||||
// Config is located in <root>/buildSrc/src/main/java/Config.kt
 | 
			
		||||
// It provides a bunch of constant values we use as dependency
 | 
			
		||||
// strings, so we don't have to duplicate a bunch of them in
 | 
			
		||||
// various scripts. The import as allows for shorthand.
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Special dependency for the buildscript to be able to use ForgeGradle 2.3-SNAPSHOT.
 | 
			
		||||
Needs to define the repository where FG exists, and then adds the classpath of the
 | 
			
		||||
plugin jar for the buildscript. It's what allows us to import UserBaseExtension
 | 
			
		||||
 */
 | 
			
		||||
buildscript {
 | 
			
		||||
    repositories {
 | 
			
		||||
        jcenter()
 | 
			
		||||
@@ -10,27 +19,43 @@ buildscript {
 | 
			
		||||
        classpath(Plugins.FG2_3.classpath)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
// Extension created to set up the minecraft block for ForgeGradle. This should change in FG3.
 | 
			
		||||
 | 
			
		||||
// Extension created to set up the minecraft block for ForgeGradle. This will be different for ForgeGradle 3>, but we don't
 | 
			
		||||
// use that newer version for 1.12, that will be used for 1.13+
 | 
			
		||||
val Project.minecraft: UserBaseExtension
 | 
			
		||||
    get() = extensions.getByName<UserBaseExtension>(Plugins.FG2_3.extensionName)
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
    `java-library`
 | 
			
		||||
    // Apply the spongegradle plugin to generate the metadata file
 | 
			
		||||
    // Apply the spongegradle plugin to generate the metadata file, these cannot be import shorthanded because
 | 
			
		||||
    // they need to be resolved at script compilation time to apply the plugin
 | 
			
		||||
    id(Config.Libs.Sponge.API7.spongeGradleId) version Config.Libs.Sponge.API7.spongeGradleVersion // supplies sponge repo and plugin metadata creation tasks
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Apply the FG2.3 plguin the old way, because there's no valid way to do it the new plugins way.
 | 
			
		||||
apply(plugin = API7.forgeGradleId)
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
    // Only SpongeAPI needed for the base plugin class, a majority will be api version dependent.
 | 
			
		||||
    compileOnly(API7.api)  // SpongeAPI
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Now this configures ForgeGradle to set up the Minecraft (NMS) dependency. To use it, one needs to run
 | 
			
		||||
`gradlew sDecW` either from root or `gradlew :sponge:api7:sDecW`. The process generates a Minecraft
 | 
			
		||||
dependency with forge sources so one can read MCP remapped code. The dependency is not included in
 | 
			
		||||
git.
 | 
			
		||||
 */
 | 
			
		||||
configure<UserBaseExtension> {
 | 
			
		||||
    version = API7.minecraftVersion
 | 
			
		||||
    runDir = "run"
 | 
			
		||||
    mappings = API7.mappings
 | 
			
		||||
    version = API7.minecraftVersion // The minecraft (forge) version
 | 
			
		||||
    runDir = "run" // Where the run directory will be placed
 | 
			
		||||
    mappings = API7.mappings // The MCP mappings version
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Some extra information that needs to be included for plugin/mod generation that will be
 | 
			
		||||
 * parsed by Sponge or Forge (when SpongeForge is involved, Forge loads the plugins for SpongeForge)
 | 
			
		||||
 */
 | 
			
		||||
tasks.withType<Jar> {
 | 
			
		||||
    inputs.properties += "version" to project.version
 | 
			
		||||
    inputs.properties += "mcversion" to project.minecraft.version
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
mod_name = "mcmmo"
 | 
			
		||||
mod_version = "2.2-SNAPSHOT"
 | 
			
		||||
mc_version = "1.12.2"
 | 
			
		||||
@@ -1,8 +1,13 @@
 | 
			
		||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
 | 
			
		||||
import Config.Libs.Sponge as Sponge
 | 
			
		||||
// Config is located in <root>/buildSrc/src/main/java/Config.kt
 | 
			
		||||
// It provides a bunch of constant values we use as dependency
 | 
			
		||||
// strings, so we don't have to duplicate a bunch of them in
 | 
			
		||||
// various scripts. The import as allows for shorthand.
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
    java
 | 
			
		||||
    `java-library` // This is already provided, but for static compilation,
 | 
			
		||||
    // we declare it here so we can use the IDE static type references
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
val core = Projects.core!! // because it's a var and potentially null by declaration
 | 
			
		||||
@@ -10,23 +15,36 @@ val sponge = Projects.sponge!! // because it's a var and potentially null by dec
 | 
			
		||||
 | 
			
		||||
description = "mcMMO for Sponge"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
These dependencies are minimalized. SpongeAPI is not inherited by subprojects.
 | 
			
		||||
Bstats-sponge is api version agnostic for the moment.
 | 
			
		||||
 */
 | 
			
		||||
dependencies {
 | 
			
		||||
    compile(Sponge.bstats) // Bstats is used for all sponge versions
 | 
			
		||||
    compileOnly(Sponge.API7.api) // Base version
 | 
			
		||||
    compileOnly(Sponge.API7.api) // Base version for common plugin class
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This configures ":sponge" and it's dependent projects:
 | 
			
		||||
   - ":sponge:api7"
 | 
			
		||||
   Basically sets up all projects to depend on ":core" and
 | 
			
		||||
   bstats-sponge. Bstatss-sponge should not be relocated
 | 
			
		||||
 */
 | 
			
		||||
allprojects {
 | 
			
		||||
    dependencies {
 | 
			
		||||
        compile(Projects.core!!)
 | 
			
		||||
    }
 | 
			
		||||
    // TODO dunno if this works yet... project needs to compile.
 | 
			
		||||
    val shadowJar by tasks.getting(ShadowJar::class) {
 | 
			
		||||
    val shadowJar by tasks.getting(ShadowJar::class) { // We set this up so we relocate all sponge projects, not just ":sponge"
 | 
			
		||||
        relocate(Deps.Groups.nossr, "${Deps.Groups.nossr}.sponge") {
 | 
			
		||||
            exclude("${Deps.Groups.nossr}.core")
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Tells all subprojects of ":sponge" (":sponge:api7")
 | 
			
		||||
// to depend on this project (":sponge") to inherit the dependencies, and
 | 
			
		||||
// does NOT inherit the same configurations (anything configured outside
 | 
			
		||||
// here does not persist to child projects).
 | 
			
		||||
subprojects {
 | 
			
		||||
    dependencies {
 | 
			
		||||
        (compileOnly(sponge) as ModuleDependency).apply {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user