1
+ @ echo off
2
+ @ title %0
3
+
4
+ @ setlocal
5
+
6
+ @ REM checkPreconditions
7
+ where mvn > NUL
8
+ if not %ERRORLEVEL% == 0 (
9
+ echo It seems you do not have maven installed. Please ensure you have it installed and executable as " mvn" .
10
+ exit /B 1
11
+ )
12
+
13
+ where java > NUL
14
+ if not %ERRORLEVEL% == 0 (
15
+ echo It seems you do not have java installed. Please ensure you have it installed and executable as " java" .
16
+ exit /B 1
17
+ )
18
+ if not exist target (
19
+ md target
20
+ )
21
+
22
+ :preconditions_ok
23
+ if not " %* " == " " goto parse_args
24
+
25
+ :print_usage
26
+ echo usage: call %0 with the following options:
27
+ echo --test to run the tests
28
+ echo --testUi to run the tests including UI tests
29
+ echo --packageJmc to package JMC
30
+ echo --clean to run maven clean
31
+ echo --run to run JMC once it was packaged
32
+ echo --help to show this help dialog
33
+ exit /B 0
34
+
35
+ :parse_args
36
+ if " %1 " == " --help" goto print_usage
37
+ if " %1 " == " --test" goto test
38
+ if " %1 " == " --testUi" goto testUi
39
+ if " %1 " == " --packageJmc" goto packageJmc
40
+ if " %1 " == " --clean" goto clean
41
+ if " %1 " == " --run" goto run
42
+ echo unknown argument %1
43
+ goto print_usage
44
+
45
+ :startJetty
46
+ for /f " skip=1" %%A in ('wmic os get localdatetime ^ | findstr .') do (set LOCALDATETIME=%%A )
47
+ set TIMESTAMP = %LOCALDATETIME:~0 ,14 %
48
+ set P2_SITE_LOG = %cd% \build_%TIMESTAMP% .1.p2_site.log
49
+ set JETTY_LOG = %cd% \build_%TIMESTAMP% .2.jetty.log
50
+ set INSTALL_LOG = %cd% \build_%TIMESTAMP% .3.install.log
51
+ echo %time% building p2:site - logging output to %P2_SITE_LOG%
52
+ call mvn -f releng\third-party\pom.xml p2:site --log-file " %P2_SITE_LOG% "
53
+ if not %ERRORLEVEL% == 0 (
54
+ echo p2:site build failed!
55
+ exit /B 1
56
+ )
57
+ echo %time% run jetty - logging output to %JETTY_LOG%
58
+ start " %1 " cmd /C " mvn -f releng\third-party\pom.xml jetty:run --log-file %JETTY_LOG% "
59
+ :wait_jetty
60
+ echo Waiting for jetty server to start
61
+ timeout /t 1
62
+ findstr " [INFO] Started Jetty Server" %JETTY_LOG%
63
+ if not %ERRORLEVEL% == 0 goto :wait_jetty
64
+ echo %time% jetty server up and running
65
+ echo %time% installing core artifacts - logging output to %INSTALL_LOG%
66
+ call mvn -f core\pom.xml clean install --log-file " %INSTALL_LOG% "
67
+ if not %ERRORLEVEL% == 0 (
68
+ call :killJetty %1
69
+ echo installing core artifacts failed!
70
+ exit /B 1
71
+ )
72
+ exit /B 0
73
+
74
+ @ REM Kill the console based on title passed as first arg (%1)
75
+ @ REM tasklist gives us the pid, and using unique id on window title to filter the list
76
+ :killJetty
77
+ echo kill jetty
78
+ for /F " tokens=2 delims=," %%R in ('tasklist /FI " Windowtitle eq %1 " /NH /FO csv') do (
79
+ taskkill /PID %%R
80
+ )
81
+ exit /B 0
82
+
83
+ :test
84
+ echo %time% running tests
85
+ call mvn verify
86
+ goto end
87
+
88
+ :testUi
89
+ @ REM generate a unique id for window title
90
+ @ REM allow to filter uniquely to get PID associated later
91
+ set JETTY_TITLE = jmc-jetty-%time%
92
+ call :startJetty %JETTY_TITLE%
93
+ if not %ERRORLEVEL% == 0 (
94
+ exit /B 1
95
+ )
96
+ echo %time% running UI tests
97
+ call mvn verify -P uitests
98
+ call :killJetty %JETTY_TITLE%
99
+ goto end
100
+
101
+ :packageJmc
102
+ @ REM generate a unique id for window title
103
+ @ REM allow to filter uniquely to get PID associated later
104
+ set JETTY_TITLE = jmc-jetty-%time%
105
+ call :startJetty %JETTY_TITLE%
106
+ if not %ERRORLEVEL% == 0 (
107
+ exit /B 1
108
+ )
109
+ for /f " skip=1" %%A in ('wmic os get localdatetime ^ | findstr .') do (set LOCALDATETIME=%%A )
110
+ set TIMESTAMP = %LOCALDATETIME:~0 ,14 %
111
+ set PACKAGE_LOG = %cd% \build_%TIMESTAMP% .4.package.log
112
+ echo %time% packaging jmc - logging output to %PACKAGE_LOG%
113
+ call mvn package --log-file " %PACKAGE_LOG% "
114
+ if %ERRORLEVEL% == 0 echo You can now run jmc by calling " %0 --run" or " %cd% \target\products\org.openjdk.jmc\win32\win32\x86_64\JDK Mission Control\jmc.exe"
115
+ call :killJetty %JETTY_TITLE%
116
+ goto end
117
+
118
+ :clean
119
+ echo %time% running clean up
120
+ call mvn clean
121
+ cd core
122
+ call mvn clean
123
+ cd ..
124
+ cd releng\third-party
125
+ call mvn clean
126
+ cd ..\..
127
+ goto end
128
+
129
+ :run
130
+ set JMC_EXE = %cd% \target\products\org.openjdk.jmc\win32\win32\x86_64\JDK Mission Control\jmc.exe
131
+ if exist " %JMC_EXE% " (
132
+ start /B cmd /c " %JMC_EXE% "
133
+ ) else (
134
+ echo JMC not found in \" %JMC_EXE% \" . Did you call --packageJmc before?
135
+ )
136
+ goto end
137
+
138
+ :end
0 commit comments