Move API to it's own source set

This commit is contained in:
Nicholas Ignoffo 2018-02-14 23:37:23 -08:00
parent c03af41c88
commit 2afc235af7
11 changed files with 32 additions and 27 deletions

View file

@ -11,7 +11,7 @@ buildscript {
plugins { plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2" id "net.minecraftforge.gradle.forge" version "2.0.2"
id 'com.matthewprenger.cursegradle' version '1.0.9' id 'com.matthewprenger.cursegradle' version '1.0.10'
id 'io.franzbecker.gradle-lombok' version '1.6' id 'io.franzbecker.gradle-lombok' version '1.6'
id 'maven-publish' id 'maven-publish'
} }
@ -69,16 +69,16 @@ processResources {
} }
} }
if (JavaVersion.current().isJava8Compatible()) { allprojects {
allprojects {
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
} }
}
} }
jar { jar {
classifier = '' classifier = ''
from sourceSets.main.output
from sourceSets.api.output
manifest.mainAttributes( manifest.mainAttributes(
"Built-By": System.getProperty('user.name'), "Built-By": System.getProperty('user.name'),
"Created-By": "${System.getProperty('java.vm.version')} + (${System.getProperty('java.vm.vendor')})", "Created-By": "${System.getProperty('java.vm.version')} + (${System.getProperty('java.vm.vendor')})",
@ -88,22 +88,28 @@ jar {
) )
} }
// API jar
task apiJar(type: Jar) { task apiJar(type: Jar) {
from sourceSets.main.allSource
from sourceSets.main.output
include 'WayofTime/bloodmagic/api/**/*'
exclude 'WayofTime/bloodmagic/api/impl/**/*'
classifier = 'api' classifier = 'api'
from sourceSets.api.output
// 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
} }
// Javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) { task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir from javadoc.destinationDir
classifier = 'javadoc' classifier = 'javadoc'
} }
tasks.build.dependsOn javadoc, javadocJar, apiJar task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
from sourceSets.api.allJava
}
tasks.build.dependsOn javadoc, javadocJar, apiJar, sourcesJar
tasks.withType(JavaCompile) { task -> tasks.withType(JavaCompile) { task ->
task.options.encoding = 'UTF-8' task.options.encoding = 'UTF-8'
@ -115,7 +121,7 @@ publishing {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
artifact jar artifact jar
artifact javadocJar artifact javadocJar
artifact sourceJar artifact sourcesJar
artifact apiJar artifact apiJar
} }
} }
@ -169,7 +175,7 @@ curseforge {
relations curseRelations relations curseRelations
addArtifact javadocJar addArtifact javadocJar
addArtifact sourceJar addArtifact sourcesJar
addArtifact apiJar addArtifact apiJar
} }
} }

View file

@ -1,7 +1,7 @@
package WayofTime.bloodmagic.api.event; package WayofTime.bloodmagic.api.event;
import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.Event;
public class BloodMagicCraftedEvent extends Event { public class BloodMagicCraftedEvent extends Event {
@ -34,16 +34,16 @@ public class BloodMagicCraftedEvent extends Event {
*/ */
public static class Altar extends BloodMagicCraftedEvent { public static class Altar extends BloodMagicCraftedEvent {
private final RecipeBloodAltar recipe; private final Ingredient input;
public Altar(RecipeBloodAltar recipe, ItemStack output) { public Altar(Ingredient input, ItemStack output) {
super(output, true); super(output, true);
this.recipe = recipe; this.input = input;
} }
public RecipeBloodAltar getRecipe() { public Ingredient getInput() {
return recipe; return input;
} }
} }
} }

View file

@ -0,0 +1,4 @@
@API(owner = "bloodmagic", provides = "bloodmagic-api", apiVersion = "2.0.0")
package WayofTime.bloodmagic.api;
import net.minecraftforge.fml.common.API;

View file

@ -314,7 +314,7 @@ public class BloodAltar implements IFluidHandler {
if (progress >= liquidRequired * stackSize) { if (progress >= liquidRequired * stackSize) {
ItemStack result = recipe.getOutput().copy(); ItemStack result = recipe.getOutput().copy();
BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe, result); BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe.getInput(), result);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
tileAltar.setInventorySlotContents(0, event.getOutput()); tileAltar.setInventorySlotContents(0, event.getOutput());
progress = 0; progress = 0;

View file

@ -1,5 +0,0 @@
@API(owner = BloodMagic.MODID, provides = BloodMagic.MODID + "|api", apiVersion = "2.0.0")
package WayofTime.bloodmagic.api;
import WayofTime.bloodmagic.BloodMagic;
import net.minecraftforge.fml.common.API;