-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
131 lines (115 loc) · 3.86 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
/*
* Note: starting from Mendix 8.14, it is possible to depend on runtime public API artifacts in nexus.
* In that case, add compileOnly dependencies like this (with MX_VERSION being major.minor.patch without build number):
*
* compileOnly "com.mendix:public-api:${MX_VERSION}@jar"
* compileOnly "com.mendix:logging-api:${MX_VERSION}@jar"
* compileOnly "com.mendix:m2ee-api:${MX_VERSION}@jar"
* compileOnly "com.mendix:json:${MX_VERSION}@jar"
* compileOnly "javax.servlet:servlet-api:2.5"
* compileOnly "javax.websocket:javax.websocket-api:1.0"
*
* and replace the ivy repository definition for cdn.mendix.com by a maven one, like this:
*
* maven {
* url 'https://nexus.rnd.mendix.com/repository/maven-hosted'
* }
*/
plugins {
id 'java-library'
id 'jacoco'
id "io.snyk.gradle.plugin.snykplugin" version "0.4"
}
sourceCompatibility = '11'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
def runtimeLibs = "$buildDir/runtime/bundles"
def userLibDir = "$projectDir/userlib"
configurations {
prepareDependencies
testImplementation.extendsFrom compileOnly // Make Mendix runtime classes available to unit tests
}
repositories {
mavenCentral()
ivy {
url 'https://cdn.mendix.com/'
patternLayout {
artifact '/[organisation]/[module]-[revision].[ext]'
}
metadataSources {
artifact()
}
}
}
dependencies {
implementation 'org.apache.commons:commons-lang3:3.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
testImplementation 'org.slf4j:slf4j-simple:1.7.30'
testImplementation 'org.mockito:mockito-junit-jupiter:3.2.4'
testImplementation 'org.mockito:mockito-core:3.2.4'
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.2'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.1'
compileOnly fileTree(dir: "$runtimeLibs")
compileOnlyApi "javax.websocket:javax.websocket-api:1.0"
// set for example MX_VERSION=8.12.0.2541 in gradle.properties
prepareDependencies "runtime:mxbuild:${MX_VERSION}@tar.gz"
}
sourceSets {
main {
java {
srcDirs = ["javasource"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
}
}
test {
useJUnitPlatform()
reports {
junitXml.required = true
}
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.required = true
csv.destination file("${buildDir}/jacocoCsv")
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: ['**/proxies/**', '**/system/**'])
}))
}
}
task copyToUserlib( type: Copy ) {
into userLibDir
from configurations.runtimeClasspath
}
task untarMxbuild( type: Copy ) {
configurations.prepareDependencies.findAll{it.name.endsWith('tar.gz')}.each {
from tarTree(resources.gzip(it))
into buildDir
include('**/runtime/bundles/com.mendix.public-api.jar')
include('**/runtime/bundles/com.mendix.logging-api.jar')
include('**/runtime/bundles/com.mendix.m2ee-api.jar')
include('**/runtime/bundles/com.mendix.json.jar')
include('**/runtime/bundles/javax.servlet-api.servlet.jar')
include('**/runtime/bundles/javax.websocket-api.websocket.jar')
includeEmptyDirs = false
}
}
task prepareDeps {
dependsOn 'clean', 'copyToUserlib', 'untarMxbuild'
}
clean {
delete "$projectDir/userlib"
}
snyk {
arguments = "--package-manager=gradle --file=build.gradle"
}
//compileJava.dependsOn tasks.prepareDeps
tasks.untarMxbuild.shouldRunAfter tasks.copyToUserlib