-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
executable file
·199 lines (169 loc) · 5.19 KB
/
build.gradle
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "nallar"
url = "http://repo.nallar.me/"
}
}
configurations.all { resolutionStrategy.cacheChangingModulesFor 30, 'seconds' }
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath group: 'me.nallar', name: 'ModPatcherGradle', version: '0.1-SNAPSHOT', changing: true
}
}
apply plugin: 'me.nallar.ModPatcherGradle'
apply plugin: 'maven'
group = 'me.nallar'
archivesBaseName = 'modpatcher'
// Extended project information
ext.projectName = 'ModPatcher'
ext.inceptionYear = '2014'
ext.packaging = 'jar'
ext.url = 'http://nallar.me/minecraft'
ext.description = 'Mod Patcher'
ext.organization = 'nallar.me'
ext.mcVersion = '1.8.9'
ext.forgeVersion = "11.15.1.1734"
ext.mappings_channel = "stable"
ext.mappings_version = "20"
ext.mappings = mappings_channel + '_' + mappings_version
ext.fullForgeVersion = mcVersion + "-" + forgeVersion
// ci information
ext.buildNumber = System.getenv("BUILD_NUMBER") ?: 0
ext.ciSystem = System.getenv("JENKINS_URL") ? 'Jenkins' : 'unknown'
ext.commit = System.getenv("GIT_COMMIT") ?: 'unknown'
// version information
version = mcVersion + '-SNAPSHOT'
ext.versionWithBuildNumber = project.buildNumber != 0 ? project.version.replace("-SNAPSHOT", "") + "." + project.buildNumber : project.version
ext.versionPath = "./build/version.txt"
def versionFile = file(versionPath);
versionFile.getParentFile().mkdir()
minecraft {
version = fullForgeVersion
mappings = project.mappings
replace "@MOD_NAME@", project.name
replace "@MOD_VERSION@", project.versionWithBuildNumber
replace "@MC_VERSION@", version
}
modpatcher {
extractGeneratedSources = true
generateInheritanceHierarchy = true
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
maven { url 'https://repo.nallar.me/' }
}
configurations {
all { resolutionStrategy.cacheChangingModulesFor 30, 'seconds' }
provided
compile.extendsFrom provided
}
dependencies {
testCompile 'junit:junit:4.12'
compile group: 'me.nallar', name: 'JavaPatcher', version: '1.3', changing: false
compile group: 'me.nallar', name: 'Mixin', version: '1.0-SNAPSHOT', changing: true
compile 'org.javassist:javassist:3.20.0-GA'
}
if (System.env.GRADLE_USER_HOME) {
ext.homeDir = System.env.GRADLE_USER_HOME + '/'
} else {
ext.homeDir = System.properties['user.home'] + '/.gradle/'
}
ext.mappingsPath = homeDir + 'caches/minecraft/de/oceanlabs/mcp/mcp_' + mappings_channel + '/' + mappings_version + '/'
ext.srgPath = mappingsPath + 'srgs/notch-srg.srg'
jar.doFirst {
if (
!file(mappingsPath + 'fields.csv').exists() ||
!file(mappingsPath + 'methods.csv').exists() ||
!file('./generated/extendsMap.obj').exists() ||
!file(srgPath).exists()
)
throw new Error("Can't find mappings at $mappingsPath and/or $srgPath and/or extendsMap")
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from((configurations.runtime - configurations.provided).filter { it.exists() }.collect {
it.isDirectory() ? it : zipTree(it)
}) {
exclude "META-INF/**"
}
from srgPath
from mappingsPath + 'methods.csv'
from mappingsPath + 'fields.csv'
from './generated/extendsMap.obj'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.versionWithBuildNumber
inputs.property "mcversion", project.minecraft.version
println("Determined ModPatcher version: " + project.versionWithBuildNumber)
versionFile.text = project.versionWithBuildNumber
filesMatching("mcmod.info") {
expand 'version': project.versionWithBuildNumber, 'mcversion': project.minecraft.version, 'name': project.projectName
}
filesMatching("modpatcher.version") {
expand 'version': project.versionWithBuildNumber
}
}
tasks.withType(JavaCompile) {
sourceCompatibility = 8
targetCompatibility = 8
options.with {
encoding = 'UTF-8'
compilerArgs << "-Xlint:all" << "-Xlint:-classfile"
}
}
jar {
classifier = 'lib'
}
def apiJarConfig = {
classifier = 'api'
from {
sourceSets.main.allSource
sourceSets.main.output
}
include 'me/nallar/modpatcher/ModPatcher.*'
include 'me/nallar/modpatcher/ModPatcher$Version.*'
include 'me/nallar/modpatcher/ModPatcherSetup.*'
}
task apiJar(type: Jar, dependsOn: classes)
apiJar apiJarConfig
task coremodJar(type: Jar, dependsOn: classes)
coremodJar apiJarConfig
coremodJar {
classifier = 'coremod'
include 'me/nallar/modpatcher/coremod/*'
include 'mcmod.info'
include '*.example'
}
artifacts {
archives apiJar
archives coremodJar
archives jar
archives file(versionPath)
}
def installer = install.repositories.mavenInstaller
[installer]*.pom*.whenConfigured {
p ->
p.dependencies = p.dependencies.findAll {
dep -> dep.artifactId == "junit"
}
}
tasks.withType(Jar) {
baseName = project.name
manifest.mainAttributes(
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Title": name,
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Implementation-Vendor": url,
"FMLCorePlugin": "me.nallar.modpatcher.coremod.CoreMod"
)
}