-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
194 lines (178 loc) · 5.58 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
plugins {
id 'java'
id 'java-library'
id "idea"
id 'maven-publish'
}
group 'org.zkoss.test'
idea {
module {
outputDir file("$buildDir/classes/main")
testOutputDir file("$buildDir/classes/test")
}
}
repositories {
mavenCentral()
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-parameters'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
java {
// Declaring feature variants for optionalImplementation, to generate dependency optional in pom
registerFeature('optional') {
usingSourceSet(sourceSets.main)
}
}
javadoc {
configure {
options.author true
options.use true
options.version true
options.showFromProtected()
options.addStringOption("charset", "UTF-8")
options.addBooleanOption("notimestamp", false)
options.addBooleanOption("-allow-script-in-comments", true)
options.addBooleanOption('Xdoclint:none', true)
options.addBooleanOption("breakiterator", true)
options.addStringOption("-source ${version}")
options.docFilesSubDirs = true
}
}
// build javadoc jar each subproject for bundle
task javadocJar(type: Jar) {
dependsOn 'javadoc'
archiveClassifier = 'javadoc'
from "$javadoc.destinationDir"
}
// build sources jar for bundle
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
// add generated java in to source
from "$buildDir/generated/source/buildConfig/main/main/"
includeEmptyDirs false
from 'src/main/java/'
from('src/main/resources') {
exclude '**/metainfo'
}
setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
dependencies {
api "org.hamcrest:hamcrest:$hamcrestVersion"
api "io.github.bonigarcia:webdrivermanager:$webdrivermanagerVersion"
api "com.palantir.docker.compose:docker-compose-junit-jupiter:$dockerJunitVersion"
api "org.seleniumhq.selenium:selenium-java:$seleniumVersion"
api "org.apache.commons:commons-compress:$commonsCompressVersion"
api "org.apache.commons:commons-lang3:$commonsLang3Version"
api "org.eclipse.jetty:jetty-server:$jettyVersion"
api "org.eclipse.jetty:jetty-webapp:$jettyVersion"
api "com.google.guava:guava:33.3.1-jre" // override com.palantir.docker.compose using old version fails on maven project
api "org.junit.jupiter:junit-jupiter-api:$junitVersion"
optionalImplementation "org.zkoss.common:zcommon:${zkVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
test {
useJUnitPlatform()
}
allprojects {
afterEvaluate {
// generate Publishing tasks each project, you can check these tasks with 'gradle task' command
publishing {
publications {
"$project.name"(MavenPublication) {
groupId = "${group}"
artifactId = project.name
// pom configuration
pom {
name = project.description
url = "https://www.zkoss.org/$project.name"
description = project.description
licenses {
license {
name = 'GNU LESSER GENERAL PUBLIC LICENSE, Version 3'
url = 'https://www.gnu.org/licenses/lgpl.html'
distribution = 'repo'
}
}
developers {
developer {
id = 'zkteam'
name = 'ZK Team'
email = '[email protected]'
url = 'https://www.zkoss.org'
organization = 'Potix'
organizationUrl = 'https://www.zkoss.org'
roles = ['architect', 'developer']
timezone = '8'
properties = [
picUrl: 'https://www.zkoss.org'
]
}
}
scm {
connection = 'scm:git:https://github.com/zkoss/zk-webdriver.git'
url = 'https://mavensync.zkoss.org/maven2'
}
withXml {
// add repositories in generated pom
def repositoriesNode = asNode().appendNode('repositories')
project.repositories.each {repository ->
if (repository instanceof MavenArtifactRepository && repository.name != 'MavenRepo') {
def repositoryNode = repositoriesNode.appendNode('repository')
repositoryNode.appendNode('id', repository.name)
repositoryNode.appendNode('url', repository.url)
}
}
// add provided dependency in generated pom
project.configurations.compileOnly.allDependencies.each { dependency ->
asNode().dependencies[0].appendNode("dependency").with {
it.appendNode("groupId", dependency.group)
it.appendNode("artifactId", dependency.name)
it.appendNode("version", dependency.version)
it.appendNode("scope", "provided")
}
}
}
}
// add dependencies to pom
afterEvaluate {
from(components.java)
}
suppressAllPomMetadataWarnings()
}
}
}
// move & rename default-pom.xml
task preparePomFile(type: Copy) {
dependsOn(rootProject.tasks.withType(GenerateMavenPom))
into file("$projectDir/build/pom")
from file("$rootDir/build/publications/$project.name")
include '**/pom-default.xml'
rename 'pom-default.xml', 'pom.xml'
setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
// combine jar, source.jar, javadoc.jar & pom.xml into one bundle.jar
task bundleJar(type: Jar) {
dependsOn 'jar'
dependsOn 'sourcesJar'
dependsOn 'javadocJar'
dependsOn 'preparePomFile'
dependsOn(project.getTasksByName('bundleAPIJar', false))
dependsOn(project.getTasksByName('bundleIMPLJar', false))
archiveClassifier = "bundle"
def elementName = "${project.name}-${project.version}"
from("$buildDir/libs") {
include "**/${elementName}.jar"
include "**/${elementName}-sources.jar"
include "**/${elementName}-javadoc.jar"
setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
from("$buildDir/pom") {
include "pom.xml"
setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
}
}
}
description = 'ZK Webdriver'