build.gradle 5.82 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 47 48 49

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

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

war {
    entryCompression = ZipEntryCompression.STORED
}

50 51 52 53
warOverlay {
    includeWarJars = true
}

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
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
}

74 75 76 77 78
wrapper {
    distributionType = Wrapper.DistributionType.BIN
    gradleVersion = "${project.gradleVersion}"
}

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

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

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

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

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

182 183 184 185 186 187 188
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 }
    }
}

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

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