-
Notifications
You must be signed in to change notification settings - Fork 754
/
build.gradle
149 lines (136 loc) · 4.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
plugins {
id 'base'
alias libs.plugins.spotbugs
alias libs.plugins.dorongold.task.tree
alias libs.plugins.github.johnrengelman.shadow
id 'maven-publish'
alias libs.plugins.researchgate.release
id 'jacoco'
alias libs.plugins.sonarqube
id 'repositories'
}
allprojects {
tasks.withType(JavaCompile).configureEach {
options.fork = true
}
group = project.group
version = project.version
tasks.register('printPath') {
doLast{
println projectDir
}
}
}
subprojects {
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.name
version = project.version
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ballerina-platform/ballerina-lang")
credentials {
username System.getenv("publishUser")
password System.getenv("publishPAT")
}
}
}
}
release {
// Disable check snapshots temporarily
failOnSnapshotDependencies = false
failOnCommitNeeded = false
tagTemplate = 'v${version}'
buildTasks = ['build']
git {
// To release from any branch
requireBranch = null
}
}
}
dependencies {
constraints {
//implementation 'org.springframework:spring-web:5.0.2.RELEASE'
}
}
def classFilesArray = []
def execFilesArray = []
def skipDirectories = [
"ballerina-gradle-plugins", // Gradle plugins
"jballerina-benchmark-test", // Benchmark test code
"lib-creator", // Gradle code for generate Bala files
"semtypes", // Tests are in nBallerina branch
"test-artifacts",// Tests directories for project api
"ballerina-lang/tests"// Ballerina Language Tests
]
tasks.register('copyExecFilesAndJavaClassFiles') {
subprojects.forEach { subproject ->
fileTree("${subproject.buildDir}/jacoco").matching {
include "**/*.exec"
}.each {
execFilesArray.push(it)
}
// Sources of modules used specifically for tests, gradle plugins are skipped
boolean skipProject = false
skipDirectories.forEach { dir ->
{
if (subproject.projectDir.path.contains(dir)) {
skipProject = true
return
}
}
}
if (skipProject) {
return
}
fileTree("${subproject.buildDir}/classes").matching {
exclude '**/java/test/**'
exclude '**/default/**'
exclude '**/module-info.class'
}.each { file ->
classFilesArray.push(file)
}
}
}
tasks.register('copyBallerinaClassFiles') {
subprojects.forEach { subproject ->
def ballerinaSourceDirectory = new File("${subproject.buildDir}/ballerina-src")
if (ballerinaSourceDirectory.exists() && subproject.projectDir.getParentFile().getName() == "langlib") {
fileTree("${subproject.buildDir}/ballerina-src/target").include("**/*.zip").forEach { zip ->
def jarFiles = zipTree(zip).matching { include '**/*.jar' }
jarFiles.forEach { jar ->
zipTree(jar).matching {
exclude '**/tests/*'
}.each { file -> classFilesArray.push(file) }
}
}
}
}
}
tasks.register('createCodeCoverageReport', JacocoReport) {
executionData files(execFilesArray)
additionalClassDirs files(classFilesArray)
reports {
xml.required = true
html.required = true
xml.destination new File("${rootDir}/.jacoco/reports/jacoco/report.xml")
html.destination new File("${rootDir}/.jacoco/reports/jacoco/report.html")
}
onlyIf = {
true
}
}
sonarqube {
properties {
property "sonar.projectKey", "ballerina-lang"
property "sonar.organization", "ballerina-platform"
property "sonar.host.url", "https://sonarcloud.io"
}
}
copyBallerinaClassFiles.dependsOn copyExecFilesAndJavaClassFiles