61 lines
1.7 KiB
Groovy
61 lines
1.7 KiB
Groovy
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||
|
|
||
|
apply plugin: 'jetty'
|
||
|
|
||
|
def keystore = "$rootDir/samples/certificates/server.jks"
|
||
|
def password = 'password'
|
||
|
|
||
|
configurations {
|
||
|
casServer
|
||
|
}
|
||
|
dependencies {
|
||
|
casServer "org.jasig.cas:cas-server-webapp:3.4.3.1@war"
|
||
|
}
|
||
|
|
||
|
task casServerOverlay(type: Sync) {
|
||
|
war = configurations.casServer.resolve().toArray()[0]
|
||
|
warName = war.name.replace('.war','-custom')
|
||
|
overlayDir = file('src/main/webapp')
|
||
|
explodedWar = file("$buildDir/tmp/${warName}")
|
||
|
customWar = file("$buildDir/tmp/${warName}.war")
|
||
|
tokens = [logLevel: 'INFO']
|
||
|
|
||
|
inputs.files(war, overlayDir)
|
||
|
inputs.property('tokens',{tokens})
|
||
|
outputs.files (customWar,explodedWar,file("$buildDir/tmp/expandedArchives"))
|
||
|
|
||
|
from zipTree(war)
|
||
|
from (overlayDir) {
|
||
|
filter(ReplaceTokens,tokens: tokens)
|
||
|
}
|
||
|
into explodedWar
|
||
|
|
||
|
doLast {
|
||
|
if(customWar.exists()) {
|
||
|
customWar.delete()
|
||
|
}
|
||
|
ant.zip(destfile: customWar, baseDir: explodedWar)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
casServerOverlay.metaClass.setLogLevel { level ->
|
||
|
tokens['logLevel'] = level
|
||
|
}
|
||
|
|
||
|
task casServer (type: org.gradle.api.plugins.jetty.JettyRunWar, dependsOn: 'casServerOverlay') {
|
||
|
contextPath = "/cas"
|
||
|
connectors = [new org.mortbay.jetty.security.SslSocketConnector()]
|
||
|
connectors[0].port = 9443
|
||
|
connectors[0].keystore = connectors[0].truststore = keystore
|
||
|
connectors[0].keyPassword = connectors[0].trustPassword = password
|
||
|
connectors[0].wantClientAuth = true
|
||
|
connectors[0].needClientAuth = false
|
||
|
webApp = casServerOverlay.customWar
|
||
|
|
||
|
inputs.file casServerOverlay.customWar
|
||
|
|
||
|
doFirst() {
|
||
|
System.setProperty('javax.net.ssl.trustStore', keystore)
|
||
|
System.setProperty('javax.net.ssl.trustStorePassword', password)
|
||
|
}
|
||
|
}
|