-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild.gradle
145 lines (128 loc) · 5.03 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
import org.apache.commons.io.output.ByteArrayOutputStream
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
repositories {
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven/"
}
ivy {
name "CoFHCore"
artifactPattern 'http://addons-origin.cursecdn.com/files/2234/199/[module]-[revision].[ext]'
}
}
apply plugin: 'forge'
ext.mc_version = "1.7.10"
ext.mod_version = "1.1.5R"
ext.build_number = System.getenv("BUILD_NUMBER")
if (!ext.build_number) {
ext.build_number = System.getenv("TRAVIS_BUILD_NUMBER")
}
if (ext.build_number) {
// add the build # of the last jenkins build for consistency
version = ext.mc_version + "-" + ext.mod_version + "-" + (349 + System.getenv("TRAVIS_BUILD_NUMBER").toInteger())
} else {
version = ext.mc_version + "-" + ext.mod_version + "-" + "DEV"
}
group = "com.shukaro.artifice"
archivesBaseName = "Artifice"
project.ext.set('fullVersion', version)
if(ext.mod_version.endsWith("A")) {
project.ext.set('curseType', 'alpha')
} else if(ext.mod_version.endsWith("B")) {
project.ext.set('curseType', 'beta')
} else {
project.ext.set('curseType', 'release')
}
project.ext.set('curseProjectID', '223174')
project.ext.set('modsioProjectID', '1139')
minecraft {
// forge version
version = "1.7.10-10.13.2.1291"
runDir = "minecraft"
}
dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.127:dev"
compile 'codechicken:CodeChickenCore:1.7.10-1.0.4.35:dev'
compile group: 'cofh', name: 'CoFHCore', version: '[1.7.10]3.0.2-262-dev', ext: 'jar'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// 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.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
def getGitChangelog = { ->
try {
def stdout = new ByteArrayOutputStream()
def gitHash = System.getenv("GIT_COMMIT")
def gitPrevHash = System.getenv("GIT_PREVIOUS_COMMIT")
def travisRange = System.getenv("TRAVIS_COMMIT_RANGE")
if(gitHash && gitPrevHash) {
exec {
commandLine 'git', 'log', '--pretty=tformat:%s - %aN', '' + gitPrevHash + '...' + gitHash
standardOutput = stdout
}
return stdout.toString().trim()
} else if(travisRange) {
exec {
commandLine 'git', 'log', '--pretty=tformat:%s - %aN', '' + travisRange
standardOutput = stdout
}
return stdout.toString().trim()
} else {
return "";
}
} catch(ignored) {
return "";
}
}
task publish(dependsOn: ['build','curseUpload', 'modsioUpload'])
task curseUpload(type: Exec) {
executable 'curl'
// 4449 = 1.7.10
args = ['-F', 'metadata={\"releaseType\":\"' + project.curseType + '\",\"changelog\":\"' + getGitChangelog() + '\",\"gameVersions\":[4449]}',
'-F', 'file=@./build/libs/' + archivesBaseName + '-' + project.fullVersion + '.jar',
'-H', 'X-API-Token: ' + System.getenv('CURSE_API_KEY'),
'https://minecraft.curseforge.com/api/projects/' + project.curseProjectID + '/upload-file']
}
task modsioUpload(type: Exec) {
executable 'curl'
args = ['-F', 'body={\"version\":{\"name\":\"' + project.fullVersion + '\",\"minecraft\":\"' + project.minecraft.version + '\",\"changelog\":\"' + getGitChangelog() + '\"},\"filename\":\"' + 'Artifice-' + project.fullVersion + '.jar' + '\"}',
'-F', 'file=@./build/libs/' + archivesBaseName + '-' + project.fullVersion + '.jar',
'-H', 'X-API-Key: ' + System.getenv('MODSIO_API_KEY'),
'https://mods.io/mods/' + project.modsioProjectID + '/versions/create.json']
}