-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
177 lines (142 loc) · 4.39 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
import org.jetbrains.gradle.ext.Gradle
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.35'
}
ext.configFile = file('gradle.properties')
ext.config = parseConfig(configFile)
version = "${config.version}"
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
group = "vazkii.patchouli"
archivesBaseName = config.mod_name
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
sourceCompatibility = targetCompatibility = 8
}
repositories {
maven {
url "https://www.cursemaven.com"
}
}
dependencies {
compileOnly 'curse.maven:bnbgamingcore-274341:2991671'
}
minecraft {
mcVersion = "1.12.2"
injectedTags.put('MOD_VERSION', project.version)
extraRunJvmArguments.addAll("-Xms512m", "-Xmx2048m")
}
tasks.injectTags.configure {
outputClassName.set("${project.group}.common.base.Tags")
}
jar {
exclude "**/*.bat"
exclude "**/*.psd"
exclude "**/*.exe"
exclude "**/unused"
// exclude test assets
exclude "**/assets/patchouli/patchouli_books/**"
exclude "**/assets/patchouli/advancements/**"
manifest {
attributes(['FMLAT': 'patchouli_at.cfg'])
}
}
for (File at : sourceSets.getByName("main").resources.files) {
if (at.name.toLowerCase().endsWith("_at.cfg")) {
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
}
}
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
// Replace version and mcversion
fcd.expand (
'version': project.version,
'mcversion': project.minecraft.mcVersion
)
}
rename '(.+_at.cfg)', 'META-INF/$1'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.register("deobfJar", Jar) {
from(sourceSets.main.output)
archiveClassifier = "deobf"
}
tasks.jar {
from(sourceSets.main.output)
manifest {
def attributes = [:]
attributes["FMLAT"] = "patchouli_at.cfg"
}
}
artifacts {
archives deobfJar
}
/*publishing { I can't use Maven tasks well i will learn how to use them later pfft
publications {
mavenJava (MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
artifacts {
deobfJar {
cl
classifier 'deobf'
}
}
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}*/
/**
* Increments the buildnumber in your config file, and saves it
* Note: The doFirst is important, without it the build number
* will be incremented every time tasks are configured, i.e every
* time gradle is run on this project.
*/
/*task incrementBuildNumber {doFirst{
config.build_number = (config.build_number.toString().toInteger()) + 1
configFile.withWriter {
config.toProperties().store(it, "")
}
}} this is just weird to me. Why? */
import java.util.regex.*
tasks.register('sortArtifacts', Copy) { copy ->
from jar.destinationDirectory
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("$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)
}
}
}
static def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}
defaultTasks 'clean', 'build', 'sortArtifacts', 'incrementBuildNumber'