-
Notifications
You must be signed in to change notification settings - Fork 62
/
sbt.bat
980 lines (821 loc) · 25 KB
/
sbt.bat
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
@REM SBT launcher script
@REM
@REM Environment:
@REM JAVA_HOME - location of a JDK home dir (mandatory)
@REM SBT_OPTS - JVM options (optional)
@REM Configuration:
@REM sbtconfig.txt found in the SBT_HOME.
@REM ZOMG! We need delayed expansion to build up CFG_OPTS later
@setlocal enabledelayedexpansion
@echo off
set SBT_BIN_DIR=%~dp0
if not defined SBT_HOME for %%I in ("!SBT_BIN_DIR!\..") do set "SBT_HOME=%%~fI"
set SBT_ARGS=
set _JAVACMD=
set _SBT_OPTS=
set _JAVA_OPTS=
set init_sbt_version=1.4.5
set sbt_default_mem=1024
set default_sbt_opts=
set default_java_opts=-Dfile.encoding=UTF-8
set sbt_jar=
set build_props_sbt_version=
set run_native_client=
set sbt_args_print_version=
set sbt_args_print_sbt_version=
set sbt_args_print_sbt_script_version=
set sbt_args_verbose=
set sbt_args_debug=
set sbt_args_debug_inc=
set sbt_args_batch=
set sbt_args_color=
set sbt_args_no_colors=
set sbt_args_no_global=
set sbt_args_no_share=
set sbt_args_sbt_jar=
set sbt_args_ivy=
set sbt_args_supershell=
set sbt_args_timings=
set sbt_args_traces=
set sbt_args_sbt_create=
set sbt_args_sbt_dir=
set sbt_args_sbt_version=
set sbt_args_mem=
set sbt_args_client=
rem users can set SBT_OPTS via .sbtopts
if exist .sbtopts for /F %%A in (.sbtopts) do (
set _sbtopts_line=%%A
if not "!_sbtopts_line:~0,1!" == "#" (
if "!_sbtopts_line:~0,2!" == "-J" (
set _sbtopts_line=!_sbtopts_line:~2,1000!
)
if defined _SBT_OPTS (
set _SBT_OPTS=!_SBT_OPTS! !_sbtopts_line!
) else (
set _SBT_OPTS=!_sbtopts_line!
)
)
)
rem TODO: remove/deprecate sbtconfig.txt and parse the sbtopts files
rem FIRST we load the config file of extra options.
set SBT_CONFIG=!SBT_HOME!\conf\sbtconfig.txt
set SBT_CFG_OPTS=
for /F "tokens=* eol=# usebackq delims=" %%i in ("!SBT_CONFIG!") do (
set DO_NOT_REUSE_ME=%%i
rem ZOMG (Part #2) WE use !! here to delay the expansion of
rem SBT_CFG_OPTS, otherwise it remains "" for this loop.
set SBT_CFG_OPTS=!SBT_CFG_OPTS! !DO_NOT_REUSE_ME!
)
rem poor man's jenv (which is not available on Windows)
if defined JAVA_HOMES (
if exist .java-version for /F %%A in (.java-version) do (
set JAVA_HOME=%JAVA_HOMES%\%%A
set JDK_HOME=%JAVA_HOMES%\%%A
)
)
if exist "project\build.properties" (
for /F "eol=# delims== tokens=1*" %%a in (project\build.properties) do (
if "%%a" == "sbt.version" if not "%%b" == "" (
set build_props_sbt_version=%%b
)
)
)
rem must set PATH or wrong javac is used for java projects
if defined JAVA_HOME set "PATH=%JAVA_HOME%\bin;%PATH%"
rem We use the value of the JAVACMD environment variable if defined
if defined JAVACMD set "_JAVACMD=%JAVACMD%"
rem remove quotes
if defined _JAVACMD set _JAVACMD=!_JAVACMD:"=!
if not defined _JAVACMD (
if not "%JAVA_HOME%" == "" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
)
)
if not defined _JAVACMD set _JAVACMD=java
rem users can set JAVA_OPTS via .jvmopts (sbt-extras style)
if exist .jvmopts for /F %%A in (.jvmopts) do (
set _jvmopts_line=%%A
if not "!_jvmopts_line:~0,1!" == "#" (
if defined _JAVA_OPTS (
set _JAVA_OPTS=!_JAVA_OPTS! %%A
) else (
set _JAVA_OPTS=%%A
)
)
)
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
if not defined _JAVA_OPTS if defined JAVA_OPTS set _JAVA_OPTS=%JAVA_OPTS%
if not defined _JAVA_OPTS if defined default_java_opts set _JAVA_OPTS=!default_java_opts!
rem We use the value of the SBT_OPTS environment variable if defined, rather than the config.
if not defined _SBT_OPTS if defined SBT_OPTS set _SBT_OPTS=%SBT_OPTS%
if not defined _SBT_OPTS if defined SBT_CFG_OPTS set _SBT_OPTS=!SBT_CFG_OPTS!
if not defined _SBT_OPTS if defined default_sbt_opts set _SBT_OPTS=!default_sbt_opts!
if defined SBT_NATIVE_CLIENT (
if "%SBT_NATIVE_CLIENT%" == "true" (
set sbt_args_client=1
)
)
:args_loop
shift
if "%~0" == "" goto args_end
set g=%~0
rem make sure the sbt_args_debug gets set first incase any argument parsing uses :dlog
if "%~0" == "-d" set _debug_arg=true
if "%~0" == "--debug" set _debug_arg=true
if defined _debug_arg (
set _debug_arg=
set sbt_args_debug=1
set SBT_ARGS=-debug !SBT_ARGS!
goto args_loop
)
if "%~0" == "-h" goto usage
if "%~0" == "-help" goto usage
if "%~0" == "--help" goto usage
if "%~0" == "-v" set _verbose_arg=true
if "%~0" == "-verbose" set _verbose_arg=true
if "%~0" == "--verbose" set _verbose_arg=true
if defined _verbose_arg (
set _verbose_arg=
set sbt_args_verbose=1
goto args_loop
)
if "%~0" == "-V" set _version_arg=true
if "%~0" == "-version" set _version_arg=true
if "%~0" == "--version" set _version_arg=true
if defined _version_arg (
set _version_arg=
set sbt_args_print_version=1
goto args_loop
)
if "%~0" == "--client" set _client_arg=true
if defined _client_arg (
set _client_arg=
set sbt_args_client=1
goto args_loop
)
if "%~0" == "-batch" set _batch_arg=true
if "%~0" == "--batch" set _batch_arg=true
if defined _batch_arg (
set _batch_arg=
set sbt_args_batch=1
goto args_loop
)
if "%~0" == "-no-colors" set _no_colors_arg=true
if "%~0" == "--no-colors" set _no_colors_arg=true
if defined _no_colors_arg (
set _no_colors_arg=
set sbt_args_no_colors=1
goto args_loop
)
if "%~0" == "-no-global" set _no_global_arg=true
if "%~0" == "--no-global" set _no_global_arg=true
if defined _no_global_arg (
set _no_global_arg=
set sbt_args_no_global=1
goto args_loop
)
if "%~0" == "-traces" set _traces_arg=true
if "%~0" == "--traces" set _traces_arg=true
if defined _traces_arg (
set _traces_arg=
set sbt_args_traces=1
goto args_loop
)
if "%~0" == "-sbt-create" set _sbt_create_arg=true
if "%~0" == "--sbt-create" set _sbt_create_arg=true
if defined _sbt_create_arg (
set _sbt_create_arg=
set sbt_args_sbt_create=1
goto args_loop
)
if "%~0" == "-sbt-dir" set _sbt_dir_arg=true
if "%~0" == "--sbt-dir" set _sbt_dir_arg=true
if defined _sbt_dir_arg (
set _sbt_dir_arg=
if not "%~1" == "" (
set sbt_args_sbt_dir=%1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "-sbt-boot" set _sbt_boot_arg=true
if "%~0" == "--sbt-boot" set _sbt_boot_arg=true
if defined _sbt_boot_arg (
set _sbt_boot_arg=
if not "%~1" == "" (
set sbt_args_sbt_boot=%1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "-sbt-jar" set _sbt_jar=true
if "%~0" == "--sbt-jar" set _sbt_jar=true
if defined _sbt_jar (
set _sbt_jar=
if not "%~1" == "" (
if exist "%~1" (
set sbt_args_sbt_jar=%1
shift
goto args_loop
) else (
echo %~1 does not exist
goto error
)
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "-ivy" set _sbt_ivy_arg=true
if "%~0" == "--ivy" set _sbt_ivy_arg=true
if defined _sbt_ivy_arg (
set _sbt_ivy_arg=
if not "%~1" == "" (
set sbt_args_ivy=%1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "-debug-inc" set _debug_inc_arg=true
if "%~0" == "--debug-inc" set _debug_inc_arg=true
if defined _debug_inc_arg (
set _debug_inc_arg=
set sbt_args_debug_inc=1
goto args_loop
)
if "%~0" == "--sbt-version" set _sbt_version_arg=true
if "%~0" == "-sbt-version" set _sbt_version_arg=true
if defined _sbt_version_arg (
set _sbt_version_arg=
if not "%~1" == "" (
set sbt_args_sbt_version=%~1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "--mem" set _sbt_mem_arg=true
if "%~0" == "-mem" set _sbt_mem_arg=true
if defined _sbt_mem_arg (
set _sbt_mem_arg=
if not "%~1" == "" (
set sbt_args_mem=%~1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "--supershell" set _supershell_arg=true
if "%~0" == "-supershell" set _supershell_arg=true
if defined _supershell_arg (
set _supershell_arg=
if not "%~1" == "" (
set sbt_args_supershell=%~1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
)
if "%~0" == "--color" set _color_arg=true
if "%~0" == "-color" set _color_arg=true
if defined _color_arg (
set _color_arg=
if not "%~1" == "" (
set sbt_args_color=%~1
shift
goto args_loop
) else (
echo "%~0" is missing a value
goto error
)
goto args_loop
)
if "%~0" == "--no-share" set _no_share_arg=true
if "%~0" == "-no-share" set _no_share_arg=true
if defined _no_share_arg (
set _no_share_arg=
set sbt_args_no_share=1
goto args_loop
)
if "%~0" == "--timings" set _timings_arg=true
if "%~0" == "-timings" set _timings_arg=true
if defined _timings_arg (
set _timings_arg=
set sbt_args_timings=1
goto args_loop
)
if "%~0" == "--script-version" (
set sbt_args_print_sbt_script_version=1
goto args_loop
)
if "%~0" == "--numeric-version" (
set sbt_args_print_sbt_version=1
goto args_loop
)
if "%~0" == "-jvm-debug" set _jvm_debug_arg=true
if "%~0" == "--jvm-debug" set _jvm_debug_arg=true
if defined _jvm_debug_arg (
set _jvm_debug_arg=
if not "%~1" == "" (
set /a JVM_DEBUG_PORT=%~1 2>nul >nul
if !JVM_DEBUG_PORT! EQU 0 (
rem next argument wasn't a port, set a default and process next arg
set /A JVM_DEBUG_PORT=5005
goto args_loop
) else (
shift
goto args_loop
)
)
)
if "%~0" == "-java-home" set _java_home_arg=true
if "%~0" == "--java-home" set _java_home_arg=true
if defined _java_home_arg (
set _java_home_arg=
if not "%~1" == "" (
if exist "%~1\bin\java.exe" (
set "_JAVACMD=%~1\bin\java.exe"
set "JAVA_HOME=%~1"
set "JDK_HOME=%~1"
shift
goto args_loop
) else (
echo Directory "%~1" for JAVA_HOME is not valid
goto error
)
) else (
echo Second argument for --java-home missing
goto error
)
)
if "%~0" == "new" (
if not defined SBT_ARGS (
set sbt_new=true
)
)
if "%g:~0,2%" == "-D" (
rem special handling for -D since '=' gets parsed away
for /F "tokens=1 delims==" %%a in ("%g%") do (
rem make sure it doesn't have the '=' already
if "%g%" == "%%a" (
if not "%~1" == "" (
call :dlog [args_loop] -D argument %~0=%~1
set "SBT_ARGS=!SBT_ARGS! %~0=%~1"
shift
goto args_loop
) else (
echo %g% is missing a value
goto error
)
) else (
call :dlog [args_loop] -D argument %~0
set "SBT_ARGS=!SBT_ARGS! %~0"
goto args_loop
)
)
)
if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" (
rem special handling for -XX since '=' gets parsed away
for /F "tokens=1 delims==" %%a in ("%g%") do (
rem make sure it doesn't have the '=' already
if "%g%" == "%%a" (
if not "%~1" == "" (
call :dlog [args_loop] -XX argument %~0=%~1
set "SBT_ARGS=!SBT_ARGS! %~0=%~1"
shift
goto args_loop
) else (
echo %g% is missing a value
goto error
)
) else (
call :dlog [args_loop] -XX argument %~0
set "SBT_ARGS=!SBT_ARGS! %~0"
goto args_loop
)
)
)
rem the %0 (instead of %~0) preserves original argument quoting
set SBT_ARGS=!SBT_ARGS! %0
goto args_loop
:args_end
rem Confirm a user's intent if the current directory does not look like an sbt
rem top-level directory and the "new" command was not given.
if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not exist build.sbt (
if not exist project\ (
if not defined sbt_new (
echo [warn] Neither build.sbt nor a 'project' directory in the current directory: "%CD%"
setlocal
:confirm
echo c^) continue
echo q^) quit
set /P reply=^?
if /I "!reply!" == "c" (
goto confirm_end
) else if /I "!reply!" == "q" (
exit /B 1
)
goto confirm
:confirm_end
endlocal
)
)
)
call :process
rem avoid bootstrapping/java version check for script version
if !sbt_args_print_sbt_script_version! equ 1 (
echo !init_sbt_version!
goto :eof
)
if !run_native_client! equ 1 (
goto :runnative !SBT_ARGS!
goto :eof
)
call :checkjava
call :copyrt
if defined JVM_DEBUG_PORT (
set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT!
)
call :sync_preloaded
call :run !SBT_ARGS!
if ERRORLEVEL 1 goto error
goto end
:run
rem set arguments
if defined sbt_args_debug_inc (
set _SBT_OPTS=-Dxsbt.inc.debug=true !_SBT_OPTS!
)
if defined sbt_args_no_colors (
set _SBT_OPTS=-Dsbt.log.noformat=true !_SBT_OPTS!
)
if defined sbt_args_no_global (
set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot !_SBT_OPTS!
)
if defined sbt_args_no_share (
set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy !_SBT_OPTS!
)
if defined sbt_args_supershell (
set _SBT_OPTS=-Dsbt.supershell=!sbt_args_supershell! !_SBT_OPTS!
)
if defined sbt_args_sbt_version (
set _SBT_OPTS=-Dsbt.version=!sbt_args_sbt_version! !_SBT_OPTS!
)
if defined sbt_args_sbt_dir (
set _SBT_OPTS=-Dsbt.global.base=!sbt_args_sbt_dir! !_SBT_OPTS!
)
if defined sbt_args_sbt_boot (
set _SBT_OPTS=-Dsbt.boot.directory=!sbt_args_sbt_boot! !_SBT_OPTS!
)
if defined sbt_args_ivy (
set _SBT_OPTS=-Dsbt.ivy.home=!sbt_args_ivy! !_SBT_OPTS!
)
if defined sbt_args_color (
set _SBT_OPTS=-Dsbt.color=!sbt_args_color! !_SBT_OPTS!
)
if defined sbt_args_mem (
call :addMemory !sbt_args_mem!
) else (
call :addDefaultMemory
)
if defined sbt_args_timings (
set _SBT_OPTS=-Dsbt.task.timings=true -Dsbt.task.timings.on.shutdown=true !_SBT_OPTS!
)
if defined sbt_args_traces (
set _SBT_OPTS=-Dsbt.traces=true !_SBT_OPTS!
)
if defined sbt_args_sbt_jar (
set "sbt_jar=!sbt_args_sbt_jar!"
) else (
set "sbt_jar=!SBT_HOME!\bin\sbt-launch.jar"
)
set sbt_jar=!sbt_jar:"=!
rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS
if !sbt_args_print_sbt_version! equ 1 (
call :set_sbt_version
echo !sbt_version!
goto :eof
)
if !sbt_args_print_version! equ 1 (
call :set_sbt_version
echo sbt version in this project: !sbt_version!
echo sbt script version: !init_sbt_version!
goto :eof
)
if defined sbt_args_verbose (
echo # Executing command line:
echo "!_JAVACMD!"
if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! )
if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! )
echo -cp
echo "!sbt_jar!"
echo xsbt.boot.Boot
if not "%~1" == "" ( call :echolist %* )
echo.
)
"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -cp "!sbt_jar!" xsbt.boot.Boot %*
goto :eof
:runnative
set "_SBTNCMD=!SBT_BIN_DIR!sbtn-x86_64-pc-win32.exe"
if defined sbt_args_verbose (
echo # running native client
if not "%~1" == "" ( call :echolist %* )
set "SBT_ARGS=-v !SBT_ARGS!"
)
set "SBT_SCRIPT=!SBT_BIN_DIR: =%%20!sbt.bat"
set "SBT_ARGS=--sbt-script=!SBT_SCRIPT! %SBT_ARGS%"
rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required
rem https://www.microsoft.com/en-us/download/details.aspx?id=13523
"!_SBTNCMD!" %SBT_ARGS%
goto :eof
rem for expression tries to interpret files, so simply loop over %* instead
rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Last\.sbt\0.13\java9-rt-ext-adoptopenjdk_11_0_3"
:echolist
rem call method is in first call of %0
shift
if "%~0" == "" goto echolist_end
set "p=%~0"
if "%p:~0,2%" == "-D" (
rem special handling for -D since '=' gets parsed away
for /F "tokens=1 delims==" %%a in ("%p%") do (
rem make sure it doesn't have the '=' already
if "%p%" == "%%a" if not "%~1" == "" (
echo %0=%1
shift
goto echolist
)
)
)
if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" (
rem special handling for -XX since '=' gets parsed away
for /F "tokens=1 delims==" %%a in ("%p%") do (
rem make sure it doesn't have the '=' already
if "%p%" == "%%a" if not "%~1" == "" (
echo %0=%1
shift
goto echolist
)
)
)
if "%p:~0,14%" == "-agentlib:jdwp" (
rem special handling for --jvm-debug since '=' and ',' gets parsed away
for /F "tokens=1 delims==" %%a in ("%p%") do (
rem make sure it doesn't have the '=' already
if "%p%" == "%%a" if not "%~1" == "" if not "%~2" == "" if not "%~3" == "" if not "%~4" == "" if not "%~5" == "" if not "%~6" == "" if not "%~7" == "" if not "%~8" == "" (
echo %0=%1=%2,%3=%4,%5=%6,%7=%8
shift & shift & shift & shift & shift & shift & shift & shift
goto echolist
)
)
)
echo %0
goto echolist
:echolist_end
exit /B 0
:addJava
call :dlog [addJava] arg = '%*'
set "_JAVA_OPTS=!_JAVA_OPTS! %*"
exit /B 0
:addMemory
call :dlog [addMemory] arg = '%*'
rem evict memory related options
set _new_java_opts=
set _old_java_opts=!_JAVA_OPTS!
:next_java_opt
if "!_old_java_opts!" == "" goto :done_java_opt
for /F "tokens=1,*" %%g in ("!_old_java_opts!") do (
set "p=%%g"
if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" (
set _new_java_opts=!_new_java_opts! %%g
)
set "_old_java_opts=%%h"
)
goto :next_java_opt
:done_java_opt
set _JAVA_OPTS=!_new_java_opts!
set _new_sbt_opts=
set _old_sbt_opts=!_SBT_OPTS!
:next_sbt_opt
if "!_old_sbt_opts!" == "" goto :done_sbt_opt
for /F "tokens=1,*" %%g in ("!_old_sbt_opts!") do (
set "p=%%g"
if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" (
set _new_sbt_opts=!_new_sbt_opts! %%g
)
set "_old_sbt_opts=%%h"
)
goto :next_sbt_opt
:done_sbt_opt
set _SBT_OPTS=!_new_sbt_opts!
rem a ham-fisted attempt to move some memory settings in concert
set mem=%1
set /a codecache=!mem! / 8
if !codecache! GEQ 512 set /a codecache=512
if !codecache! LEQ 128 set /a codecache=128
set /a class_metadata_size=!codecache! * 2
call :addJava -Xms!mem!m
call :addJava -Xmx!mem!m
call :addJava -Xss4M
call :addJava -XX:ReservedCodeCacheSize=!codecache!m
if /I !JAVA_VERSION! LSS 8 (
call :addJava -XX:MaxPermSize=!class_metadata_size!m
)
exit /B 0
:addDefaultMemory
rem if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings.
rem The reason is the Xms/Xmx, if they don't line up, cause errors.
set _has_memory_args=
if defined _JAVA_OPTS for /F %%g in ("!_JAVA_OPTS!") do (
set "p=%%g"
if "!p:~0,4!" == "-Xmx" set _has_memory_args=1
if "!p:~0,4!" == "-Xms" set _has_memory_args=1
)
if defined JAVA_TOOL_OPTIONS for /F %%g in ("%JAVA_TOOL_OPTIONS%") do (
set "p=%%g"
if "!p:~0,4!" == "-Xmx" set _has_memory_args=1
if "!p:~0,4!" == "-Xms" set _has_memory_args=1
)
if defined _SBT_OPTS for /F %%g in ("!_SBT_OPTS!") do (
set "p=%%g"
if "!p:~0,4!" == "-Xmx" set _has_memory_args=1
if "!p:~0,4!" == "-Xms" set _has_memory_args=1
)
if not defined _has_memory_args (
call :addMemory !sbt_default_mem!
)
exit /B 0
:dlog
if defined sbt_args_debug (
echo %* 1>&2
)
exit /B 0
:process
rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx
rem Otherwise, parses the major version; 9 out of java version 9-ea
set JAVA_VERSION=0
for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do (
set JAVA_VERSION=%%g
)
rem removes all quotes from JAVA_VERSION
set JAVA_VERSION=!JAVA_VERSION:"=!
for /f "delims=.-_ tokens=1-2" %%v in ("!JAVA_VERSION!") do (
if /I "%%v" EQU "1" (
set JAVA_VERSION=%%w
) else (
set JAVA_VERSION=%%v
)
)
rem parse the first two segments of sbt.version and set run_native_client to
rem 1 if the user has also indicated they want to use native client.
set sbtV=!build_props_sbt_version!
set sbtBinaryV_1=
set sbtBinaryV_2=
for /F "delims=.-_ tokens=1-2" %%v in ("!sbtV!") do (
set sbtBinaryV_1=%%v
set sbtBinaryV_2=%%w
)
set native_client_ready=
if !sbtBinaryV_1! geq 2 (
set native_client_ready=1
) else (
if !sbtBinaryV_1! geq 1 (
if !sbtBinaryV_2! geq 4 (
set native_client_ready=1
)
)
)
if !native_client_ready! equ 1 (
if !sbt_args_client! equ 1 (
set run_native_client=1
)
)
set native_client_ready=
exit /B 0
:checkjava
set /a required_version=6
if /I !JAVA_VERSION! GEQ !required_version! (
exit /B 0
)
echo.
echo The Java Development Kit ^(JDK^) installation you have is not up to date.
echo sbt requires at least version !required_version!+, you have
echo version "!JAVA_VERSION!"
echo.
echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download
echo a valid JDK and install before running sbt.
echo.
exit /B 1
:copyrt
if /I !JAVA_VERSION! GEQ 9 (
set "rtexport=!SBT_BIN_DIR!java9-rt-export.jar"
"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt"
set /p java9_ext= < "%TEMP%.\rtext.txt"
set "java9_rt=!java9_ext!\rt.jar"
if not exist "!java9_rt!" (
mkdir "!java9_ext!"
"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" "!java9_rt!"
)
set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!"
)
exit /B 0
:sync_preloaded
if not defined init_sbt_version (
rem FIXME: better !init_sbt_version! detection
FOR /F "tokens=* usebackq" %%F IN (`dir /b "!SBT_HOME!\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO (
SET init_sbt_version=%%F
)
)
set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\!init_sbt_version!\"
if /I !JAVA_VERSION! GEQ 8 (
where robocopy >nul 2>nul
if %ERRORLEVEL% EQU 0 (
if not exist !PRELOAD_SBT_JAR! (
if exist "!SBT_HOME!\lib\local-preloaded\" (
robocopy "!SBT_HOME!\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E >nul 2>nul
)
)
)
)
exit /B 0
:usage
for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do (
set FULL_JAVA_VERSION=%%g
)
echo.
echo Usage: %~n0 [options]
echo.
echo -h ^| --help print this message
echo -v ^| --verbose this runner is chattier
echo -V ^| --version print sbt version information
echo --numeric-version print the numeric sbt version (sbt sbtVersion)
echo --script-version print the version of sbt script
echo -d ^| --debug set sbt log level to debug
echo -debug-inc ^| --debug-inc
echo enable extra debugging for the incremental debugger
echo --no-colors disable ANSI color codes
echo --color=auto^|always^|true^|false^|never
echo enable or disable ANSI color codes ^(sbt 1.3 and above^)
echo --supershell=auto^|always^|true^|false^|never
echo enable or disable supershell ^(sbt 1.3 and above^)
echo --traces generate Trace Event report on shutdown ^(sbt 1.3 and above^)
echo --timings display task timings report on shutdown
echo --sbt-create start sbt even if current directory contains no sbt project
echo --sbt-dir ^<path^> path to global settings/plugins directory ^(default: ~/.sbt^)
echo --sbt-boot ^<path^> path to shared boot directory ^(default: ~/.sbt/boot in 0.11 series^)
echo --ivy ^<path^> path to local Ivy repository ^(default: ~/.ivy2^)
echo --mem ^<integer^> set memory options ^(default: %sbt_default_mem%^)
echo --no-share use all local caches; no sharing
echo --no-global uses global caches, but does not use global ~/.sbt directory.
echo --jvm-debug ^<port^> enable on JVM debugging, open at the given port.
rem echo --batch disable interactive mode
echo.
echo # sbt version ^(default: from project/build.properties if present, else latest release^)
echo --sbt-version ^<version^> use the specified version of sbt
echo --sbt-jar ^<path^> use the specified jar as the sbt launcher
echo.
echo # java version ^(default: java from PATH, currently !FULL_JAVA_VERSION!^)
echo --java-home ^<path^> alternate JAVA_HOME
echo.
echo # jvm options and output control
echo JAVA_OPTS environment variable, if unset uses "!default_java_opts!"
echo .jvmopts if this file exists in the current directory, its contents
echo are appended to JAVA_OPTS
echo SBT_OPTS environment variable, if unset uses "!default_sbt_opts!"
echo .sbtopts if this file exists in the current directory, its contents
echo are prepended to the runner args
echo !SBT_CONFIG!
echo if this file exists, it is prepended to the runner args
echo -Dkey=val pass -Dkey=val directly to the java runtime
rem echo -J-X pass option -X directly to the java runtime
rem echo ^(-J is stripped^)
rem echo -S-X add -X to sbt's scalacOptions ^(-S is stripped^)
echo.
echo In the case of duplicated or conflicting options, the order above
echo shows precedence: JAVA_OPTS lowest, command line options highest.
echo.
@endlocal
exit /B 1
:set_sbt_version
rem set project sbtVersion
for /F "usebackq tokens=2" %%G in (`CALL "!_JAVACMD!" -jar "!sbt_jar!" "sbtVersion" 2^>^&1`) do set "sbt_version=%%G"
exit /B 0
:error
@endlocal
exit /B 1
:end
@endlocal
exit /B 0