-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
161 lines (144 loc) · 5.02 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
plugins {
id 'com.gradle.build-scan' version '1.0'
id "groovy"
id "application"
id 'maven'
id "com.jfrog.bintray" version "1.7.1"
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
repositories {
jcenter()
}
dependencies {
compile "org.codehaus.groovy:groovy-all:$groovyVersion"
testCompile "org.spockframework:spock-core:${getSpockClassifier(groovyVersion)}", {
exclude module: "groovy-all", group: "org.codehaus.groovy"
}
}
project.group = 'org.groocss'
applicationName = "groocss"
mainClassName= 'org.groocss.Main'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
test {
def projectDir = "$project.projectDir"
inputs.files("$projectDir/index.css", "$projectDir/black.png")
}
tasks.withType(GroovyCompile) {
groovyOptions.optimizationOptions.indy = true
}
task zipDocs(type: Jar) {
dependsOn 'groovydoc'
archiveName "$applicationName-${version}-javadocs.jar"
from "$buildDir/docs/groovydoc/"
}
task zipSrc(type: Jar) {
archiveName "$applicationName-${version}-sources.jar"
from "src/main/groovy/"
}
task jars {
dependsOn 'zipDocs', 'zipSrc', 'jar'
}
tasks['jar'].archiveName = "${applicationName}-${project.version}.jar"
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
pkg {
repo = 'maven'
name = 'GrooCSS'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/adamldavis/groocss.git'
version {
name = project.version
released = new Date()
}
filesSpec {
from "$project.buildDir/libs", {
include '*.jar'
}
from "$project.buildDir/", {
include '*.pom'
}
into "org/groocss/groocss/$project.version"
}
}
}
task prepareRelease(dependsOn: clean, description: 'Cleans build and removes -SNAPSHOT') doLast {
def props = file('gradle.properties')
def text = props.text
props.text = text.replace('-SNAPSHOT','')
}
task buildRelease(dependsOn: ['clean', 'test', 'jars', 'pom'], description: 'Tests and builds artifacts',
group: 'build') {}
task release(dependsOn: [buildRelease, bintrayUpload],
description: 'Builds then Uploads artifacts to bintray maven repo (jcenter)', group: 'publishing') doLast {
println "Uploaded $project.version to bintray"
}
task inc(description: 'Increments the project version') doLast { incrementVersion() }
task g24(description: 'Sets the groovy version to 2.4') doLast { updateGroovy('2_4') }
task g25(description: 'Sets the groovy version to 2.5') doLast { updateGroovy('2_5') }
task g30(description: 'Sets the groovy version to 3.0') doLast { updateGroovy('3_0') }
def incrementVersion() {
def props = new Properties()
def f = file('gradle.properties')
f.withInputStream { props.load(it) }
def version = props.getProperty('version')
def nums = version.trim().split(/\.|-M|-RC|-groovy\d.\d/)
nums[-1] = (nums[-1] as int) + 1
def matcher = version =~ /(-M|-RC)/
def newVersion = matcher ? "${nums[0..-2].join('.')}${matcher.group()}${nums[-1]}" : "${nums.join('.')}"
props.setProperty('version', newVersion + '-groovy2.5')
f.withOutputStream {props.store(it, 'gradle properties')}
}
def updateGroovy(gversion) {
def props = new Properties()
def f = file('gradle.properties')
f.withInputStream { props.load(it) }
def version = props.getProperty('version')
props.setProperty('groovyVersion', props.getProperty("groovy$gversion"))
props.setProperty('version', version.substring(0, version.lastIndexOf('-')) + "-groovy${gversion.replace(/_/, /./)}")
f.withOutputStream {props.store(it, 'gradle properties')}
}
println "Groovy version = ${GroovySystem.getVersion()}"
task pom doFirst {
pom {
project {
groupId 'org.groocss'
artifactId 'groocss'
inceptionYear '2016'
url 'http://groocss.org/'
name 'GrooCSS'
description 'Code CSS in Groovy'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
name 'Adam L. Davis'
email 'adamd@adamldavis.com'
}
}
scm {
connection 'scm:git:git://github.com/adamldavis/groocss.git'
developerConnection 'scm:git:ssh://git@github.com:adamldavis/groocss.git'
url 'https://github.com/adamldavis/groocss'
}
}
}.writeTo("$buildDir/$applicationName-${version}.pom")
}
String getSpockClassifier(String groovyVersion) {
if (groovyVersion.startsWith('2.5')) {
return '1.3-groovy-2.5'
}
if (groovyVersion.startsWith('2.4')) {
return '1.3-groovy-2.4'
}
return '1.2-groovy-2.5'
}