Last active
April 27, 2020 22:45
-
-
Save cwchentw/30d0a9f034c0c6bc10a598930a7d404c to your computer and use it in GitHub Desktop.
Wrapper and utilities for Clojure on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Build script for Clojure on Windows | |
rem Copyright (c) 2020 Michael Chen | |
rem Licensed under MIT | |
rem Place the script at the scripts/ subdirectory of of a local Clojure repo. | |
rem *TODO* Use system Maven to compile Clojure | |
set script_path=%~dp0 | |
set rootdir=%script_path%..\ | |
cd %rootdir% || ( | |
echo Failed to go to %rootdir% >&2 | |
exit /B 1 | |
) | |
rem Check whether PowerShell is available. | |
powershell -Help 1>nul 2>&1 || ( | |
echo No PowerShell on the system >&2 | |
exit /B 1 | |
) | |
rem Download Maven. | |
powershell -Command "Invoke-WebRequest -Uri https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip -OutFile %rootdir%apache-maven-3.6.3-bin.zip" | |
if not exist %rootdir%apache-maven-3.6.3-bin.zip ( | |
echo Failed to download %rootdir%apache-maven-3.6.3-bin.zip >&2 | |
exit /B 1 | |
) | |
rem Unzip Maven. | |
powershell -Command "Expand-Archive -Path %rootdir%apache-maven-3.6.3-bin.zip -DestinationPath %rootdir% " | |
if not exist %rootdir%apache-maven-3.6.3 ( | |
echo Failed to extract maven to %rootdir%apache-maven-3.6.3 >&2 | |
exit /B 1 | |
) | |
set mvn=%rootdir%apache-maven-3.6.3\bin\mvn.cmd | |
%mvn% -Plocal -Dmaven.test.skip=true package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Clean script for Clojure on Windows | |
rem Copyright (c) 2020 Michael Chen | |
rem Licensed under MIT | |
rem Place the script at the scripts/ subdirectory of of a local Clojure repo. | |
set script_path=%~dp0 | |
set rootdir=%script_path%..\ | |
if exist %rootdir%clojure.jar del /S %rootdir%clojure.jar | |
if exist %rootdir%jline-1.1-SNAPSHOT.jar del /S %rootdir%jline-1.1-SNAPSHOT.jar | |
if exist %rootdir%apache-maven-3.6.3-bin.zip del /S %rootdir%apache-maven-3.6.3-bin.zip | |
if exist %rootdir%apache-maven-3.6.3 rmdir /S /Q %rootdir%apache-maven-3.6.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Wrapper for Clojure on Windows | |
rem Copyright (c) 2020 Michael Chen | |
rem Licensed under MIT | |
rem Place the script at the root path of a local Clojure repo. | |
rem Check whether Java is available. | |
java -version 1>nul 2>&1 || ( | |
echo No Java on the system >&2 | |
exit /B 1 | |
) | |
set cwd=%CD% | |
set rootdir=%~dp0 | |
rem Set extra classpath as needed. | |
if "x%CLASSPATH%" == "x" ( | |
set extra_classpath=";." | |
) else ( | |
set extra_classpath=";%CLASSPATH%;." | |
) | |
rem Check whether compiled Clojure is available. | |
rem If Clojure is not available, compile it from scratch | |
if not exist %rootdir%clojure.jar ( | |
echo No compiled Clojure on the system >&2 | |
echo Compile Clojure from scratch >&2 | |
call %rootdir%scripts\clean.bat | |
call %rootdir%scripts\build.bat | |
cd %cwd% | |
echo Restart Clojure >&2 | |
exit /B 0 | |
) | |
set arg=%1 | |
if "x%arg%" == "x" ( | |
rem Run Clojure along with jline 1.x in interactive mode. | |
java -cp %rootdir%clojure.jar;%rootdir%jline-1.1-SNAPSHOT.jar%extra_classpath% jline.ConsoleRunner clojure.main | |
) else ( | |
rem Run Clojure alone in batch mode. | |
java -cp %rootdir%clojure.jar%extra_classpath% clojure.main %* | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
We automate the whole process here.