-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
213 lines (178 loc) · 7.06 KB
/
build.gradle.kts
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
val buildEpoch = System.currentTimeMillis()
plugins {
war
id("com.github.ben-manes.versions") version "0.38.0"
}
group = "dz.jsoftware95"
version = "4.0-SNAPSHOT"
val sourceEncoding = "UTF-8"
val warFileName = "ROOT.war"
val deploymentDir = layout.projectDirectory.dir("target")
val testDatabaseLogDir = "h2"
val activeProfiles: String? = System.getenv("SPRING_PROFILES_ACTIVE")
val intTest = "intTest"
val intTestSourceSet = sourceSets.register(intTest) {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
val intTestImplementation by lazy { intTestSourceSet.get().implementationConfigurationName }
println("$name config with active profiles: $activeProfiles")
configurations.configureEach {
if (this.name.startsWith(intTest)) {
val parentConfigName = SourceSet.TEST_SOURCE_SET_NAME + this.name.substring(intTest.length)
this.extendsFrom(configurations[parentConfigName])
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
flatDir { dir("lib") }
mavenCentral()
maven {
name = "JBoss Community repository"
setUrl("http://repository.jboss.org/nexus/content/groups/public")
}
maven {
name = "JBoss Deprecated"
setUrl("http://repository.jboss.org/nexus/content/repositories/deprecated")
}
maven {
name = "PrimeFaces Maven Repository"
setUrl("http://repository.primefaces.org")
}
}
dependencies {
val hibernateVersion = "5.4.30.Final"
providedCompile("javax:javaee-api:8.0.1")
providedCompile("org.glassfish:javax.faces:2.3.8")
providedCompile("org.hibernate:hibernate-core:$hibernateVersion")
providedCompile("org.hibernate:hibernate-entitymanager:$hibernateVersion")
implementation("org.jetbrains:annotations:17.0.0")
implementation("org.omnifaces:omnifaces:3.11")
implementation("org.primefaces:primefaces:8.0")
implementation("org.primefaces.extensions:primefaces-extensions:8.0.4")
implementation("org.primefaces.extensions:resources-ckeditor:8.0.4")
implementation("org.apache.logging.log4j:log4j-api:2.12.1")
implementation("org.apache.logging.log4j:log4j-core:2.12.1")
//implementation("org.picketbox:picketbox:+")
implementation("de.mkammerer:argon2-jvm:2.6")
implementation("com.itextpdf:kernel:7.1.8")
implementation("com.itextpdf:io:7.1.8")
implementation("com.itextpdf:layout:7.1.8")
implementation("com.itextpdf:html2pdf:2.1.5")
implementation("org.apache.commons:commons-lang3:3.9")
implementation("org.apache.commons:commons-text:1.8")
testImplementation("junit:junit:4.13")
testImplementation("org.jboss.weld:weld-junit4:2.0.1.Final")
testImplementation("org.jboss.weld.module:weld-ejb:3.1.2.Final")
testImplementation("com.h2database:h2:1.4.200")
testImplementation("mysql:mysql-connector-java:8.0.24")
testImplementation("org.hamcrest:hamcrest-all:1.3")
testImplementation("org.mockito:mockito-all:2.0.2-beta")
testImplementation("org.reflections:reflections:0.9.12")
testRuntimeOnly("org.hibernate:hibernate-core:$hibernateVersion")
testRuntimeOnly("org.hibernate:hibernate-entitymanager:$hibernateVersion")
// testImplementation("org.hibernate:hibernate-c3p0:$hibernateVersion")
// testImplementation("c3p0:c3p0:0.9.1.2")
testImplementation("org.codehaus.btm:btm:2.1.4")
testImplementation("org.slf4j:slf4j-api:1.7.30")
testImplementation("ch.qos.logback:logback-classic:1.2.3")
testImplementation("nl.jqno.equalsverifier:equalsverifier:3.3")
testImplementation("com.carrotsearch:junit-benchmarks:0.7.2")
add(intTestImplementation, "org.testng:testng:7.1.0")
add(intTestImplementation, "org.jboss.arquillian.testng:arquillian-testng-container:1.5.0.Final")
add(intTestImplementation, "org.arquillian.container:arquillian-chameleon-testng-container-starter:1.0.0.CR6")
}
configurations.configureEach {
resolutionStrategy {
eachDependency {
if (requested.group == "log4j" && requested.name == "log4j")
useVersion("1.2.17")
else if (requested.group == "com.sun.istack"
&& requested.name == "istack-commons-runtime"
&& requested.version?.startsWith("1.") == true
)
useVersion("1.0")
}
}
}
// this config is nice to have but cause a huge performance issue during sync
//tasks.withType(JavaCompile::class).configureEach {
// this.options.encoding = sourceEncoding
//}
fun passClasspathAsSystemProperty(test: Test) {
val files: Set<File> = test.classpath.files
val classpathFiles: String = files
.filter { it.isFile }
.map { it.absolutePath }
.reduce { path1, path2 -> path1 + File.pathSeparatorChar + path2 }
test.systemProperty("intTest.testWar.classpath", classpathFiles)
}
fun addIntTestClasspath(test: Test) {
test.testClassesDirs = intTestSourceSet.get().output.classesDirs
test.classpath = intTestSourceSet.get().runtimeClasspath
}
tasks {
this.war {
destinationDirectory.set(deploymentDir)
archiveFileName.set(warFileName)
this.filesMatching("**/web.xml") {
filter { line ->
val result = line.replace("@buildEpoch", buildEpoch.toString())
if (activeProfiles == null && result.contains("@removeLine", true)) "" else result
}
}
}
val cleanTestLog by registering(Delete::class) {
delete(testDatabaseLogDir)
}
val cleanTest by existing {
dependsOn(cleanTestLog)
}
this.clean {
description = "delete compiled/deployed/test output the are generated by running other tasks"
dependsOn(cleanTest)
delete("out", deploymentDir)
}
// val parseTestLog by registering(H2LogParser::class) {
// description = "extract SQL statements from H2 database log"
// from(testDatabaseLogDir)
// into(testDatabaseLogDir)
// }
//
// this.test {
// description = "run unit tests"
// useJUnit()
// jvmArgs = listOf("-Djub.consumers=CONSOLE,H2", "-Djub.db.file=out/test/benchmarks")
// this.failFast = true
// finalizedBy(parseTestLog)
// doFirst {
// delete("h2/test_db.trace.db")
// }
// }
//
// register("intTests", Test::class) {
// description = "run integration tests"
// addIntTestClasspath(this)
// passClasspathAsSystemProperty(this)
// useTestNG()
// }
}
class Benchmark : TaskExecutionListener {
private var startTime: Long? = null
override fun beforeExecute(task: Task) {
startTime = System.nanoTime()
}
override fun afterExecute(task: Task, state: TaskState) {
val t0 = startTime
if (t0 != null) {
val duration = System.nanoTime() - t0
startTime = null
if (state.didWork)
println("Task " + task.name + " took: " + TimeUnit.NANOSECONDS.toSeconds(duration) + " seconds")
}
}
}
gradle.taskGraph.addTaskExecutionListener(Benchmark())