22
33EVOMASTER_VERSION = "1.6.2-SNAPSHOT"
44
5-
65import sys
76import os
87import shutil
1110from shutil import copytree
1211from subprocess import run
1312from os .path import expanduser
14-
13+ import re
1514
1615MAKE_ZIP = False
1716UPDATE = False
1817
18+ # handle maven
19+ MAVEN_VERSION_REGEX = "\d{1,2}\\ .\d{1,2}\\ .\d{1,2}"
20+ MAVEN_VERSION_ABOVE = "3.8.6"
21+
22+
23+ def checkMavenVersion ():
24+ mvn_txt = re .search (MAVEN_VERSION_REGEX , shutil .which ("mvn" )).group ()
25+ mvn_version = mvn_txt .split ("." )
26+ if len (mvn_version ) != 3 :
27+ print ("\n ERROR: Cannot find maven with `which mvn`:" + mvn_txt )
28+ exit (1 )
29+ above = MAVEN_VERSION_ABOVE .split ("." )
30+ for index , v in enumerate (mvn_version ):
31+ if int (above [index ]) > int (v ):
32+ return True
33+
34+ return False
35+
36+
37+ if not checkMavenVersion ():
38+ print ("\n ERROR: Maven version must be " + MAVEN_VERSION_ABOVE + "or above in order to successfully compile all Web "
39+ "APIs in EMB" )
40+ exit (1 )
41+
1942if len (sys .argv ) > 1 :
2043 MAKE_ZIP = "zip" in sys .argv
2144 UPDATE = "update" in sys .argv
2245
23-
2446### Environment variables ###
2547
2648HOME = expanduser ("~" )
@@ -51,11 +73,9 @@ def checkJavaVersions():
5173 exit (1 )
5274
5375
54-
5576######################################
5677### Prepare "dist" folder ###
5778def prepareDistFolder ():
58-
5979 if os .path .exists (DIST ):
6080 shutil .rmtree (DIST )
6181
@@ -66,117 +86,125 @@ def callMaven(folder, jdk_home):
6686 env_vars = os .environ .copy ()
6787 env_vars ["JAVA_HOME" ] = jdk_home
6888
69- mvnres = run (["mvn" , "clean" , "install" , "-DskipTests" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION ,folder ), env = env_vars )
89+ mvnres = run (["mvn" , "clean" , "install" , "-DskipTests" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION , folder ),
90+ env = env_vars )
7091 mvnres = mvnres .returncode
7192
7293 if mvnres != 0 :
7394 print ("\n ERROR: Maven command failed" )
7495 exit (1 )
7596
76- ### Building Maven JDK 8 projects ###
77- def build_jdk_8_maven () :
7897
98+ ### Building Maven JDK 8 projects ###
99+ def build_jdk_8_maven ():
79100 folder = "jdk_8_maven"
80101 callMaven (folder , JAVA_HOME_8 )
81102
82103 # Copy JAR files
83- copy (folder + "/cs/rest/original/features-service/target/features-service-sut.jar" , DIST )
84- copy (folder + "/em/external/rest/features-service/target/features-service-evomaster-runner.jar" , DIST )
104+ copy (folder + "/cs/rest/original/features-service/target/features-service-sut.jar" , DIST )
105+ copy (folder + "/em/external/rest/features-service/target/features-service-evomaster-runner.jar" , DIST )
106+
107+ copy (folder + "/cs/rest/original/scout-api/api/target/scout-api-sut.jar" , DIST )
108+ copy (folder + "/em/external/rest/scout-api/target/scout-api-evomaster-runner.jar" , DIST )
109+
110+ copy (folder + "/cs/rest/original/proxyprint/target/proxyprint-sut.jar" , DIST )
111+ copy (folder + "/em/external/rest/proxyprint/target/proxyprint-evomaster-runner.jar" , DIST )
85112
86- copy (folder + "/cs/rest/original/scout-api/api/ target/scout-api -sut.jar" , DIST )
87- copy (folder + "/em/external/rest/scout-api /target/scout-api -evomaster-runner.jar" , DIST )
113+ copy (folder + "/cs/rest/original/catwatch/catwatch-backend/ target/catwatch -sut.jar" , DIST )
114+ copy (folder + "/em/external/rest/catwatch /target/catwatch -evomaster-runner.jar" , DIST )
88115
89- copy (folder + "/cs/rest/original/proxyprint /target/proxyprint -sut.jar" , DIST )
90- copy (folder + "/em/external/rest/proxyprint /target/proxyprint -evomaster-runner.jar" , DIST )
116+ copy (folder + "/cs/rest/artificial/ncs /target/rest-ncs -sut.jar" , DIST )
117+ copy (folder + "/em/external/rest/ncs /target/rest-ncs -evomaster-runner.jar" , DIST )
91118
92- copy (folder + "/cs/rest/original/catwatch/catwatch-backend/ target/catwatch -sut.jar" , DIST )
93- copy (folder + "/em/external/rest/catwatch /target/catwatch -evomaster-runner.jar" , DIST )
119+ copy (folder + "/cs/rest/artificial/scs/ target/rest-scs -sut.jar" , DIST )
120+ copy (folder + "/em/external/rest/scs /target/rest-scs -evomaster-runner.jar" , DIST )
94121
95- copy (folder + "/cs/rest/artificial/ncs /target/rest-ncs -sut.jar" , DIST )
96- copy (folder + "/em/external/rest/ncs /target/rest-ncs -evomaster-runner.jar" , DIST )
122+ copy (folder + "/cs/rest/artificial/news /target/rest-news -sut.jar" , DIST )
123+ copy (folder + "/em/external/rest/news /target/rest-news -evomaster-runner.jar" , DIST )
97124
98- copy (folder + "/cs/rest/artificial/scs /target/rest-scs -sut.jar" , DIST )
99- copy (folder + "/em/external/rest/scs /target/rest-scs -evomaster-runner.jar" , DIST )
125+ copy (folder + "/cs/rest-gui/ocvn/web /target/ocvn-rest -sut.jar" , DIST )
126+ copy (folder + "/em/external/rest/ocvn /target/ocvn-rest -evomaster-runner.jar" , DIST )
100127
101- copy (folder + "/cs/rest/artificial/news/ target/rest-news -sut.jar" , DIST )
102- copy (folder + "/em/external/rest/news /target/rest-news -evomaster-runner.jar" , DIST )
128+ copy (folder + "/cs/rest/original/languagetool/languagetool-server/ target/languagetool -sut.jar" , DIST )
129+ copy (folder + "/em/external/rest/languagetool /target/languagetool -evomaster-runner.jar" , DIST )
103130
104- copy (folder + "/cs/rest-gui/ocvn/web /target/ocvn-rest -sut.jar" , DIST )
105- copy (folder + "/em/external/rest/ocvn /target/ocvn-rest -evomaster-runner.jar" , DIST )
131+ copy (folder + "/cs/rest/original/restcountries /target/restcountries -sut.jar" , DIST )
132+ copy (folder + "/em/external/rest/restcountries /target/restcountries -evomaster-runner.jar" , DIST )
106133
107- copy (folder + "/cs/rest/original/languagetool/languagetool-server/ target/languagetool -sut.jar" , DIST )
108- copy (folder + "/em/external/rest/languagetool /target/languagetool -evomaster-runner.jar" , DIST )
134+ copy (folder + "/cs/rest-gui/gestaohospital/ target/gestaohospital-rest -sut.jar" , DIST )
135+ copy (folder + "/em/external/rest/gestaohospital /target/gestaohospital-rest -evomaster-runner.jar" , DIST )
109136
110- copy (folder + "/cs/rest/original/restcountries /target/restcountries -sut.jar" , DIST )
111- copy (folder + "/em/external/rest/restcountries /target/restcountries -evomaster-runner.jar" , DIST )
137+ copy (folder + "/cs/rest-gui/genome-nexus/web /target/genome-nexus -sut.jar" , DIST )
138+ copy (folder + "/em/external/rest/genome-nexus /target/genome-nexus -evomaster-runner.jar" , DIST )
112139
113- copy (folder + "/cs/rest-gui/gestaohospital/ target/gestaohospital-rest -sut.jar" , DIST )
114- copy (folder + "/em/external/rest/gestaohospital /target/gestaohospital-rest -evomaster-runner.jar" , DIST )
140+ copy (folder + "/cs/graphql/petclinic-graphql/ target/petclinic-graphql -sut.jar" , DIST )
141+ copy (folder + "/em/external/graphql/petclinic-graphql /target/petclinic-graphql -evomaster-runner.jar" , DIST )
115142
116- copy (folder + "/cs/rest-gui/genome-nexus/web/ target/genome-nexus -sut.jar" , DIST )
117- copy (folder + "/em/external/rest/genome-nexus /target/genome-nexus -evomaster-runner.jar" , DIST )
143+ copy (folder + "/cs/graphql/graphql-ncs/ target/graphql-ncs -sut.jar" , DIST )
144+ copy (folder + "/em/external/graphql/graphql-ncs /target/graphql-ncs -evomaster-runner.jar" , DIST )
118145
119- copy (folder + "/cs/graphql/petclinic- graphql/target/petclinic- graphql-sut.jar" , DIST )
120- copy (folder + "/em/external/graphql/petclinic- graphql/target/petclinic- graphql-evomaster-runner.jar" , DIST )
146+ copy (folder + "/cs/graphql/graphql-scs /target/graphql-scs -sut.jar" , DIST )
147+ copy (folder + "/em/external/graphql/graphql-scs /target/graphql-scs -evomaster-runner.jar" , DIST )
121148
122- copy (folder + "/cs/graphql/graphql-ncs/target/graphql-ncs-sut.jar" , DIST )
123- copy (folder + "/em/external/graphql/graphql-ncs/target/graphql-ncs-evomaster-runner.jar" , DIST )
149+ # thrift RPC
150+ copy (folder + "/cs/rpc/thrift/artificial/thrift-ncs/target/rpc-thrift-ncs-sut.jar" , DIST )
151+ copy (folder + "/em/external/thrift/ncs/target/rpc-thrift-ncs-evomaster-runner.jar" , DIST )
124152
125- copy (folder + "/cs/graphql/graphql -scs/target/graphql -scs-sut.jar" , DIST )
126- copy (folder + "/em/external/graphql/graphql- scs/target/graphql -scs-evomaster-runner.jar" , DIST )
153+ copy (folder + "/cs/rpc/thrift/artificial/thrift -scs/target/rpc-thrift -scs-sut.jar" , DIST )
154+ copy (folder + "/em/external/thrift/ scs/target/rpc-thrift -scs-evomaster-runner.jar" , DIST )
127155
128- #RPC
129- copy (folder + "/cs/rpc/thrift /artificial/thrift -ncs/target/rpc-thrift -ncs-sut.jar" , DIST )
130- copy (folder + "/em/external/thrift /ncs/target/rpc-thrift -ncs-evomaster-runner.jar" , DIST )
156+ # grpc RPC
157+ copy (folder + "/cs/rpc/grpc /artificial/grpc -ncs/target/rpc-grpc -ncs-sut.jar" , DIST )
158+ copy (folder + "/em/external/grpc /ncs/target/rpc-grpc -ncs-evomaster-runner.jar" , DIST )
131159
132- copy (folder + "/cs/rpc/thrift /artificial/thrift -scs/target/rpc-thrift -scs-sut.jar" , DIST )
133- copy (folder + "/em/external/thrift /scs/target/rpc-thrift -scs-evomaster-runner.jar" , DIST )
160+ copy (folder + "/cs/rpc/grpc /artificial/grpc -scs/target/rpc-grpc -scs-sut.jar" , DIST )
161+ copy (folder + "/em/external/grpc /scs/target/rpc-grpc -scs-evomaster-runner.jar" , DIST )
134162
135163 ind0 = os .environ .get ('SUT_LOCATION_IND0' , '' )
136164 if ind0 == '' :
137165 print ("\n WARN: SUT_LOCATION_IND0 env variable is not defined" )
138166 else :
139167 copy (ind0 , os .path .join (DIST , "ind0-sut.jar" ))
140- copy (folder + "/em/external/rest/ind0/target/ind0-evomaster-runner.jar" , DIST )
141-
168+ copy (folder + "/em/external/rest/ind0/target/ind0-evomaster-runner.jar" , DIST )
142169
143170
144171####################
145- def build_jdk_11_maven () :
146-
172+ def build_jdk_11_maven ():
147173 folder = "jdk_11_maven"
148174 callMaven (folder , JAVA_HOME_11 )
149175
150- copy (folder + "/cs/rest/cwa-verification-server/target/cwa-verification-sut.jar" , DIST )
151- copy (folder + "/em/external/rest/cwa-verification/target/cwa-verification-evomaster-runner.jar" , DIST )
176+ copy (folder + "/cs/rest/cwa-verification-server/target/cwa-verification-sut.jar" , DIST )
177+ copy (folder + "/em/external/rest/cwa-verification/target/cwa-verification-evomaster-runner.jar" , DIST )
152178
153- copy (folder + "/cs/graphql/timbuctoo/timbuctoo-instancev4/target/timbuctoo-sut.jar" , DIST )
154- copy (folder + "/em/external/graphql/timbuctoo/target/timbuctoo-evomaster-runner.jar" , DIST )
179+ copy (folder + "/cs/graphql/timbuctoo/timbuctoo-instancev4/target/timbuctoo-sut.jar" , DIST )
180+ copy (folder + "/em/external/graphql/timbuctoo/target/timbuctoo-evomaster-runner.jar" , DIST )
155181
156- copy (folder + "/cs/rest-gui/market/market-rest/target/market-sut.jar" , DIST )
157- copy (folder + "/em/external/rest/market/target/market-evomaster-runner.jar" , DIST )
182+ copy (folder + "/cs/rest-gui/market/market-rest/target/market-sut.jar" , DIST )
183+ copy (folder + "/em/external/rest/market/target/market-evomaster-runner.jar" , DIST )
158184
159185 ind1 = os .environ .get ('SUT_LOCATION_IND1' , '' )
160186 if ind1 == '' :
161- print ("\n WARN: SUT_LOCATION_IND1 env variable is not defined" )
187+ print ("\n WARN: SUT_LOCATION_IND1 env variable is not defined" )
162188 else :
163- copy (ind1 , os .path .join (DIST , "ind1-sut.jar" ))
164- copy (folder + "/em/external/rest/ind1/target/ind1-evomaster-runner.jar" , DIST )
189+ copy (ind1 , os .path .join (DIST , "ind1-sut.jar" ))
190+ copy (folder + "/em/external/rest/ind1/target/ind1-evomaster-runner.jar" , DIST )
165191
166192
167193####################
168- def build_jdk_17_maven () :
169-
194+ def build_jdk_17_maven ():
170195 folder = "jdk_17_maven"
171196 callMaven (folder , JAVA_HOME_17 )
172197
173- copy (folder + "/cs/web/spring-petclinic/target/spring-petclinic-sut.jar" , DIST )
174- copy (folder + "/em/external/web/spring-petclinic/target/spring-petclinic-evomaster-runner.jar" , DIST )
198+ copy (folder + "/cs/web/spring-petclinic/target/spring-petclinic-sut.jar" , DIST )
199+ copy (folder + "/em/external/web/spring-petclinic/target/spring-petclinic-evomaster-runner.jar" , DIST )
175200
176201
177- ####################
178- def build_jdk_11_gradle () :
202+ copy ( folder + "/cs/grpc/signal-registration/target/rpc-grpc-signal-registration-sut.jar" , DIST )
203+ copy ( folder + "/em/external/grpc/signal-registration/target/signal-registration-evomaster-runner.jar" , DIST )
179204
205+
206+ ####################
207+ def build_jdk_11_gradle ():
180208 env_vars = os .environ .copy ()
181209 env_vars ["JAVA_HOME" ] = JAVA_HOME_11
182210 folder = "jdk_11_gradle"
@@ -186,24 +214,22 @@ def build_jdk_11_gradle() :
186214 if platform .system () == "Darwin" :
187215 command = "./gradlew"
188216
189- gradleres = run ([command , "build" , "-x" , "test" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION ,folder ), env = env_vars )
217+ gradleres = run ([command , "build" , "-x" , "test" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION , folder ),
218+ env = env_vars )
190219 gradleres = gradleres .returncode
191220
192221 if gradleres != 0 :
193222 print ("\n ERROR: Gradle command failed" )
194223 exit (1 )
195224
196-
197225 # Copy JAR files
198- copy (folder + "/cs/graphql/patio-api/build/libs/patio-api-sut.jar" , DIST )
199- copy (folder + "/em/external/graphql/patio-api/build/libs/patio-api-evomaster-runner.jar" , DIST )
200-
201-
226+ copy (folder + "/cs/graphql/patio-api/build/libs/patio-api-sut.jar" , DIST )
227+ copy (folder + "/em/external/graphql/patio-api/build/libs/patio-api-evomaster-runner.jar" , DIST )
202228
203229
204230# Building JavaScript projects
205231def buildJS (path , name ):
206- print ("Building '" + name + "' from " + path )
232+ print ("Building '" + name + "' from " + path )
207233 # we use "ci" instead of "install" due to major flaws in NPM
208234 res = run (["npm" , "ci" ], shell = SHELL , cwd = path ).returncode
209235 if res != 0 :
@@ -219,45 +245,42 @@ def buildJS(path, name):
219245 copytree (path , target )
220246
221247
222-
223248####################
224249def build_js_npm ():
225- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"ncs" )), "js-rest-ncs" )
226- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"scs" )), "js-rest-scs" )
227- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"cyclotron" )), "cyclotron" )
228- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"disease-sh-api" )), "disease-sh-api" )
229- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"realworld-app" )), "realworld-app" )
230- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"rest" ,"spacex-api" )), "spacex-api" )
231- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"graphql" ,"react-finland" )), "react-finland" )
232- buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" ,"graphql" ,"ecommerce-server" )), "ecommerce-server" )
250+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "ncs" )), "js-rest-ncs" )
251+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "scs" )), "js-rest-scs" )
252+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "cyclotron" )), "cyclotron" )
253+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "disease-sh-api" )), "disease-sh-api" )
254+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "realworld-app" )), "realworld-app" )
255+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "rest" , "spacex-api" )), "spacex-api" )
256+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "graphql" , "react-finland" )), "react-finland" )
257+ buildJS (os .path .abspath (os .path .join (PROJ_LOCATION , "js_npm" , "graphql" , "ecommerce-server" )), "ecommerce-server" )
258+
233259
234260####################
235261def build_dotnet_3 ():
236-
237262 env_vars = os .environ .copy ()
238263 folder = "dotnet_3"
239264
240- dotnet = run (["dotnet" , "build" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION ,folder ), env = env_vars )
265+ dotnet = run (["dotnet" , "build" ], shell = SHELL , cwd = os .path .join (PROJ_LOCATION , folder ), env = env_vars )
241266
242267 if dotnet .returncode != 0 :
243268 print ("\n ERROR: .Net command failed" )
244269 exit (1 )
245270
246- rest = os .path .join (PROJ_LOCATION , "dotnet_3" ,"em" ,"embedded" ,"rest" )
247-
248- ncs = os .path .abspath (os .path .join (rest ,"NcsDriver" ,"bin" ,"Debug" ,"netcoreapp3.1" ))
249- scs = os .path .abspath (os .path .join (rest ,"ScsDriver" ,"bin" ,"Debug" ,"netcoreapp3.1" ))
250- sampleproject = os .path .abspath (os .path .join (rest ,"SampleProjectDriver" ,"bin" ,"Debug" ,"netcoreapp3.1" ))
251- menuapi = os .path .abspath (os .path .join (rest ,"MenuAPIDriver" ,"bin" ,"Debug" ,"netcoreapp3.1" ))
271+ rest = os .path .join (PROJ_LOCATION , "dotnet_3" , "em" , "embedded" , "rest" )
252272
273+ ncs = os .path .abspath (os .path .join (rest , "NcsDriver" , "bin" , "Debug" , "netcoreapp3.1" ))
274+ scs = os .path .abspath (os .path .join (rest , "ScsDriver" , "bin" , "Debug" , "netcoreapp3.1" ))
275+ sampleproject = os .path .abspath (os .path .join (rest , "SampleProjectDriver" , "bin" , "Debug" , "netcoreapp3.1" ))
276+ menuapi = os .path .abspath (os .path .join (rest , "MenuAPIDriver" , "bin" , "Debug" , "netcoreapp3.1" ))
253277
254278 copytree (ncs , os .path .join (DIST , "cs-rest-ncs" ))
255279 copytree (scs , os .path .join (DIST , "cs-rest-scs" ))
256280 copytree (sampleproject , os .path .join (DIST , "sampleproject" ))
257281 copytree (menuapi , os .path .join (DIST , "menu-api" ))
258282
259283
260-
261284######################################################################################
262285### Copy JavaAgent library ###
263286## This requires EvoMaster to be "mvn install"ed on your machine
@@ -268,7 +291,6 @@ def copyEvoMasterAgent():
268291 os .path .join (DIST , "evomaster-agent.jar" ))
269292
270293
271-
272294######################################################################################
273295### Create Zip file with all the SUTs and Drivers ###
274296def makeZip ():
@@ -298,8 +320,8 @@ def makeZip():
298320build_jdk_11_gradle ()
299321
300322## Those are disabled for now... might support back in the future
301- #build_js_npm()
302- #build_dotnet_3()
323+ # build_js_npm()
324+ # build_dotnet_3()
303325
304326
305327copyEvoMasterAgent ()
0 commit comments