build.gradle 5.83 KB
Newer Older
1 2 3 4
buildscript {
    repositories {
        mavenLocal()
        jcenter()
5
        maven { url "https://repo.spring.io/libs-milestone" }
6 7
    }
    dependencies {
Misagh Moayyed's avatar
Misagh Moayyed committed
8
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}"
9 10
        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
11 12 13 14 15 16 17 18 19
    }
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url 'https://build.shibboleth.net/nexus/content/repositories/releases/' }
20 21
    maven { url "https://repo.spring.io/milestone/" }
    maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
22 23 24
}

apply from: "https://dl.bintray.com/scalding/generic/waroverlay.gradle"
Misagh Moayyed's avatar
Misagh Moayyed committed
25

26 27 28 29
apply plugin: "war"
apply plugin: "org.springframework.boot"
apply plugin: "eclipse"
apply plugin: "idea"
30
apply plugin: 'de.undercouch.download'
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

eclipse {
    classpath {
       downloadSources = true
       downloadJavadoc = true
    }
}

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

war {
47
    includeWarJars = true
48
    entryCompression = ZipEntryCompression.STORED
49 50
}

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
springBoot {
    mainClassName = "org.apereo.cas.web.CasWebApplication"
}

bootWar {
	if (project.hasProperty('executable')) {
    	launchScript()
	}

	archiveName 'cas.war'
    baseName 'cas'

    excludeDevtools = false
}

bootRun {
    sourceResources sourceSets.main
    classpath = sourceSets.main.runtimeClasspath
}

71 72 73 74 75
wrapper {
    distributionType = Wrapper.DistributionType.BIN
    gradleVersion = "${project.gradleVersion}"
}

76
dependencies {
Misagh Moayyed's avatar
Misagh Moayyed committed
77
    if (project.hasProperty("external")) {
78
        compile "org.apereo.cas:cas-server-webapp:${project.'cas.version'}"
Misagh Moayyed's avatar
Misagh Moayyed committed
79
    } else {
80
        compile "org.apereo.cas:cas-server-webapp${project.appServer}:${project.'cas.version'}"
Misagh Moayyed's avatar
Misagh Moayyed committed
81 82
    }
    // Other dependencies may be listed here...
83 84 85
}

task explodeWar(type: Copy, group: "build", description: "Explodes the cas.war") {
Misagh Moayyed's avatar
Misagh Moayyed committed
86 87 88
    dependsOn build
    from zipTree("build/libs/cas.war")
    into "${buildDir}/cas"
89 90 91 92 93
}

task run(group: "build", description: "Run the CAS web application in embedded container mode") {
    dependsOn build
    doLast {
94
        def casRunArgs = Arrays.asList("-Xmx2048M -XX:+TieredCompilation -XX:TieredStopAtLevel=1".split(" "))
95
        javaexec {
96
            main = "-jar"
97 98 99 100 101 102 103
            jvmArgs = casRunArgs
            args = ["build/libs/cas.war"]
            logger.info "Started ${commandLine}"
        }
    }
}

104
task debug(group: "build", description: "Debug the CAS web application in embedded mode on port 5005") {
105 106
    dependsOn build
    doLast {
107
        def casArgs = Arrays.asList("-Xmx2048M".split(" "))
108
        javaexec {
109
            main = "-jar"
110 111
            jvmArgs = casArgs
            debug = true
112 113 114 115 116 117 118 119
            args = ["build/libs/cas.war"]
            logger.info "Started ${commandLine}"
        }
    }
}

task casVersion(group: "build", description: "Display the current CAS version") {
    doFirst {
120
        println "${project.'cas.version'}"
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
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"]
        }
    }
}

179 180 181 182 183 184 185
task showConfiguration(group: "build", description: "Show configurations for each dependency, etc") {
    doLast() {
        def cfg = project.hasProperty("configuration") ? project.property("configuration") : "compile"
        configurations.getByName(cfg).each { println it }
    }
}

186
task updateWrapper(description: "Update the Gradle wrapper") {
187 188 189
    doFirst {
        println "Updating gradle wrapper to version specified in gradle.properties: ${project.gradleVersion}"
    }
190 191 192
    dependsOn wrapper
}

193
task allDependenciesInsight(type: DependencyInsightReportTask, description: "Produce insight information for all dependencies") {}
Daniel Ramos's avatar
Daniel Ramos committed
194
task allDependencies(type: DependencyReportTask, description: "Display a graph of all project dependencies") {}