-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
196 lines (168 loc) · 5.66 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
buildscript {
repositories {
maven { url 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
ext.configFile = file('build.properties')
ext.config = parseConfig(configFile)
def mc_version = '1.14.4'
version = "${mc_version}-${config.version}-${config.build_number}"
group = "com.dwightaspencer.${config.mod_id}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "${config.mod_name}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
minecraft {
mappings channel: "snapshot", version: "20200123-mixed-1.15.2"
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'fml.earlyprogresswindow', 'false'
mods {
patchouli {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'fml.earlyprogresswindow', 'false'
mods {
patchouli {
source sourceSets.main
}
}
}
}
}
repositories {
maven {
url "https://dvs1.progwml6.com/files/maven/"
}
maven {
name "yarn2mcp"
url "https://maven.tterrag.com/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-31.0.14"
compile "epicsquid.mysticallib:mysticallib:1.16.1"
compile project(':MysticalLib')
compile project(':MysticalWorld')
compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
deobfCompile "com.azanor:Baubles:${version_baubles}"
compileOnly fg.deobf("mezz.jei:jei-${mc_version}:6.0.0.2:api")
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:6.0.0.2")
}
processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
// replace version and mcversion
expand 'version': project.version
}
// copy everything else, thats not the mods.toml
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml', '**/psd/**'
}
}
task incrementBuildNumber {
doFirst {
config.build_number = (config.build_number.toString().toInteger()) + 1
configFile.withWriter {
config.toProperties().store(it, "")
}
}
}
import java.util.regex.Pattern
task sortArtifacts(type: Copy) {
from jar.destinationDir
into config.dir_output
//Put each jar with a classifier in a subfolder with the classifier as its name
eachFile {
//This matcher is used to get the classifier of the jar
def matcher = Pattern.compile(Pattern.quote("$config.mod_name-$version") + "-(?<classifier>\\w+).jar").matcher(it.name)
//Only change the destination for full matches, i.e jars with classifiers
if (matcher.matches())
{
def classifier = matcher.group('classifier')
/* Set the relative path to change the destination, since
* Gradle doesn't seem to like the absolute path being set*/
it.relativePath = it.relativePath.parent.append(false, classifier, it.name)
}
}
}
def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}
jar {
manifest {
attributes([
"Specification-Title": "${config.mod_id}",
"Specification-Vendor": "denzuko",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": "${config.mod_id}",
"Implementation-Version": "${version}",
"Implementation-Vendor" :"denzuko",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
// exclude test data
exclude "**/data/amorfati/patchouli_books/**"
exclude "**/data/amorfati/advancements/**"
}
task srcJar (type: Jar) {
from sourceSets.main.java
classifier = 'sources'
}
task apiJar(type: Jar) {
// Sources included because of MinecraftForge/ForgeGradle#369
from(sourceSets.main.allJava)
from(sourceSets.main.output)
include 'com/dwightaspencer/amorfati/api/**'
classifier = 'api'
}
artifacts {
archives srcJar, apiJar
}
publishing {
tasks.publish.dependsOn build
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
artifact srcJar
artifact apiJar
pom.withXml {
def node = asNode()
if(node.dependencies.size() > 0)
node.remove(node.dependencies) // Remove deps, as they are all mappings-dependent and/or forge
}
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}
defaultTasks 'clean', 'build', 'sortArtifacts', 'incrementBuildNumber'