-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
306 lines (247 loc) · 9.25 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
// PROJECT_NAME is defined in settings.gradle
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat' // provides embedded tomcat 7 for testing purposes
apply plugin: 'signing'
apply plugin: 'maven-publish'
group = "io.soluble.pjb"
archivesBaseName = 'php-java-bridge'
//version = "6.2.11"
version = "7.1.4-SNAPSHOT"
description = "PHPJavaBridge server (soluble fork)"
ext {
pomFile = file("${project.buildDir}/generated-pom.xml")
isReleaseVersion = !(project.version =~ /-SNAPSHOT$/)
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.5'
//classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3'
//classpath 'org.ajoberstar:gradle-git:1.6.0'
}
}
tomcatRun {
dependsOn war, tomcatStop
contextPath = '/'
httpPort = 8093;
outputFile = file('./tomcat.log')
// httpsPort = 8091
enableSSL = false
daemon = true
}
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testCompile('junit:junit:3.8.2') // the test code still uses this junit API
providedCompile('javax.servlet:servlet-api:2.5')
def tomcatVersion = '8.5.16'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:8.5.2",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
runtime('log4j:log4j:1.2.17')
}
tomcat {
httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol'
ajpProtocol = 'org.apache.coyote.ajp.AjpNio2Protocol'
}
// When testing you can specify your local PHP executable as a system property with
// -Dphp_exec=/path/to/php-executabale on the Gradle command line
// Default value is "php" which should work both on Linux and Windows for most standard PHP installations.
if (System.getProperty('php_exec') == null) {
ant.properties['php_exec'] = 'php'
}
ant.importBuild 'build.xml'
jar {
manifest {
attributes('Main-Class': 'io.soluble.pjb.bridge.Standalone')
}
}
war {
dependsOn jar
classifier 'web'
archiveName = "JavaBridgeTemplate.war"
//version = null
//baseName "${project.archivesBaseName}-template"
//from 'src/rootContent' // could add a file-set to the root of the archive
}
jacocoTestReport {
group = 'Reporting'
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${buildDir}/reports/coverage")
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc {
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
signing {
required { signatory != null && project.ext.isReleaseVersion }
sign configurations.archives
}
publishing {
repositories {
maven {
if (project.ext.isReleaseVersion) {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
} else {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
credentials {
username = project.properties.ossrhUsername
password = project.properties.ossrhPassword
}
}
}
publications {
jar(MavenPublication) {
artifactId 'php-java-bridge'
from components.java
// Add those artifacts to the publication
artifact sourcesJar
artifact javadocJar
// Add license
tasks.withType(Jar) {
from(project.projectDir) {
include 'LICENSE.md'
into 'META-INF'
}
}
pom.withXml {
asNode().with {
appendNode('name', 'php-java-bridge')
appendNode('description', "PHPJavaBridge server (soluble fork)")
appendNode('url', 'https://github.com/belgattitude/php-java-bridge')
appendNode('scm').with {
appendNode('url', 'https://github.com/belgattitude/php-java-bridge')
appendNode('connection', 'scm:git:git://github.com/belgattitude/php-java-bridge.git')
}
appendNode('issueManagement').with {
appendNode('url', 'https://github.com/belgattitude/php-java-bridge/issues')
appendNode('system', 'GitHub')
}
appendNode('licenses').with {
appendNode('license').with {
appendNode('name', 'The Apache Software License, Version 2.0')
appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
}
}
appendNode('organization').with {
appendNode('name', 'php-java-bridge')
appendNode('url', 'https://github.com/belgattitude/php-java-bridge')
}
appendNode('developers').with {
appendNode('developer').with {
//appendNode('id', 'belgattitude')
appendNode('name', 'Sébastien Vanvelthem')
appendNode('email', 'belgattitude@gmail.com')
appendNode('organization', 'soluble.io')
appendNode('organizationUrl', 'https://github.com/belgattitude')
}
appendNode('developer').with {
appendNode('name', 'Christian P. Lerch')
appendNode('email', 'christian.p.lerch@gmail.com')
appendNode('organization', 'km-works.eu')
appendNode('organizationUrl', 'https://github.com/km-works')
}
}
}
}
//
pom.withXml {
groovy.util.Node pomNode = asNode()
// Fix the providedCompile('javax.servlet:servlet-api:2.5') that
// was resolved as 'runtime' - instead put it as provided
// And add optional to true, as the standalone server is still supported
pomNode.dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.providedCompile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'provided'
it.appendNode('optional', true)
}
// Fix the duplicate inclusion of
// providedCompile('javax.servlet:servlet-api:2.5') dep
int i = 0;
Collection servletApiDeps = pomNode.dependencies.'*'.findAll() {
it.artifactId.text() == 'servlet-api' && ++i > 1
}.each() {
it.parent().remove(it)
}
}
// Sign the pom.xml and artifacts.
if (signing.required) {
// Sign the pom.xml.
pom.withXml {
writeTo(project.ext.pomFile)
def pomAscFile = signing.sign(project.ext.pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
project.ext.pomFile.delete()
}
// Sign the artifacts. Not working
configurations.signatures.getArtifacts().each { sig ->
println "adding signature to jars publication: $sig"
artifact(sig) {
extension "jar.asc"
}
}
/*
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}*/
}
}
}
}
model {
tasks.publishJarPublicationToMavenLocal {
dependsOn(project.tasks.signArchives)
}
tasks.publishJarPublicationToMavenRepository {
dependsOn(project.tasks.signArchives)
}
}
task install(dependsOn: publishToMavenLocal)
configure(rootProject) {
task wrapper(type: Wrapper) {
description = 'Generates gradlew and gradlew.bat scripts'
gradleVersion = '4.10'
//jarFile = "${project.projectDir}/.infra/gradle/gradle-wrapper.jar"
}
}