-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
213 lines (182 loc) · 6.92 KB
/
build.gradle
File metadata and controls
213 lines (182 loc) · 6.92 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'maven-publish'
// explicit package import needed to use the SignJar task
// import net.minecraftforge.gradle.common.task.SignJar
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.k-4u.nl"
}
}
version = modVersion
group = 'tld.testmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "${modBaseName}-${minecraftVersion}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
minecraft {
version = project.forgeVersion
runDir = "run"
mappings = "${project.forgeMappings}"
replaceIn "tld/testmod/Main.java"
replace "{@VERSION}", project.version
replace "{@FORGE_VERSION}", "${project.forgeVersion}"
}
// Embed library jars in your mod jar. I'm using a combination of the two. Actually just a simple change
// See https://github.com/PaleoCrafter/Dependency-Extraction-Example/blob/library-embedding/build.gradle
// But this is the official way to handle dependencies: thought finding good information is tough
// https://forums.minecraftforge.net/topic/64554-forge-14234-minecraft-1122/
// https://mcforge.readthedocs.io/en/1.13.x/gettingstarted/dependencymanagement/#dependency-extraction
// https://forums.minecraftforge.net/topic/67027-112-how-do-i-do-mod-dependencies/
configurations {
embed
compile.extendsFrom embed
}
dependencies {
embed 'com.h2database:h2:1.4.200'
embed 'com.gitblit.iciql:iciql:2.2.0'
embed 'com.esotericsoftware:kryo:5.0.3'
// compile against the JEI API but do not include it at runtime
//compileOnly fg.deobf("mezz.jei:jei_1.12.2:4.15.0.293:api")
// at runtime, use the full JEI jar
//runtimeOnly fg.deobf("mezz.jei:jei_1.12.2:4.15.0.293")
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs.addAll(['-Xlint:unchecked', '-Xlint:deprecation'])
}
// Custom task to generate the metadata files required for our dependencies
task generateMetaFiles {
// Code for execution after the whole buildscript was parsed and loaded
doLast {
// Clear the dependencyMeta directory since we don't want old dependencies to still be listed in there
file("${buildDir}/dependencyMeta/").deleteDir()
configurations.embed.resolvedConfiguration.resolvedArtifacts.each {
// Create a meta file for each dependency in a specified directory
def metaFile = file("${buildDir}/dependencyMeta/${it.file.name}.meta")
metaFile.parentFile.mkdirs()
// Use the Gradle notation provided by the API ('group:artifact:version') for the meta file...
def artifactRef = it.moduleVersion.toString()
// ...and append the classifier if present
if (it.classifier != null) {
artifactRef += ":${it.classifier}"
}
// Write the artifact information to the meta file, to be used by the
metaFile.text = "Maven-Artifact: $artifactRef"
}
}
}
jar {
into('/META-INF/libraries') {
// Add all of the dependency JARs to the main JAR for later extraction
from configurations.embed
// Also include all dependency meta files
from "${buildDir}/dependencyMeta/"
}
manifest {
attributes([
'FMLAT': 'testmod_at.cfg',
'ContainedDeps': configurations.embed.collect { it.name }.join(' '),
"Specification-Title": "testmod",
"Specification-Vendor": "aeronica",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"aeronica",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
dependsOn generateMetaFiles
}
// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task
// and then declare that to be published
// Note you'll need to add a repository here
def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact reobfArtifact
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', version
inputs.property 'mcversion', project.minecraftVersion
// 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.minecraftVersion
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
// Exclude the GIMP image files
exclude '**/*.xcf'
// Exclude the Cubik model files
exclude '**/*.bdc3D'
// Exclude the Paint.NET image files
exclude '**/*.pdn'
eachFile {
println "Processing: $it.name"
if (it.relativePath.segments[0] in ['META-INF'])
expand project.properties
}
rename '(.+_at.cfg)', 'META-INF/$1'
}
task signJar(type: SignJar, dependsOn: jar) {
onlyIf {
project.hasProperty("keyStore")
}
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
build {
dependsOn signJar
}