Skip to content

Commit 5f4dafc

Browse files
committed
Switch to gradle.properties
1 parent eeb0631 commit 5f4dafc

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
lines changed

build.gradle

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ apply plugin: 'idea'
3434
apply plugin: 'jacoco'
3535
apply plugin: 'com.github.kt3k.coveralls'
3636

37-
ext.config = parseConfig("build.properties")
38-
39-
version = config.nova.version
40-
group = "nova.core"
4137

4238
/*checkstyle {
4339
configFile = file('checkstyle.xml')
@@ -134,7 +130,7 @@ publishing {
134130
artifact sourceJar
135131
artifact wrapperTestJar
136132

137-
pom.withXml(writePom())
133+
pom.withXml(writePom(project.properties))
138134
}
139135
}
140136
repositories {

build.properties gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
nova.version=0.1.0-SNAPSHOT
1+
version=0.1.0-SNAPSHOT
2+
group = nova.core
23

34
packaging = jar
45
info.inceptionYear = 2015

gradle/modules/utils.gradle

+8-34
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,16 @@
1-
def getGitRef() {
2-
try {
3-
def stdout = new ByteArrayOutputStream()
4-
exec {
5-
commandLine 'git', 'rev-parse', '--short', 'HEAD'
6-
standardOutput = stdout
7-
}
8-
return stdout.toString().trim()
9-
} catch (Throwable e) {
10-
return "unknown"
11-
}
12-
}
13-
14-
def parseConfig(String configFile) {
15-
file(configFile).withReader {
16-
def prop = new Properties()
17-
prop.load(it)
18-
return new ConfigSlurper().parse(prop)
19-
}
20-
}
21-
22-
def writePom() {
23-
return new Action<XmlProvider>() {
24-
@Override
25-
void execute(XmlProvider xmlProvider) {
26-
def node = xmlProvider.asNode()
1+
def writePom(config) {
2+
return { xmlProvider ->
3+
def node = xmlProvider.asNode()
274

28-
node.appendNode("description", config.info.description)
29-
node.appendNode("inceptionYear", config.info.inceptionYear)
30-
node.appendNode("packaging", config.packaging)
31-
new Node(node, "organization")
32-
.appendNode("name", config.info.organization.name)
33-
}
5+
node.appendNode("description", config["info.description"])
6+
node.appendNode("inceptionYear", config["info.inceptionYear"])
7+
node.appendNode("packaging", config["packaging"])
8+
node.appendNode("organisation")
9+
.appendNode("name", config["info.organization.name"])
3410
}
3511
}
3612

3713
// Fucking gradle
3814
ext {
39-
getGitRef = this.&getGitRef
40-
parseConfig = this.&parseConfig
4115
writePom = this.&writePom
4216
}

0 commit comments

Comments
 (0)