-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
231 lines (201 loc) · 6.19 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:1.0.1"
}
}
apply plugin : 'java'
apply plugin : 'eclipse'
apply plugin : 'checkstyle'
apply plugin : 'pmd'
apply plugin : 'findbugs'
apply plugin : 'cobertura'
apply plugin : 'maven'
apply plugin : 'signing'
group = 'com.ninja-squad'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
build.dependsOn tasks.getByName("cobertura")
dependencies {
compile 'com.google.guava:guava:11.0.2'
compile 'com.google.code.findbugs:jsr305:2.0.0'
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.servlet.jsp:jsp-api:2.1'
compile 'javax.servlet:jstl:1.1.2'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
compile 'joda-time:joda-time:2.1'
compile 'net.sourceforge.findbugs:annotations:1.3.2'
compile 'org.hibernate:hibernate-core:3.6.10.Final'
testCompile 'junit:junit:4.+'
testCompile 'org.mockito:mockito-all:1.9.0'
}
configurations {
compile.transitive = false
testCompile.transitive = false
runtime.transitive = false
testRuntime.transitive = false
}
task checkJavaVersion << {
if (!JavaVersion.current().isJava6()) {
String message = "ERROR: Java 1.6 required but " +
JavaVersion.current() +
" found. Change your JAVA_HOME environment variable.";
throw new IllegalStateException(message);
}
}
compileJava.dependsOn checkJavaVersion
[compileJava, compileTestJava]*.options*.encoding = 'ISO-8859-1'
checkstyle {
sourceSets = [sourceSets.main]
}
checkstyleMain << {
ant.xslt(in: reports.xml.destination,
style: new File(configFile.parent, 'checkstyle-noframes-sorted.xsl'),
out: new File(reports.xml.destination.parent, 'main.html'))
}
pmd {
sourceSets = [sourceSets.main]
}
pmdMain {
ignoreFailures = true
ruleSetFiles = files('config/pmd/ruleSet.xml')
}
findbugs {
sourceSets = [sourceSets.main]
ignoreFailures = true
}
findbugsMain {
reports {
xml {
enabled = false
}
html {
enabled = true
}
}
}
def sharedManifest = manifest {
attributes(['Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'ninja-squad.com'])
}
jar {
manifest {
from sharedManifest
}
}
javadoc {
options.noTimestamp true
options.linkSource true
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
manifest {
from sharedManifest
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
manifest {
from sharedManifest
}
}
task distributionZip(type: Zip, dependsOn: [javadoc, jar]) {
classifier = 'dist'
def rootDir = project.name + '-' + project.version;
into(rootDir) {
from jar.archivePath
}
into(rootDir + '/src') {
from sourceSets.main.java
}
into(rootDir + '/javadoc') {
from javadoc.destinationDir
}
}
assemble {
dependsOn distributionZip
}
artifacts {
archives sourcesJar
archives javadocJar
}
eclipseJdt << {
File f = file('.settings/org.eclipse.core.resources.prefs')
f.write('eclipse.preferences.version=1\n')
f.append('encoding/<project>=ISO-8859-1')
}
cleanEclipseJdt << {
File f = file('.settings/org.eclipse.core.resources.prefs')
f.delete()
}
task checkSonatypeProperties << {
if (project.properties['sonatypeUsername'] == null || project.properties['sonatypePassword'] == null) {
throw new IllegalStateException("ERROR: you need to have sonatypeUsername and sonatypePassword properties" +
" defined in your HOME/.gradle/gradle.properties file to upload archives");
}
}
uploadArchives {
dependsOn checkSonatypeProperties
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: project.properties['sonatypeUsername'], password: project.properties['sonatypePassword'])
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: project.properties['sonatypeUsername'], password: project.properties['sonatypePassword'])
}
}
}
}
[install.repositories.mavenInstaller, uploadArchives.repositories.mavenDeployer]*.pom*.whenConfigured {pom ->
// we don't care about test dependencies
pom.dependencies = pom.dependencies.findAll {it.scope != 'test'}
// all compile dependencies are optional except guava
pom.dependencies.findAll {dep -> dep.artifactId != 'guava'}*.optional = true
// all dependencies are compile time dependencies, and there is no need to say it
pom.dependencies*.scope = null
pom.project {
name = 'ninja-core'
description = 'Core utilities from Ninja Squad'
url = 'http://ninja-core.ninja-squad.com/'
organization {
name = 'Ninja Squad'
url = 'http://ninja-squad.com'
}
licenses {
license {
name 'MIT License'
url 'http://ninja-core.ninja-squad.com/license.html'
distribution 'repo'
}
}
scm {
url = 'https://github.com/Ninja-Squad/ninja-core'
connection = 'scm:git:git://github.com/Ninja-Squad/ninja-core'
developerConnection = 'scm:git:git://github.com/Ninja-Squad/ninja-core'
}
developers {
developer {
id = 'jnizet'
name = 'Jean-Baptiste Nizet'
email = '[email protected]'
}
}
}
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
task wrapper(type: Wrapper) {
gradleVersion = '1.1'
}