build.gradle 4.76 KB
Newer Older
Remi  PLANEL's avatar
Remi PLANEL committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
apply plugin: "war"
apply plugin: "webapp"
apply plugin: "com.bmuschko.cargo"

sourceSets {
    main {
        java {
            srcDirs = ["src/main/java"]
        }
        resources {
            srcDirs = ["src/main/resources"]
        }
    }
}

configurations {
    onlyRunTime
}

def explodedWebAppDir = "$buildDir/explodedWebApp"
def mergePropsDir = "$buildDir/props"

dependencies {
    compile (project(":dbmodel")) {transitive = false}
    compile group: "org.intermine", name: "bio-core", version: System.getProperty("bioVersion"), transitive: false
    compile group: "org.intermine", name: "intermine-api", version: System.getProperty("imVersion")
    compile group: "org.intermine", name: "intermine-webapp", version: System.getProperty("imVersion"), classifier: "classes"
    compile group: "org.intermine", name: "intermine-webtasks", version: System.getProperty("imVersion")
    onlyRunTime group: 'org.intermine', name: 'bluegenes', version: System.getProperty("blueGenesVersion")
}

war {
    dependsOn 'mergeProperties', 'summariseObjectStore', 'unwarBioWebApp', 'addStrutsConfig'
    finalizedBy 'warWebApp'
}

task warWebApp(type: War) {
    dependsOn 'copyWebappContent'
    description "Create the war from the build/explodedWebAppDir directory"
    from "${explodedWebAppDir}"
    exclude "WEB-INF/web.properties"
    webInf { from "${mergePropsDir}" }
}

task copyWebappContent(type: Copy) {
    from "src/main/webapp/"
    into "${explodedWebAppDir}"
}

// read in mine.properties to get the contextPath
def props = new Properties()
file(minePropertyFile).withInputStream { props.load(it) }

webappConfig {
    mineName = "legiomine"
    objectStoreName = "os.production"
    userProfileObjectStoreName = "os.userprofile-production"
    userProfileObjectStoreWriterName = "osw.userprofile-production"
    defaultInterminePropertiesFile = "default.intermine.production.properties"
    propsDir = "$mergePropsDir"
}

// -------------------------------------------------------------------------------------------------------
// Use cargo to deploy the webapp to an existing Tomcat instance, either via the HTTP Tomcat manager or local file copy.
// -------------------------------------------------------------------------------------------------------
cargo {

    // change this to match your Tomcat major version (keep the x)
    containerId = 'tomcat8x'
    int remotePort = 8080
    if (props.getProperty("webapp.port") != null) {
        remotePort = props.getProperty("webapp.port").toInteger()
    }

    // change this to the Tomcat root of your choice
    deployable {
        context = props.getProperty("webapp.path")
    }

    def remoteHostName = "localhost"

    // if "hostname" is defined in properties file, use that
    if (props.getProperty("webapp.hostname") != null) {
        remoteHostName = props.getProperty("webapp.hostname")
    } else {
        remoteHostName = getServerName(props.getProperty("webapp.deploy.url"))
    }

    def remoteProtocol = "http"

    // if "protocol" is defined in properties file, use that
    if (props.getProperty("webapp.protocol") != null) {
        remoteProtocol = props.getProperty("webapp.protocol")
    }

    // change these to match your Tomcat host and tomcat-users config
    remote {
        hostname = remoteHostName
        protocol = remoteProtocol
        username = props.getProperty("webapp.manager")
        password = props.getProperty("webapp.password")
        port = remotePort
    }
}

cargoStartLocal.dependsOn war
cargoRunLocal.dependsOn war
cargoRedeployLocal.dependsOn war
cargoDeployRemote.dependsOn war
cargoRedeployRemote.dependsOn war

// gets the hostname from the old intermine parameter, e.g. http://localhost:8080 > localhost
String getServerName(String deployUrl) {
    // chop off protocol
    if (deployUrl != null && deployUrl.indexOf("/") >= 0) {
        // https:// or http://
        deployUrl = deployUrl.substring(deployUrl.indexOf("/") + 2, deployUrl.length())
    }

    // chop off port
    if (deployUrl != null && deployUrl.contains(":")) {
        // localhost:8080
        String[] bits = deployUrl.split(":")
        deployUrl = bits[0]
    }

    return deployUrl
}

task blueGenesStart(type: JavaExec) {
    classpath = configurations.onlyRunTime
    main = "bluegenes.core"
    //println "Loading blue genes for '" + props.getProperty("project.title") + "' at '" + props.getProperty("webapp.baseurl") + "/" + props.getProperty("webapp.path") + "'"

    //:bluegenes-default-service-root "http://beta.flymine.org/beta"
    environment("bluegenes-default-service-root", props.getProperty("webapp.baseurl") + "/" + props.getProperty("webapp.path"))
    // FlyMine Beta
    environment("bluegenes-default-mine-name", props.getProperty("project.title"))
    environment("bluegenes-jar-version", System.getProperty("blueGenesVersion"))
}