Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Create a separate moddev jar
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed May 30, 2019
1 parent 6206ab3 commit ac314f0
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
73 changes: 70 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
plugins {
id 'fabric-loom' version '0.2.2-SNAPSHOT'
buildscript {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.3-SNAPSHOT"
}
}

apply plugin: net.fabricmc.loom.LoomGradlePlugin

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

Expand Down Expand Up @@ -40,9 +51,65 @@ dependencies {
compile ('net.fabricmc:stitch:0.1.2.49+') {
transitive = false
}
include ('net.fabricmc:stitch:0.1.2.49+')
include 'net.fabricmc:stitch:0.1.2.49+'
}

import groovy.json.JsonOutput
import groovy.json.JsonSlurper

task unzip(type: Copy) {
def zipFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
def outputDir = file("${buildDir}/unpacked/dist")

if(outputDir.exists()){
outputDir.deleteDir()
}

from zipTree(zipFile)
into outputDir
}

task modevJar (type: Jar, dependsOn: unzip) {
classifier = 'moddev'

def tempFile = file("${buildDir}/temp/fabric.mod.json")
tempFile.mkdirs()
tempFile.delete()

def json = new JsonSlurper().parseText(file("src/main/resources/fabric.mod.json").text)
json.jars = configurations.include.resolve().stream().map{f -> new FileHolder("META-INF/jars/" + f.getName())}.toArray()
tempFile.write JsonOutput.toJson(json)
from tempFile

from (sourceSets.main.output) {
exclude "fabric.mod.json"
exclude '*.jar'
}
}

afterEvaluate { project ->
projects.logger.lifecycle("hi")
project.configurations.include.resolve().stream().forEach{f ->
def file = file("${buildDir}/unpacked/dist/META-INF/jars/${f.getName()}")
projects.logger.lifecycle(file.getName() + ":" + f.getName())
modevJar.from (file) {
into ("META-INF/jars")
}
}
}


class FileHolder {
String file

FileHolder(String file) {
this.file = file
}
}

modevJar.dependsOn remapJar
build.dependsOn modevJar

processResources {
inputs.property "version", project.version

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ minecraft_version=1.14.2
yarn_mappings=1.14.2+build.2
loader_version=0.4.8+build.154

mod_version = 0.2.0
mod_version = 0.2.1
maven_group = me.modmuss50
archives_base_name = optifabric
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit ac314f0

Please sign in to comment.