-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
97 lines (81 loc) · 2.16 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
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
repositories {
mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
apply from: 'build.properties'
minecraft {
runDir = "eclipse/"
}
project.version = getVersion()
project.ext.shortVersion = getShortVersion()
minecraft {
replaceIn "Reference.java"
replace "@VERSION@", project.shortVersion
replace "@modid@", project.archivesBaseName
replace "@MODNAME@", project.longname
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}
tasks["sourceJar"].classifier = 'sources'
tasks.build.dependsOn('deobfJar', 'sourceJar')
install.dependsOn build
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand project.properties
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
repositories {
mavenLocal()
}
artifacts {
archives jar
archives deobfJar
archives sourceJar
}
def getShortVersion() {
def stdout = new ByteArrayOutputStream()
exec {
executable "git"
args "rev-list", "--count", "HEAD"
standardOutput = stdout
}
def revision = stdout.toString().trim()
return "${major}.${minor}.${patch}.${revision}"
}
def getVersion() {
return getShortVersion() + getArtifactID() + "+${minecraft.version}"
}
def getArtifactID() {
def stdout = new ByteArrayOutputStream()
exec {
executable "git"
args "rev-parse", "--abbrev-ref", "HEAD"
standardOutput = stdout
}
def branch = stdout.toString().trim()
if(branch == "HEAD") {
stdout.reset()
exec {
executable "git"
args "rev-parse", "--short", "HEAD"
standardOutput = stdout
}
branch = stdout.toString().trim()
}
return "${branch == 'master' ? '' : '-' + branch.replace('/', '.')}"
}