@@ -35,6 +35,7 @@ repositories {
35
35
}
36
36
37
37
apply plugin : ' forge'
38
+ apply plugin : ' idea'
38
39
39
40
// These settings allow you to choose what version of Java you want to be compatible with. Forge 1.7.10 runs on Java 6 to 8.
40
41
sourceCompatibility = 1.8
@@ -47,25 +48,10 @@ minecraft {
47
48
version = project. minecraft_version + " -" + project. forge_version
48
49
runDir = " run"
49
50
}
50
-
51
- dependencies {
52
- // you may put jars on which you depend on in ./libs
53
- // or you may define them like so..
54
- // compile "some.group:artifact:version:classifier"
55
- // compile "some.group:artifact:version"
56
-
57
- // real examples
58
- // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
59
- // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
60
-
61
- // for more info...
62
- // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
63
- // http://www.gradle.org/docs/current/userguide/dependency_management.html
64
-
65
- implementation " codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev"
66
- implementation " codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev"
51
+ configurations {
52
+ embed
53
+ compile. extendsFrom(embed)
67
54
}
68
-
69
55
processResources {
70
56
// This will ensure that this task is redone when the versions change.
71
57
inputs. property " version" , project. version
@@ -95,31 +81,111 @@ task devJar(type: Jar) {
95
81
from sourceSets. main. output
96
82
}
97
83
98
- // Creates the listed artifacts on building the mod.
99
- artifacts {
100
- archives sourcesJar
101
- archives devJar
84
+
85
+ // ##########################################################################################################
86
+ // ######################################## Mixin Part ################################################
87
+ // ##########################################################################################################
88
+ // Add
89
+ // --tweakClass org.spongepowered.asm.launch.MixinTweaker --mixin mixins.examplemod.json
90
+ // to your client and server program arguments if working in a dev environment.
91
+ def yourMixinConfig = " mixins.${ modId} .json"
92
+ def refMapForYourConfig = " mixins.${ modId} .refmap.json"
93
+ def relativePathToMixinAP = ' libs/mixin-0.8-SNAPSHOT.jar'
94
+
95
+ def embedMixin = false
96
+
97
+ if (! embedMixin) {
98
+ version + = " -mixinless"
99
+ }
100
+
101
+ repositories {
102
+ maven {
103
+ name = " sponge"
104
+ url = " https://repo.spongepowered.org/maven/"
105
+ }
102
106
}
103
107
104
- // This block configures any maven publications you want to make.
105
- publishing {
106
- publications {
107
- mavenJava(MavenPublication ) {
108
- // Add any other artifacts here that you would like to publish!
109
- artifact(jar) {
110
- builtBy build
111
- }
112
- artifact(sourcesJar) {
113
- builtBy sourcesJar
114
- }
115
- artifact(devJar) {
116
- builtBy devJar
117
- }
108
+ dependencies {
109
+
110
+ implementation " codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev"
111
+ implementation " codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev"
112
+
113
+ if (embedMixin) {
114
+ embed(' org.spongepowered:mixin:0.7.11-SNAPSHOT' ) {
115
+ // Mixin includes a lot of dependencies that are too up-to-date
116
+ exclude module : ' launchwrapper'
117
+ exclude module : ' guava'
118
+ exclude module : ' gson'
119
+ exclude module : ' commons-io'
120
+ exclude module : ' log4j-core'
121
+ }
122
+ } else {
123
+ compile(' org.spongepowered:mixin:0.7.11-SNAPSHOT' ) {
124
+ // Mixin includes a lot of dependencies that are too up-to-date
125
+ exclude module : ' launchwrapper'
126
+ exclude module : ' guava'
127
+ exclude module : ' gson'
128
+ exclude module : ' commons-io'
129
+ exclude module : ' log4j-core'
118
130
}
119
131
}
132
+ }
133
+
134
+ def refMap = " ${ tasks.compileJava.temporaryDir} " + File . separator + refMapForYourConfig
135
+
136
+ def mixinSrg = " ${ tasks.reobf.temporaryDir} " + File . separator + " mixins.srg"
137
+
138
+ jar {
139
+ from refMap
140
+ manifest {
141
+ attributes. put(" TweakClass" , " org.spongepowered.asm.launch.MixinTweaker" )
142
+ attributes. put(" FMLCorePluginContainsFMLMod" , true )
143
+ attributes. put(" ForceLoadAsMod" , true )
144
+ attributes. put(" MixinConfigs" , yourMixinConfig)
145
+ }
146
+
147
+ // embed libraries in jar
148
+ from configurations. embed. collect {
149
+ exclude ' **/LICENSE.txt'
150
+ it. isDirectory() ? it : zipTree(it)
151
+ }
152
+ }
153
+
154
+ reobf {
155
+ addExtraSrgFile mixinSrg
156
+ }
157
+
158
+ afterEvaluate {
159
+ def fixedRelPathToAP = relativePathToMixinAP
160
+ if (fixedRelPathToAP. startsWith(' ./' ) || fixedRelPathToAP. startsWith(' .\\ ' )) {
161
+ fixedRelPathToAP = fixedRelPathToAP. substring(2 )
162
+ } else if (fixedRelPathToAP. startsWith(' /' ) || fixedRelPathToAP. startsWith(' \\ ' )) {
163
+ fixedRelPathToAP = fixedRelPathToAP. substring(1 )
164
+ }
165
+
166
+ tasks. compileJava {
167
+ println " Path: " + projectDir. absolutePath
168
+ options. compilerArgs + = [
169
+ // There's a bug in the AnnotationProcessor for 0.7.11 that will generate the annotations pointing to the parent class instead of subclass
170
+ // resulting in the mixin not being applied. This is fixed in 0.8, however 0.8 needs guava > 21.0, and minecraft ships with 17.0.
171
+ // So as a hacky workaround... ship with 0.7.11, but use the AP from 0.8 for compiling
172
+
173
+ " -processor" , " org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection,org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets" ,
174
+ " -Xlint:-sunapi" , " -XDenableSunApiLintControl" , " -XDignore.symbol.file" ,
175
+ " -AreobfSrgFile=${ tasks.reobf.srg} " , " -AoutSrgFile=${ mixinSrg} " , " -AoutRefMapFile=${ refMap} "
176
+ ]
177
+ options. annotationProcessorPath = files(projectDir. absolutePath + ' /' + fixedRelPathToAP)
178
+ }
179
+ tasks. runClient{
120
180
121
- // This block selects the repositories you want to publish to.
122
- repositories {
123
- // Add the repositories you want to publish to here.
124
181
}
125
182
}
183
+
184
+ sourceSets {
185
+ main {
186
+ java {
187
+ outputDir = file(" $buildDir /classes/java/main" )
188
+ }
189
+ ext. refMap = refMapForYourConfig
190
+ }
191
+ }
0 commit comments