aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: 5a3a3bf47bd8a1d3651c4bad1c42a035774b3a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
buildscript {
    repositories {
        mavenCentral()
		jcenter()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
        // MixinGradle only works with ForgeGradle 2+, so we need to implement it ourselves.
        // (Comments mark the lines where this is done.)
        //classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
    }
}

repositories {
    maven { // this has to be here and not in buildscript.repositories, otherwise Gradle won't find mixin <0.8 for some reason
        name = 'sponge'
        url = 'https://repo.spongepowered.org/maven/'
    }
}

configurations {
    embed
    compile.extendsFrom(embed)
}

apply plugin: 'forge'

version = "0.0"
group= "makamys.lodmod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "lodmod"

minecraft {
    version = "1.7.10-10.13.4.1614-1.7.10"
    runDir = "run"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    embed 'org.spongepowered:mixin:0.7+'
    
    /* Mixin 0.8 breaks with 1.7.10, but can be made to work by embedding these. However,
	   doing so overrides the libraries provided by Forge, which will likely result in other mods breaking. */ 
    //embed 'org.ow2.asm:asm-all:5.2'
    //embed 'com.google.guava:guava:21.0'
}

def outRefMapFile = tasks.compileJava.temporaryDir.toString() + "/lodmod.mixin.refmap.json" // 1.7.10 mixin compatibility

jar {
    manifest {
        attributes (
            'MixinConfigs': 'lodmod.mixin.json',
            'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
            'TweakOrder': 0,
            
            // If these two are not set, Forge will not detect the mod, it will only run the mixins
            'FMLCorePluginContainsFMLMod': 'true',
            'ForceLoadAsMod': 'true',
            'FMLAT': "LODMod_at.cfg"
        )
    }

    from(sourceSets.main.output);
    
    from outRefMapFile; // 1.7.10 mixin compatibility

    // embed libraries in jar
    from configurations.embed.collect {
        exclude '**/LICENSE.txt'
        it.isDirectory() ? it : zipTree(it)
    }
}

// 1.7.10 mixin compatibility
def outSrgFile = tasks.compileJava.temporaryDir.toString() + "/outSrg.srg"

afterEvaluate {
    tasks.compileJava.options.compilerArgs += ["-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${outSrgFile}", "-AoutRefMapFile=${outRefMapFile}"];
}

reobf {
    addExtraSrgFile outSrgFile
}
// end of mixin stuff

processResources
{
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
                
        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
        
    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}