blob: 48c63380f666024a2ac3e77242514d3f266b6947 [file] [log] [blame]
import java.nio.file.Paths
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"
project.ext.installs = new Properties()
project.ext.versions = new Properties()
subprojects {
apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"
def oldGeodeVersion = project.name
boolean useTgz = (oldGeodeVersion >= "1.7.0")
boolean downloadInstall = (oldGeodeVersion >= "1.2.0")
String archiveType = useTgz ? "tgz" : "zip"
// Each project is named after its fixed version, removing dots and removing any release tags.
// eg: 1.0.0-incubating -> test100
def projSrcName = "test".concat(oldGeodeVersion.split(/\.|-/)
.toList()
.subList(0,3)
.join(''))
project.dependencies {
compile "org.apache.geode:geode-common:${oldGeodeVersion}"
compile "org.apache.geode:geode-core:${oldGeodeVersion}"
compile "org.apache.geode:geode-lucene:${oldGeodeVersion}"
compile "org.apache.geode:geode-old-client-support:${oldGeodeVersion}"
compile "org.apache.geode:geode-wan:${oldGeodeVersion}"
compile "org.apache.geode:geode-cq:${oldGeodeVersion}"
compile "org.apache.geode:geode-rebalancer:${oldGeodeVersion}"
}
parent.ext.versions.setProperty(projSrcName, sourceSets.main.runtimeClasspath.asPath)
def unpackDest = project.buildDir.toPath().resolve('apache-geode-'.concat(oldGeodeVersion))
project.configurations.create("oldInstall")
if (downloadInstall) {
project.dependencies.add "oldInstall", "org.apache.geode:apache-geode:${oldGeodeVersion}@${archiveType}"
parent.ext.installs.setProperty(projSrcName, unpackDest.toString())
}
project.task("downloadAndUnzipFile") {
inputs.files {
configurations.oldInstall
}
outputs.dir(unpackDest)
doLast {
def oldArchive = configurations."oldInstall".singleFile
copy {
from(useTgz ? tarTree(oldArchive) : zipTree(oldArchive))
into project.buildDir
}
}
}
project.build.dependsOn(project.downloadAndUnzipFile)
project.downloadAndUnzipFile.onlyIf {downloadInstall}
(project.tasks.jar as Task).onlyIf {false}
}
def generatedResources = buildDir.toPath().resolve('generated-resources').resolve('main').toString()
task createGeodeClasspathsFile {
def classpathsFile = Paths.get(generatedResources).resolve('geodeOldVersionClasspaths.txt').toString()
def installsFile = Paths.get(generatedResources).resolve('geodeOldVersionInstalls.txt').toString()
outputs.file(classpathsFile)
outputs.file(installsFile)
// outputs.cacheIf( false )
doLast {
sourceSets.each { sset ->
project.ext.versions.setProperty(sset.name, sset.runtimeClasspath.asPath)
}
new FileOutputStream(classpathsFile).withStream { fos ->
project.ext.versions.store(fos, '')
}
// TODO potential caching issue with implicit configuration in doLast action.
new FileOutputStream(installsFile).withStream { fos ->
project.ext.installs.store(fos, '')
}
}
}
project.createGeodeClasspathsFile.mustRunAfter(clean)
project.createGeodeClasspathsFile.inputs.files(getTasksByName('downloadAndUnzipFile', true))
project.build.dependsOn(createGeodeClasspathsFile)
sourceSets {
main {
output.dir(generatedResources, builtBy: createGeodeClasspathsFile)
}
}