blob: a757d729e987e10a29b9a5d6984418711c837e8e [file] [log] [blame]
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.opencord.gradle.rules.*
import org.yaml.snakeyaml.Yaml
allprojects {
apply plugin: 'base'
apply plugin: 'de.gesellix.docker'
//apply plugin: 'com.tmiyamon.config'
docker {
// dockerHost = System.env.DOCKER_HOST ?: 'unix:///var/run/docker.sock'
// dockerHost = System.env.DOCKER_HOST ?: 'https://192.168.99.100:2376'
// certPath = System.getProperty('docker.cert.path') ?: "${System.getProperty('user.home')}/.docker/machine/machines/default"
// authConfigPlain = [
// "username" : "joe",
// "password" : "some-pw-as-needed",
// "email" : "joe@acme.com",
// "serveraddress" : "https://index.docker.io/v1/"
// ]
}
}
ext {
appVersion = null
// Upstream registry to simplify filling out the comps table below
upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
// Target registry to be used to publish docker images needed for deployment
targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
// The tag used to tag the docker images push to the target registry
targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
comps = [
'aaa' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/aaa',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/aaa'
],
'vtn' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/vtn',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/vtn'
],
'mcast' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/mcast',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/mcast'
],
'igmp' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/igmp',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/igmp'
],
'olt' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/olt',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/olt'
],
'config' : [
'type': 'gitmodule',
'upstream': 'https://gerrit.opencord.org/config',
'branch' : 'master',
'tag' : appVersion,
'componentDir': './apps/config'
]
]
}
task fetchGitSubmodules {
comps.each { name, spec -> if (spec.type == 'gitmodule') { dependsOn "gitupdate" + name } }
}
task buildOnosApps (type: Exec) {
workingDir './apps'
commandLine 'mvn', 'clean', 'install'
}
task copyLocalRepo (dependsOn: buildOnosApps, type: Exec) {
workingDir './'
commandLine 'cp', '-R', System.env.HOME + '/.m2/repository', 'repository'
}
task buildRepoImage (dependsOn: copyLocalRepo, type: Exec) {
commandLine 'docker', 'build', '-t', 'cordproject/mavenrepo', '.'
}
task tagMavenRepoImage (type: Exec) {
commandLine 'docker', 'tag', 'cordproject/mavenrepo', "$targetReg/mavenrepo:$targetTag"
}
task publishMavenRepoImage (type: Exec) {
dependsOn tagMavenRepoImage
commandLine 'docker', 'push', "$targetReg/mavenrepo:$targetTag"
}
// ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~
task fetch {
dependsOn fetchGitSubmodules
}
task buildImages (dependsOn: fetch) {
dependsOn buildOnosApps
dependsOn copyLocalRepo
dependsOn buildRepoImage
}
task publish {
dependsOn publishMavenRepoImage
}
tasks.addRule(new GitSubmoduleUpdateRule(project))