build.gradle 4.19 KB
Newer Older
Misagh Moayyed's avatar
Misagh Moayyed committed
1
import org.apache.tools.ant.taskdefs.condition.Os
Misagh Moayyed's avatar
Misagh Moayyed committed
2
import java.nio.file.*
Misagh Moayyed's avatar
Misagh Moayyed committed
3

4 5 6
buildscript {
    repositories {
        mavenLocal()
Misagh Moayyed's avatar
Misagh Moayyed committed
7
        mavenCentral()
8
        jcenter()
9
        maven { url "https://repo.spring.io/libs-milestone" }
Misagh Moayyed's avatar
Misagh Moayyed committed
10
        maven { url "https://plugins.gradle.org/m2/" }
11 12
    }
    dependencies {
Misagh Moayyed's avatar
Misagh Moayyed committed
13
        classpath "de.undercouch:gradle-download-task:${project.gradleDownloadTaskVersion}"
Misagh Moayyed's avatar
Misagh Moayyed committed
14
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}"
Misagh Moayyed's avatar
Misagh Moayyed committed
15
        classpath "gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:${project.jibVersion}"
16 17 18 19 20 21 22
    }
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
Misagh Moayyed's avatar
Misagh Moayyed committed
23 24
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    maven { url "https://build.shibboleth.net/nexus/content/repositories/releases/" }
25 26
    maven { url "https://repo.spring.io/milestone/" }
    maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
27 28
}

Misagh Moayyed's avatar
Misagh Moayyed committed
29 30 31 32 33 34
def casServerVersion = project.'cas.version'
def casWebApplicationBinaryName = "cas.war"

project.ext."casServerVersion" = casServerVersion
project.ext."casWebApplicationBinaryName" = casWebApplicationBinaryName

35
apply from: "https://dl.bintray.com/scalding/generic/waroverlay.gradle"
Misagh Moayyed's avatar
Misagh Moayyed committed
36
apply from: rootProject.file("gradle/tasks.gradle")
Misagh Moayyed's avatar
Misagh Moayyed committed
37

38 39 40 41
apply plugin: "war"
apply plugin: "org.springframework.boot"
apply plugin: "eclipse"
apply plugin: "idea"
Misagh Moayyed's avatar
Misagh Moayyed committed
42 43
apply plugin: "com.google.cloud.tools.jib"

Misagh Moayyed's avatar
Misagh Moayyed committed
44 45 46
tasks.findByName("jibDockerBuild")
    .dependsOn(copyWebAppIntoJib, copyConfigIntoJib)
    .finalizedBy(deleteWebAppFromJib)
Misagh Moayyed's avatar
Misagh Moayyed committed
47

Misagh Moayyed's avatar
Misagh Moayyed committed
48 49
tasks.findByName("build").mustRunAfter("setExecutable")

Misagh Moayyed's avatar
Misagh Moayyed committed
50 51 52 53 54 55 56 57 58
afterEvaluate { project ->
    println "******************************************************************"
    println "Apereo CAS $casServerVersion"
    println "Enterprise Single SignOn for all earthlings and beyond"
    println "- https://github.com/apereo/cas"
    println "- https://apereo.github.io/cas"
    println "******************************************************************"
}

Misagh Moayyed's avatar
Misagh Moayyed committed
59 60 61
configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

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

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

war {
78
    includeWarJars = true
79
    entryCompression = ZipEntryCompression.STORED
80 81
}

82 83 84 85 86
springBoot {
    mainClassName = "org.apereo.cas.web.CasWebApplication"
}

bootWar {
Misagh Moayyed's avatar
Misagh Moayyed committed
87 88 89 90 91 92 93 94 95 96 97 98
    doFirst {
        def executable = project.hasProperty("executable") && Boolean.valueOf(project.getProperty("executable"))
        if (executable) {
            logger.info "Including launch script for executable WAR artifact"
            launchScript()
        } else {
            logger.info "WAR artifact is not marked as an executable"
        }
        archiveName "${casWebApplicationBinaryName}"
        baseName "cas"
        excludeDevtools = true
    }
99 100 101 102 103 104 105
}

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

106 107 108 109 110
wrapper {
    distributionType = Wrapper.DistributionType.BIN
    gradleVersion = "${project.gradleVersion}"
}

111
dependencies {
Misagh Moayyed's avatar
Misagh Moayyed committed
112
    if (project.hasProperty("external")) {
Misagh Moayyed's avatar
Misagh Moayyed committed
113
        compile "org.apereo.cas:cas-server-webapp:${casServerVersion}"
Misagh Moayyed's avatar
Misagh Moayyed committed
114
    } else {
Misagh Moayyed's avatar
Misagh Moayyed committed
115
        compile "org.apereo.cas:cas-server-webapp${project.appServer}:${casServerVersion}"
Misagh Moayyed's avatar
Misagh Moayyed committed
116 117
    }
    // Other dependencies may be listed here...
118 119
}

Misagh Moayyed's avatar
Misagh Moayyed committed
120 121
jib {
    from {
hdeadman's avatar
hdeadman committed
122
        image = project.baseDockerImage
Misagh Moayyed's avatar
Misagh Moayyed committed
123 124 125 126 127 128 129 130 131
    }
    to {
        image = "${project.group}/${project.name}"
        /**
         ecr-login: Amazon Elastic Container Registry (ECR)
         gcr: Google Container Registry (GCR)
         osxkeychain: Docker Hub
         */
        credHelper = "osxkeychain"
Misagh Moayyed's avatar
Misagh Moayyed committed
132
        /**
Misagh Moayyed's avatar
Misagh Moayyed committed
133 134 135 136 137 138 139 140
        auth {
            username = "*******"
            password = "*******"
        }
        tags = [casServerVersion]
        */
    }
    container {
Misagh Moayyed's avatar
Misagh Moayyed committed
141
        useCurrentTimestamp = true
Misagh Moayyed's avatar
Misagh Moayyed committed
142 143 144 145 146 147 148 149 150 151
        entrypoint = ['docker/entrypoint.sh']
        ports = ['80', '443', '8080', '8443']
        labels = [version:casServerVersion, name:project.name, group:project.group]
    }
    extraDirectory {
        path = file('src/main/jib')
        permissions = [
            '/docker/entrypoint.sh': '755'
        ]
    }
Misagh Moayyed's avatar
Misagh Moayyed committed
152
}