-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
201 lines (173 loc) · 5.79 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
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: "jacoco"
apply plugin: 'signing'
apply plugin: 'sonar-runner'
sourceCompatibility = 1.7
version = artifactVersion
group = artifactGroup
archivesBaseName = artifactName
/*
The sonarRunner plugin needs to be updated to work with SonarQube 4.4.
Run "gradle wrapper" to generate the wrapper script, and then run
the sonar runner with "gradlew.bat sonarRunner"
*/
task wrapper(type: Wrapper) {
gradleVersion = "2.3"
}
repositories {
mavenLocal()
mavenCentral()
}
def servletVersion = '3.1.0'
def jspApiVersion = '2.0'
def jacksonVersion = '1.9.13'
def springTestVersion = '4.1.0.RELEASE'
def mockitoVersion = '1.9.5'
def testNgVersion = '6.0.1'
def jacocoVersion = '0.7.2.201409121644'
def esapiVersion = '2.1.0'
def guavaVersion = '14.0.1'
def apacheCommonsIOVersion = '2.4'
def apacheCommonsLangVersion = '3.0'
def owaspHtmlSanitizerVersion = 'r239'
/*
These libraries are provided. Gradle has no concept of provided libraries,
but we need to identify these for Maven.
*/
def providedLibraries = [
'javax.servlet:javax.servlet-api:' + servletVersion,
'javax.servlet:jsp-api:' + jspApiVersion
]
dependencies {
/*
Add dependencies on the provided libraries
*/
for (lib in providedLibraries) {
compile lib
}
compile 'org.codehaus.jackson:jackson-mapper-asl:' + jacksonVersion
compile 'org.owasp.esapi:esapi:' + esapiVersion
compile 'com.google.guava:guava:' + guavaVersion
compile 'commons-io:commons-io:' + apacheCommonsIOVersion
compile 'org.apache.commons:commons-lang3:' + apacheCommonsLangVersion
compile 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:' + owaspHtmlSanitizerVersion
testCompile 'org.springframework:spring-test:' + springTestVersion
testCompile 'org.mockito:mockito-all:' + mockitoVersion
testCompile 'org.testng:testng:' + testNgVersion
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
def nexusUser = project.hasProperty('ossrhUsername') ? project.getProperty('ossrhUsername') : ""
def nexusPass = project.hasProperty('ossrhPassword') ? project.getProperty('ossrhPassword') : ""
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: nexusUser, password: nexusPass)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: nexusUser, password: nexusPass)
}
/*
It is currently not possible to set the scope to anything other than runtime with the gradle
plugin. This workaround sets the scope to compile.
http://forums.gradle.org/gradle/topics/maven_publish_plugin_generated_pom_making_dependency_scope_runtime
*/
pom.withXml {
/*
Set the scope to provided for those libraries we grouped together in the providedLibraries array
*/
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'compile' && providedLibraries.find {
dep -> def depSplit = dep.split(":"); return depSplit[0] == it.groupId.text() && depSplit[1] == it.artifactId.text() && depSplit[2] == it.version.text();
}
}.each() {
it.scope*.value = 'provided'
}
}
pom.project {
name 'Parameter Validation Filter'
packaging 'jar'
// optionally artifactId can be defined here
description 'A servlet filter to validate parameters'
url 'https://github.com/AutoGeneral/ParameterValidationFilter'
scm {
connection 'scm:git:https://github.com/AutoGeneral/ParameterValidationFilter.git'
developerConnection 'scm:svn:https://github.com/AutoGeneral/ParameterValidationFilter.git'
url 'https://github.com/AutoGeneral/ParameterValidationFilter'
}
licenses {
license {
name 'MIT'
url 'http://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'mcasperson'
name 'Matthew Casperson'
email '[email protected]'
}
}
}
}
}
}
/*
Use TestNG and ignore any failures
*/
test {
// enable TestNG support (default is JUnit)
useTestNG() {
// required to create the testng-results.xml file
useDefaultListeners=true
}
ignoreFailures = true
}
/*
This is required to specify the version of Jacoco
*/
jacoco {
toolVersion = jacocoVersion
}
/*
* The project in SonarQube will display the x.y version. This means all z releases will be
* grouped together
*/
def sonarQubeVersion = version
def releaseMajorMinorPattern = ~/(\d+)\.(\d+)\.(\d+)(-.*?-SNAPSHOT)?/;
def matcher = releaseMajorMinorPattern.matcher(sonarQubeVersion);
if (matcher.find()) {
sonarQubeVersion = matcher.group(1) + "." + matcher.group(2) + ".x" + (matcher.group(4) == null ? "" : matcher.group(4))
}
/*
SonarQube runner preferences
*/
sonarRunner {
sonarProperties {
property "sonar.host.url", sonarUrl
property "sonar.jdbc.url", sonarJDBC
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", sonarUser
property "sonar.jdbc.password", sonarPass
//property "sonar.sources", "src"
property "sonar.importSources", "false"
property "sonar.projectName", artifactName + " " + sonarQubeVersion
property "sonar.projectKey", artifactGroup + ":" + artifactName + ":" + sonarQubeVersion
}
}