forked from WorldSEnder/MCAnm
/
build.gradle
177 lines (154 loc) · 4.94 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
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'maven-publish'
apply from: 'build.properties'
project.version = getVersion()
project.ext.shortVersion = getShortVersion()
repositories {
// Put remote maven repositories here
}
// We will combine the outputs into one directory, so that it shows up as one entry on the classpath
// This is necessary to load resources with runClient
task combinedSource(type: Sync) {
from sourceSets.main.output
into "$buildDir/combined-classpath"
}
sourceSets {
main {
runtimeClasspath = files(combinedSource.outputs) + project.configurations.runtimeClasspath
}
}
minecraft {
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// Debug connection for development
jvmArgs += ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006"]
mods {
mcanm {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('runServer')
// Recommended logging data for a userdev environment
// property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// Debug connection for development
// jvmArgs += ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006"]
mods {
mcanm {
source sourceSets.main
}
}
}
}
}
jar {
manifest {
attributes([
"Specification-Title": project.archivesBaseName,
"Specification-Vendor": "WorldSEnder",
"Specification-Version": project.shortVersion,
"Implementation-Title": project.name,
"Implementation-Version": project.shortVersion,
"Implementation-Vendor" :"WorldSEnder",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
expand project.properties
}
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
}
}
task processSource(type: Sync) {
from(sourceSets.main.java) {
include 'com/github/worldsender/mcanm/Reference.java'
expand project.properties
}
from(sourceSets.main.java) {
exclude 'com/github/worldsender/mcanm/Reference.java'
}
into "$buildDir/processed-src"
}
compileJava {
source = processSource.outputs
}
jar.finalizedBy('reobfJar')
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from jar.source
}
build.dependsOn sourceJar
artifacts {
archives jar
archives sourceJar
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourceJar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
def getShortVersion() {
def stdout = new ByteArrayOutputStream()
exec {
executable "git"
args "rev-list", "--count", "HEAD"
standardOutput = stdout
}
def revision = stdout.toString().trim() as Integer
return "${major}.${minor}.${patch}.${revision}"
}
def getVersion() {
return "${getShortVersion()}${getArtifactID()}+${project.mcversion}"
}
def getArtifactID() {
def stdout = new ByteArrayOutputStream()
exec {
executable "git"
args "rev-parse", "--abbrev-ref", "HEAD"
standardOutput = stdout
}
def branch = stdout.toString().trim()
def branchArtifact = branch != "HEAD" ? null : {
stdout.reset()
exec {
executable "git"
args "rev-parse", "--short", "HEAD"
standardOutput = stdout
}
stdout.toString().trim().replace('/', '.')
}()
def isClean = exec({ executable "git"; args "diff", "--quiet"; ignoreExitValue = true }).exitValue == 0
def dirtyArtifact = isClean ? null : "SNAPSHOT"
def artifact = [branchArtifact, dirtyArtifact].findAll().join('.')
return "${artifact == '' ? '' : '-' + artifact}"
}