forked from ballerina-platform/openapi-connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
153 lines (138 loc) · 5.63 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
import org.ballerinax.openapi.validator.Utils
buildscript {
dependencies {
classpath files("libs/ballerinax-openapi-validator-1.0-SNAPSHOT-all.jar")
}
}
plugins {
id 'java'
id "com.github.spotbugs" version "${githubSpotbugsVersion}"
id "com.github.johnrengelman.shadow" version "${githubJohnrengelmanShadowVersion}"
id "de.undercouch.download" version "${underCouchDownloadVersion}"
id "net.researchgate.release" version "${researchgateReleaseVersion}"
}
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
def ballerinaDistributionPath = System.getenv("BALLERINA_HOME")
List<String> ballerinaPackages = new ArrayList<>();
List<String> updatedBallerinaPackages = new ArrayList<>();
boolean release = false;
boolean remote = false;
boolean buildAll = false;
boolean testTool = false;
if (project.hasProperty("remote")){
remote = new Boolean(project.property("remote").toString())
}
if (project.hasProperty("release")){
release = new Boolean(project.property("release").toString())
}
if (project.hasProperty("buildAll")){
buildAll = new Boolean(project.property("buildAll").toString())
}
if (project.hasProperty("testTool")){
testTool = new Boolean(project.property("testTool").toString())
}
String toolTestsDirPath = project.projectDir.absolutePath + "/tool-tests";
List<String> toolTestPackages = new ArrayList<>();
toolTestPackages = Utils.findBallerinaPackages(toolTestsDirPath);
Utils.loadOpenAPIProperties(project.projectDir.absolutePath)
String openApiPackageDirPath = project.projectDir.absolutePath + "/openapi";
updatedBallerinaPackages = Utils.findUpdatedBallerinaPackages(openApiPackageDirPath);
ballerinaPackages = Utils.findBallerinaPackages(openApiPackageDirPath);
if (buildAll){
updatedBallerinaPackages = ballerinaPackages;
}
task codeBuild {
if (!testTool) {
println "Task: Building connectors..."
for (String path : updatedBallerinaPackages) {
Utils.executePrechecks(path);
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal pack ${path}"
}
}
if (!release) {
println "Task: Pushing connectors to local..."
for (String path : updatedBallerinaPackages) {
try {
exec {
workingDir "${path}"
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal push --repository=local"
}
}
catch (Exception ex) {
println "Failed to push connector [" + path + "] to local repository. Error : " + ex.toString();
}
}
}
}
}
task releaseConnector {
if(release){
println "Task: Pushing connectors to Ballerina Central..."
for (String path : updatedBallerinaPackages) {
try {
exec {
println "Pushing connector [" + path + "] to Ballerina Central"
workingDir "${path}"
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal push"
}
} catch (Exception ex) {
println "Failed to push connector [" + path + "] to Ballerina Central. Error : " + ex.toString();
}
try {
Utils.bumpBallerinaTomlVersion(path);
} catch (Exception ex) {
println "Failed to bump version of connector [" + path + "] to next. Error : " + ex.toString();
}
println "---------------------------------------"
}
println "Task: Pushed all connectors to Ballerina Central successfully..."
print "Task: Updating package hashes: "
Utils.writeUpdatedFileHashes(project.projectDir.absolutePath, updatedBallerinaPackages)
println "Success"
}
}
task testOpenAPITool {
if (testTool) {
println "Task: Testing OpenAPI tool ..."
for (String path : toolTestPackages) {
println "----- Case - " + path
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal openapi -i openapi.yaml --mode client"
workingDir(path)
}
println "Connector generation done for " + path
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal pack ${path}"
}
println "bal pack done for " + path
}
// Test variations of commands in the openapi tool
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal openapi -i openapi.yaml --mode client --nullable"
workingDir(toolTestsDirPath + "/15-nullable")
}
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal pack"
workingDir(toolTestsDirPath + "/15-nullable")
}
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal openapi -i openapi.yaml --mode client " +
"--license "+ toolTestsDirPath + "/resources/licence.txt"
workingDir(toolTestsDirPath + "/16-license")
}
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal pack"
workingDir(toolTestsDirPath + "/16-license")
}
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal openapi -i openapi.yaml --mode client --with-tests"
workingDir(toolTestsDirPath + "/17-with-tests")
}
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal pack"
workingDir(toolTestsDirPath + "/17-with-tests")
}
}
}