forked from fluxroot/jcpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
206 lines (166 loc) · 4.57 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
apply plugin: 'cobertura'
apply plugin: 'coveralls'
description = 'Java Chess Protocol Interface'
group = 'com.fluxchess'
version = '1.4.0'
ext.releaseBranch = '1.4.x'
if (!project.hasProperty('buildNumber') || !(project.hasProperty('branchName') && branchName == releaseBranch)) {
// We're probably building on a dev machine or we're building a branch
ext.buildNumber = 'dev'
}
if (!project.hasProperty('revisionNumber')) {
// We're probably building on a dev machine
ext.revisionNumber = 'dev'
}
if (!version.contains('-') && !(project.hasProperty('releaseVersion') && releaseVersion == version)) {
// Append '-rc' if we're not releasing yet
version += '-rc'
}
if (version.contains('-')) {
// Append the buildNumber if we're not releasing
version += '.' + buildNumber
}
if (version.contains('-') && !(project.hasProperty('branchName') && branchName == releaseBranch)) {
// Append the revisionNumber if we're not releasing and not on a release branch
version += '+' + revisionNumber
}
afterEvaluate { println "Building ${name} version ${version}" }
if (!project.hasProperty('s3AccessKeyId_password')) {
ext.s3AccessKeyId_password = 'n/a'
}
if (!project.hasProperty('s3SecretAccessKey_password')) {
ext.s3SecretAccessKey_password = 'n/a'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.0.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.1.6'
}
}
repositories {
mavenCentral()
}
tasks.withType(Pmd) {
pmd {
ignoreFailures = true
}
}
tasks.withType(FindBugs) {
findbugs {
ignoreFailures = true
}
}
tasks.withType(Checkstyle) {
checkstyle {
configFile = new File("${rootDir}/config/checkstyle/checkstyle.xml")
ignoreFailures = true
showViolations = false
}
}
cobertura.coverageFormats = ['html', 'xml']
sourceSets {
integration
testing
}
configurations {
integrationCompile.extendsFrom testCompile
integrationRuntime.extendsFrom testRuntime
testingCompile.extendsFrom testCompile
testingRuntime.extendsFrom testRuntime
}
dependencies {
testCompile 'junit:junit:4.+'
testCompile 'org.slf4j:slf4j-api:1.7.+'
testCompile 'org.slf4j:slf4j-log4j12:1.7.+'
testCompile 'log4j:log4j:1.2.+'
integrationCompile project(path: ':', configuration: 'testRuntime')
testingCompile project(path: ':', configuration: 'testRuntime')
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
processResources {
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
version: project.version,
buildNumber: project.buildNumber,
revisionNumber: project.revisionNumber
])
}
jar {
manifest {
attributes 'Implementation-Title': project.name, 'Implementation-Version': project.version
}
}
task testsJar(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
from sourceSets.test.output
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task integration(type: Test) {
testClassesDir = sourceSets.integration.output.classesDir
classpath = sourceSets.integration.runtimeClasspath
}
task dist(type: Zip) {
def baseDir = "${project.name}-${project.version}"
into("$baseDir") {
from 'README.md'
from 'LICENSE'
from 'NOTICE'
from jar
from sourcesJar
from javadocJar
from 'src/dist/engine-interface.txt'
}
}
artifacts {
testCompile testsJar
archives testsJar
archives sourcesJar
archives javadocJar
}
uploadArchives {
if (project.hasProperty('branchName')) {
if (branchName == releaseBranch) {
if (version.contains('-')) {
ext.repositoryName = 'staging'
} else {
ext.repositoryName = 'release'
}
configurations {
deployerJars
}
dependencies {
deployerJars 'org.springframework.build:aws-maven:4.+'
}
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: "s3://maven.fluxchess.com/${repositoryName}") {
authentication(userName: s3AccessKeyId_password, passphrase: s3SecretAccessKey_password)
}
}
}
} else {
doLast { println "Skipping upload. Not on ${releaseBranch} branch (${branchName})." }
}
} else {
doLast { println "Skipping upload. No branch name defined." }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}