Commit 13e41605 authored by hdeadman's avatar hdeadman

add windows build.cmd, add tasks to gradle to download/run CAS shell

parent 74d22f49
@echo off
@set JAVA_ARGS=-Xms500m -Xmx1g
@set CAS_DIR=\etc\cas
@set CONFIG_DIR=\etc\cas\config
@set SHELL_DIR=build\libs
@set BUILD_DIR=build\libs
@if "%PROFILES%" == "" @set PROFILES=standalone
@rem Call this script with DNAME and CERT_SUBJ_ALT_NAMES already set to override
@if "%DNAME%" == "" set DNAME=CN=cas.example.org,OU=Example,OU=Org,C=US
@rem List other host names or ip addresses you want in your certificate, may help with host name verification,
@rem if client apps make https connection for ticket validation and compare name in cert (include sub. alt. names)
@rem to name used to access CAS
@if "%CERT_SUBJ_ALT_NAMES%" == "" set CERT_SUBJ_ALT_NAMES=dns:example.org,dns:localhost,dns:%COMPUTERNAME%,ip:127.0.0.1
@rem Check for gradle in path, use it if found, otherwise use gradle wrapper
@set GRADLE_CMD=gradle.bat
@where /q gradle
@if %ERRORLEVEL% neq 0 set GRADLE_CMD=.\gradlew.bat
@if "%1" == "" call:help
@if "%1" == "clean" (
call:clean
shift
)
@if "%1" == "copy" call:copy
@if "%1" == "package" call:package %2 %3 %4
@if "%1" == "debug" call:debug %2 %3 %4
@if "%1" == "run" call:run %2 %3 %4 & goto :EOF
@if "%1" == "refresh" call:refresh %2 %3 %4
@if "%1" == "help" call:help
@if "%1" == "gencert" call:gencert
@if "%1" == "cli" call:cli
@if "%1" == "debugcli" call:debugcli
@if "%1" == "dependencies" call:dependencies
@rem function section starts here
@goto :EOF
:copy
@echo "Creating configuration directory under %CONFIG_DIR%"
if not exist %CONFIG_DIR% mkdir %CONFIG_DIR%
@echo "Copying configuration files from etc/cas to /etc/cas"
xcopy /S /Y etc\cas\* \etc\cas
@goto :EOF
:help
@echo "Usage: build.cmd [copy|clean|package|refresh|run|debug|gencert] [optional extra args for gradle]"
@echo "To get started on a clean system, run 'build.cmd gencert && build.cmd copy && build.cmd run'"
@echo "Note that using the copy or gencert arguments will create and/or overwrite the %CAS_DIR% which is outside this project"
@goto :EOF
:clean
call %GRADLE_CMD% clean %1 %2 %3
exit /B %ERRORLEVEL%
@goto :EOF
:package
call %GRADLE_CMD% build %1 %2 %3
exit /B %ERRORLEVEL%
@goto :EOF
:debug
call:package %1 %2 %3 & java %JAVA_ARGS% -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n -jar %BUILD_DIR%\cas.war --spring.profiles.active=%PROFILES%
@goto :EOF
:run
call:package %1 %2 %3 & java %JAVA_ARGS% -jar %BUILD_DIR%\cas.war --spring.profiles.active=%PROFILES%
@goto :EOF
:refresh
call:package --refresh-dependencies %1 %2
@goto :EOF
:gencert
where /q keytool
if ERRORLEVEL 1 (
@echo Java keytool.exe not found in path.
exit /b 1
) else (
if not exist %CAS_DIR% mkdir %CAS_DIR%
@echo on
@echo Generating self-signed SSL cert for %DNAME% in %CAS_DIR%\thekeystore
keytool -genkeypair -alias cas -keyalg RSA -keypass changeit -storepass changeit -keystore %CAS_DIR%\thekeystore -dname %DNAME% -ext SAN=%CERT_SUBJ_ALT_NAMES%
@echo Exporting cert for use in trust store (used by cas clients)
keytool -exportcert -alias cas -storepass changeit -keystore %CAS_DIR%\thekeystore -file %CAS_DIR%\cas.cer
)
@goto :EOF
:cli
call %GRADLE_CMD% runShell
@goto :EOF
:debugcli
call %GRADLE_CMD% debugShell
@goto :EOF
:dependencies
call %GRADLE_CMD% allDependencies
@goto :EOF
......@@ -6,6 +6,8 @@ buildscript {
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}"
classpath 'de.undercouch:gradle-download-task:3.4.3' // used to download CAS shell
classpath 'org.apache.ivy:ivy:2.4.0' // used to download CAS shell from snapshot repo
}
}
......@@ -25,7 +27,7 @@ apply plugin: "war"
apply plugin: "org.springframework.boot"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: 'de.undercouch.download'
eclipse {
classpath {
......@@ -42,10 +44,13 @@ idea {
}
war {
includeWarJars = true
entryCompression = ZipEntryCompression.STORED
}
warOverlay {
includeWarJars = true
}
springBoot {
mainClassName = "org.apereo.cas.web.CasWebApplication"
}
......@@ -89,7 +94,7 @@ task explodeWar(type: Copy, group: "build", description: "Explodes the cas.war")
task run(group: "build", description: "Run the CAS web application in embedded container mode") {
dependsOn build
doLast {
def casRunArgs = Arrays.asList("-Xmx2048M ".split(" "))
def casRunArgs = Arrays.asList("-Xmx2048M -XX:+TieredCompilation -XX:TieredStopAtLevel=1".split(" "))
javaexec {
main = "-jar"
jvmArgs = casRunArgs
......@@ -99,13 +104,14 @@ task run(group: "build", description: "Run the CAS web application in embedded c
}
}
task debug(group: "build", description: "Debug the CAS web application in embedded mode on port 5000") {
task debug(group: "build", description: "Debug the CAS web application in embedded mode on port 5005") {
dependsOn build
doLast {
def casDebugArgs = Arrays.asList("-Xmx2048M -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y".split(" "))
def casArgs = Arrays.asList("-Xmx2048M".split(" "))
javaexec {
main = "-jar"
jvmArgs = casDebugArgs
jvmArgs = casArgs
debug = true
args = ["build/libs/cas.war"]
logger.info "Started ${commandLine}"
}
......@@ -118,6 +124,61 @@ task casVersion(group: "build", description: "Display the current CAS version")
}
}
task downloadShell (description: "Download CAS shell jar from snapshot or release maven repo") {
doLast {
def downloadFile
if ("${project.'cas.version'}".contains("SNAPSHOT")) {
def snapshotDir = "https://oss.sonatype.org/content/repositories/snapshots/org/apereo/cas/cas-server-support-shell/${project.'cas.version'}/"
def files = new org.apache.ivy.util.url.ApacheURLLister().listFiles(new URL(snapshotDir))
files = files.sort{it.path}
files.each {
if (it.path.endsWith('.jar')) {
downloadFile = it
}
}
} else {
downloadFile = "https://repo1.maven.org/maven2/org/apereo/cas/cas-server-support-shell/${project.'cas.version'}/cas-server-support-shell-${project.'cas.version'}.jar"
}
println ("Downloading file: ${downloadFile}")
download {
src downloadFile
dest new File("${project.shellDir}", "cas-server-support-shell-${project.'cas.version'}.jar")
overwrite false
}
}
}
downloadShell.doFirst {
mkdir "${project.shellDir}"
}
task runShell (description: "Run the CAS shell") {
dependsOn downloadShell
doLast {
def casShellArgs = Arrays.asList("-Xmx1500M".split(" "))
javaexec {
main = "-jar"
jvmArgs = casShellArgs
standardInput = System.in
args = ["${project.shellDir}/cas-server-support-shell-${project.'cas.version'}.jar", "--shell"]
}
}
}
task debugShell (description: "Run the CAS shell with debug options, wait for debugger on port 5005") {
dependsOn downloadShell
doLast {
def casArgs = Arrays.asList("-Xmx1500M ".split(" "))
javaexec {
main = "-jar"
jvmArgs = casArgs
debug = true
standardInput = System.in
args = ["${project.shellDir}/cas-server-support-shell-${project.'cas.version'}.jar", "--shell"]
}
}
}
task showConfiguration(group: "build", description: "Show configurations for each dependency, etc") {
doLast() {
def cfg = project.hasProperty("configuration") ? project.property("configuration") : "compile"
......
......@@ -12,3 +12,6 @@ sourceCompatibility=10
targetCompatibility=10
gradleVersion=4.10.2
# where do download cas shell jar
shellDir=build/libs
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment