Complete Kotlin-DSL Gradle scripting for multiple projects.

Added the shadow plugin integration with the entire project. Indvidual
modules each have their designated dependencies and each will assign
various dependencies based on constants now made through buildSrc.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
This commit is contained in:
Gabriel Harris-Rouquette
2019-02-16 18:39:44 -08:00
parent 196ace4b81
commit 8645ce641d
16 changed files with 431 additions and 68 deletions

View File

@ -1,12 +1,47 @@
plugins {
java
// Apply the spongegradle plugin to generate the metadata file
id("org.spongepowered.plugin") version "0.9.0" // supplies sponge repo and plugin metadata creation tasks
import net.minecraftforge.gradle.user.UserBaseExtension
import Config.Libs.Sponge.API7 as API7
buildscript {
repositories {
jcenter()
maven(Repos.forge)
}
dependencies {
classpath(Plugins.FG2_3.classpath)
}
}
// Extension created to set up the minecraft block for ForgeGradle. This should change in FG3.
val Project.minecraft: UserBaseExtension
get() = extensions.getByName<UserBaseExtension>(Plugins.FG2_3.extensionName)
plugins {
`java-library`
// Apply the spongegradle plugin to generate the metadata file
id(Config.Libs.Sponge.API7.spongeGradleId) version Config.Libs.Sponge.API7.spongeGradleVersion // supplies sponge repo and plugin metadata creation tasks
}
apply(plugin = API7.forgeGradleId)
dependencies {
compile("org.spongepowered", "spongeapi", "7.1.0") // SpongeAPI
compile("org.bstats", "bstats-sponge", "1.4") // Sponge bstats
compileOnly(API7.api) // SpongeAPI
}
configure<UserBaseExtension> {
version = API7.minecraftVersion
runDir = "run"
mappings = API7.mappings
}
tasks.withType<Jar> {
inputs.properties += "version" to project.version
inputs.properties += "mcversion" to project.minecraft.version
baseName = "mcmmo"
filesMatching("/mcmod.info") {
expand(mapOf(
"version" to project.version,
"mcversion" to project.minecraft.version
))
}
}
description = "mcMMO for Sponge"

View File

@ -0,0 +1,3 @@
mod_name = "mcmmo"
mod_version = "2.2-SNAPSHOT"
mc_version = "1.12.2"

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.sponge.api7;
import net.minecraft.item.Item;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.GameRegistryEvent;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.plugin.Plugin;
@Plugin(id = "mcmmo", name = "mcMMO", description = "mcMMO for Sponge")
public class API7Plugin {
@SuppressWarnings("ConstantConditions")
@Listener
public void onRegister(GameRegistryEvent.Register<ItemType> event) {
Item derp = new Item(); // NMS!!!
event.register((ItemType) derp); // Since sponge mixes into Item, we can cast.
}
}

View File

@ -1,31 +1,29 @@
import Config.Libs.Sponge as Sponge
plugins {
java
}
val core: Project by rootProject.extra
val sponge: Project by rootProject.extra
val core = Projects.core!! // because it's a var and potentially null by declaration
val sponge = Projects.sponge!! // because it's a var and potentially null by declaration
description = "mcMMO for Sponge"
repositories {
// sponge
maven("https://repo.spongepowered.org/maven")
}
dependencies {
implementation(group="org.spongepowered", name="spongeapi", version="7.1.0") // Base version
compile(Sponge.bstats) // Bstats is used for all sponge versions
compileOnly(Sponge.API7.api) // Base version
}
allprojects {
dependencies {
compile(core)
compile(Projects.core!!)
}
}
subprojects {
dependencies {
(compile(sponge) as ModuleDependency).apply {
exclude("org.spongepowered")
(compileOnly(sponge) as ModuleDependency).apply {
exclude(Sponge.Exclude.group, Sponge.Exclude.module)
}
}
}