forked from greggigon/TeamCity-Crowd-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·169 lines (134 loc) · 4.88 KB
/
build.gradle
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'groovy'
id 'java'
id 'idea'
}
ext {
teamCityVersion = '9.0.2'
crowdVersion = '2.6.7'
teamCityDistributionDir = "$projectDir/teamcitydist"
if (project.hasProperty('teamCityDist')) {
teamCityDistributionDir = project.teamCityDist
}
pluginDir = "$buildDir/plugin"
pluginLibrariesDir = "$pluginDir/server"
pluginDestinationDir = new File("${project.buildDir}/dist")
}
repositories {
mavenCentral()
maven {
url 'https://maven.atlassian.com/repository/public'
}
}
configurations {
crowd
compile {
extendsFrom crowd
}
plugin
}
dependencies {
crowd "com.atlassian.crowd:crowd-integration-client-rest:$crowdVersion"
compile files(
"$project.teamCityDistributionDir/TeamCity/lib/servlet-api.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/web.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/annotations.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/jdom.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/openapi.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/spring.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/common-api.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/guava-13.0.1.jar",
"$project.teamCityDistributionDir/TeamCity/webapps/ROOT/WEB-INF/lib/log4j-1.2.12.jar",
"$project.teamCityDistributionDir/TeamCity/devPackage/server-api.jar",
)
runtime 'org.slf4j:slf4j-log4j12:1.7.2'
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-all:1.9.5'
testRuntime "com.cyrusinnovation:mockito-groovy-support:1.2"
testCompile 'org.springframework:spring-test:3.0.7.RELEASE'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.codehaus.groovy:groovy-all:2.2.1'
}
import org.apache.tools.ant.filters.ReplaceTokens
jar {
dependsOn test
metaInf {
from(sourceSets.main.resources) {
include 'build-server-plugin*.xml'
}
}
exclude 'build-server-plugin*.xml'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
task downloadTeamCityDistribution << {
def f = new File("TeamCity-${project.teamCityVersion}.tar.gz")
def teamcityUrl = "http://download-cf.jetbrains.com/teamcity/TeamCity-${project.teamCityVersion}.tar.gz"
if (!f.exists()) {
new URL(teamcityUrl).withInputStream { i -> f.withOutputStream{ it << i }}
}
}
downloadTeamCityDistribution.onlyIf {
def destinationFile = file("TeamCity-${project.teamCityVersion}.tar.gz")
!destinationFile.exists()
}
task deletePreviousVersion(type: Delete, dependsOn: downloadTeamCityDistribution) {
def versionFile = new File(teamCityDistributionDir, "current.version")
onlyIf { !versionFile.exists() || !versionFile.text.contains(teamCityVersion) }
delete teamCityDistributionDir
}
task unpackTeamCityDistribution(type: Copy, dependsOn: deletePreviousVersion) {
def target = file(project.teamCityDistributionDir)
onlyIf { !target.exists() }
from tarTree("TeamCity-${project.teamCityVersion}.tar.gz")
into target
}
task createVersionFile(dependsOn: unpackTeamCityDistribution) << {
def versionFile = new File(teamCityDistributionDir, "current.version")
versionFile.text = teamCityVersion
}
createVersionFile.onlyIf { !new File(teamCityDistributionDir, "current.version").exists()}
compileJava.dependsOn createVersionFile
task copyPluginFile(type: Copy) {
from(projectDir) {
include 'teamcity-plugin.xml'
filter(ReplaceTokens, tokens: [version: project.version])
}
into project.pluginDir
}
task copyPluginConfiguration(type: Copy) {
from(sourceSets.main.resources) {
include 'teamcity-crowd-plugin.properties'
}
into project.pluginLibrariesDir
}
task copyPluginJarFile(dependsOn: jar, type: Copy) {
from("$project.buildDir/libs") {
include "*.jar"
}
into project.pluginLibrariesDir
}
task copyPluginDependencies(type: Copy) {
from(configurations.crowd) {
exclude "activation*.jar", 'commons-codec*', 'commons-collections*', 'commons-land*', 'commons-logging*', 'ehcache*', 'jaxen*', 'jdom*', 'log4j*'
}
into project.pluginLibrariesDir
}
//copyPluginDependencies.dependsOn unpackTeamCityDistribution
task buildPlugin(description: 'Prepares ZIP plugin file', type: Zip) {
destinationDir = project.pluginDestinationDir
archiveName = "teamcity-crowd-plugin-${project.version}.zip"
from(project.pluginDir)
}
buildPlugin.dependsOn = [copyPluginFile, copyPluginJarFile, copyPluginDependencies]
task prepareWrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
artifacts {
plugin buildPlugin
}