-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
executable file
·220 lines (185 loc) · 6.63 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
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Settings
ext {
// Project constants
github_org = 'dirkraft'
project_name = 'dropwizard-file-assets'
artifact_group = 'com.github.dirkraft.dropwizard'
project_version = '0.0.3-SNAPSHOT'
project_description = "Dropwizard FileAssetsBundle - just plain files for pity's sake!"
project_jdk = '1.7'
/*
* Dependencies can be named so that sub-projects can reference consistent version of them.
* dependencies {
* compile deps['guava']
* }
*/
deps = [
'dropwizard-core' : 'io.dropwizard:dropwizard-core:1.0.0',
'dropwizard-assets': 'io.dropwizard:dropwizard-assets:1.0.0',
'junit' : 'junit:junit:4.12',
'mockito-core' : 'org.mockito:mockito-core:2.0.42-beta',
]
/*
* Fine tune the POM contents here, particularly, the developers section. Some defaulting behavior is provided
* for all other fields based on project constants.
*/
project_pom = {
name project_name
description project_description
url "https://github.com/${github_org}/${project_name}"
licenses {
license {
name 'Apache License, v2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0'
distribution 'repo'
}
}
scm {
url "https://github.com/${github_org}/${project_name}.git"
connection "scm:git:https://github.com/${github_org}/${project_name}.git"
developerConnection "scm:git:[email protected]:${github_org}/${project_name}.git"
}
organization {
name github_org
url "https://github.com/${github_org}"
}
developers {
developer {
id 'dirkraft'
name 'Jason Dunkelberger'
}
}
}
/** Function returns a new manifest that can be customized per module */
defaultManifest = {
return manifest {
def git_cmd = "git rev-parse HEAD"
def git_proc = git_cmd.execute()
attributes 'SCM-Revision': git_proc.text.trim()
attributes 'Timestamp': String.valueOf(System.currentTimeMillis())
attributes 'Build-Host': InetAddress.localHost.hostName
}
}
/** Used where gradle task evaluation would fail because of an undefined value, even if the task wasn't targeted. */
defaultBlank = { closure ->
try {
closure()
} catch (MissingPropertyException e) {
''
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
}
}
apply plugin: 'idea'
apply plugin: 'license'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Identifiers
group = artifact_group
version = project_version
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Plugins
apply plugin: 'groovy'
sourceCompatibility = project_jdk
targetCompatibility = project_jdk
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'idea'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// License
license {
header rootProject.file('src/license/HEADER')
}
assemble {
dependsOn licenseFormatMain, licenseFormatTest
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dependencies
repositories {
mavenCentral()
}
dependencies {
compile deps['dropwizard-core']
testCompile deps['dropwizard-assets']
testCompile deps['junit']
testCompile deps['mockito-core']
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Artifacts
jar {
doFirst {
// Timestamp changes on every build. By evaluating it later, won't needlessly fail up-to-date checks.
manifest = defaultManifest()
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
doFirst {
// Timestamp changes on every build. By evaluating it later, won't needlessly fail up-to-date checks.
manifest = defaultManifest()
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
doFirst {
// Timestamp changes on every build. By evaluating it later, won't needlessly fail up-to-date checks.
manifest = defaultManifest()
}
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Publishing
assemble {
dependsOn licenseFormatMain, licenseFormatTest
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
dependsOn licenseFormatMain, licenseFormatTest
enabled = true
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
//# ./gradlew -PdeployUrl=http://server/artifactory/repo -PdeployUser=admin -PdeployPass=pass uploadArchives
// for snapshots https://oss.sonatype.org/content/repositories/snapshots
// for staging/release https://oss.sonatype.org/service/local/staging/deploy/maven2
repository(
url: defaultBlank({ deployUrl })
) {
// If these are not defined assemble needlessly fails for unrelated tasks, hence, defaultBlank.
authentication(userName: defaultBlank({ deployUser }), password: defaultBlank({ deployPass }))
}
pom.project project_pom
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Misc
task wrapper(type: Wrapper) {
gradleVersion = '2.10'
distributionUrl = 'https://services.gradle.org/distributions/gradle-2.10-all.zip'
}
idea {
module {
downloadSources = true
}
project {
jdkName = project_jdk
languageLevel = project_jdk
vcs = 'Git'
}
}