forked from cpw/ironchest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·159 lines (139 loc) · 5.49 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
// This sets us up for building a forge project - you need all of these
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
// This is a simple flatdir repository for "uploadArchives" when you don't have a remote repo to target
repositories {
flatDir {
name "fileRepo"
dirs "repo"
}
}
// IronChest uses git tagging to mark major versions. This sets up the project version to that version data
def versionInfo = getGitVersion()
version = "${versionInfo['IronChest.version']}"
// This is our group. I'm cpw.mods
group= "cpw.mods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
// This is our actual project within the group. Note: FML has "fml" here. But this is ironchest.
archivesBaseName = "ironchest"
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
minecraft {
version = "1.8.9-11.15.0.1689"
mappings = "stable_20"
runDir = "run"
}
// This wrangles the resources for the jar files- stuff like textures and languages
processResources
{
// we're omitting the .xcf files - they're development only
exclude '**/*.xcf'
// we only want to do search/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'
}
// generate version.properties file from the git version data earlier
doLast {
def propsFile = new File(destinationDir, 'version.properties')
def properties = new Properties()
properties.putAll(versionInfo)
properties['IronChest.build.mcversion'] = project.minecraft.version
properties.store(propsFile.newWriter(), null)
}
}
// Configure an upload task. this is setup for uploading to files.minecraftforge.net. There are other examples around
uploadArchives {
repositories.mavenDeployer {
dependsOn 'build'
if (project.hasProperty('forgeMavenPassword'))
{
repository(url: "http://files.minecraftforge.net/maven/manage/upload") {
authentication(userName: project.getProperty('forgeMavenUser'), password: project.getProperty('forgeMavenPassword')) // the elvis operator. look it up.
}
}
else
{
// local repo folder. Might wanna juset use gradle install if you wanans end it to maven-local
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
}
// This is just the pom data for the maven repo
pom {
groupId = project.group
// Force the maven upload to use the <mcversion>-<version> syntax preferred at files
version = "${project.minecraft.version}-${project.version}"
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'IronChest'
url 'https://github.com/progwml6/IronChest'
scm {
url 'https://github.com/progwml6/IronChest'
connection 'scm:git:git://github.com/progwml6/IronChest.git'
developerConnection 'scm:git:[email protected]:progwml6/IronChest.git'
}
issueManagement {
system 'github'
url 'https://github.com/progwml6/IronChest/issues'
}
licenses {
license {
name 'GNU Public License (GPL), Version 3.0'
url 'http://www.gnu.org/licenses/gpl-3.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'cpw'
name 'cpw'
roles { role 'developer' }
}
}
}
}
}
}
// This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER)
def getGitVersion()
{
def out = [:]
// call git command.
def outStream = new ByteArrayOutputStream()
def result = exec {
executable = 'git'
args = [ 'describe', '--long', "--match=[^(jenkins)]*"]
standardOutput = outStream
}
def fullVersion = outStream.toString().trim()
def matcher = fullVersion =~ /(\d+).(\d+)-(\d+)-(.*)/
def maj = matcher[0][1]
def min = matcher[0][2]
def rev = matcher[0][3]
def bn = System.getenv("PROMOTED_NUMBER") ?: System.getenv("BUILD_NUMBER") ?: "1"
out['IronChest.build.major.number'] = maj.toString()
out['IronChest.build.minor.number'] = min.toString()
out['IronChest.build.revision.number'] = rev.toString()
out['IronChest.build.githash'] = matcher[0][4].toString()
out['IronChest.build.number' ] = bn.toString()
out['IronChest.version' ] = "${maj}.${min}.${rev}.${bn}".toString()
return out
}