/* * Copyright 2000-2010 JetBrains s.r.o. * * 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.apache.tools.ant.filters.*; def TCPathVar = "path.variable.teamcitydistribution" def TCPathVarServer = "teamcity.path.variable.teamcitydistribution" def version = System.getProperties()["build.number"]; if (version == null) version = project.getProperties()["build.number"]; if (version == null) version = System.getenv("BUILD_NUMBER"); if (version == null) version = "snapshot-" + new Date().format("yyyyMMdd"+"'z'"+"hhmmss"); dependencies { def teamCityDir = ""; [TCPathVar, TCPathVarServer].each { if (project.hasProperty(it)) { teamCityDir = project.getProperties()[it]; } } def tmp = System.getProperty(TCPathVarServer); if (tmp != null) { teamCityDir = tmp; } tmp = System.getenv(TCPathVarServer); if (tmp != null) { teamCityDir = tmp; } if (!new File(teamCityDir).isDirectory()) { throw new StopExecutionException("Failed to find TeamCity home at ${teamCityDir}"); } teamCityLib = fileTree(teamCityDir + "/webapps/ROOT/WEB-INF/lib").matching { include 'annotations.jar' include 'openapi.jar' include 'util.jar' } annotationsJar = fileTree(teamCityDir + "/webapps/ROOT/WEB-INF/lib").matching { include 'annotations.jar' } log4j = fileTree(teamCityDir + "/webapps/ROOT/WEB-INF/lib").matching { include 'log4j*.jar' } agentApi = fileTree(teamCityDir + "/devPackage").matching { include 'agent-api.jar' } serverApi = fileTree(teamCityDir + "/devPackage").matching { include 'server-api.jar' } commonApi = fileTree(teamCityDir + "/devPackage").matching { include 'common-api.jar' } testApi = fileTree(teamCityDir + "/devPackage/tests").matching { include 'tests-support.jar' } } allprojects { tcVersion="7.1-SNAPSHOT" apply plugin: 'java' } subprojects { dependencies { compile annotationsJar compile log4j compile teamCityLib } } task debug << { [annotationsJar, commonApi, log4j, testApi].each { println it; println "${it.empty}"} } project(':powershell-common') { dependencies { compile commonApi compile annotationsJar } } project (':powershell-agent') { dependencies { compile project(':powershell-common') compile agentApi } } project (':powershell-server') { dependencies { compile project(':powershell-common') compile serverApi } } project (':powershell-test') { dependencies { compile project(':powershell-common') compile project(':powershell-agent') compile project(':powershell-server') } } task dist(dependsOn: [ ':powershell-common:build', ':powershell-server:build', ':powershell-agent:build' ]) { description = 'Create Powershell Runner plugin package for TeamCity' doLast { gradleDir = new File(distsDir, 'powershell') gradleServer = new File(gradleDir, 'server') gradleAgent = new File(gradleDir, 'agent') gradleTmp = new File(distsDir, 'tmp') gradleServer.mkdirs() gradleAgent.mkdirs() gradleTmp.mkdirs() copy { [ project(':powershell-common'), project(':powershell-agent') ].each { from it.libsDir } into new File(gradleTmp, 'powershell-agent'){{mkdirs();}} } task zipAgent(type: Zip) { from gradleTmp archiveName ='powershell-agent.zip' destinationDir = gradleAgent } zipAgent.execute() copy { from project(':powershell-server').libsDir from project(':powershell-common').libsDir into gradleServer } copy { into gradleDir from (projectDir) { include 'teamcity-plugin.xml' filter(ReplaceTokens, tokens:[VERSION: version ]) } } task zipPlugin(type: Zip) { from gradleDir archiveName='teamcity-powershell.zip' } zipPlugin.execute() println "##teamcity[publishArtifacts '${zipPlugin.archivePath}']" } }