Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 259 lines (214 sloc) 9.633 kb
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
1 /**
2 * Gradle plugins repos:
3 * https://github.com/evgeny-goldin/gradle-plugins
4 * https://github.com/valkolovos/gradle_cobertura
5 */
b2e59c9 @evgeny-goldin Gradle 1.0-m4 adaptation
authored
6
7
8168407 @evgeny-goldin Back to Gradle 1.0-m3
authored
8 task wrapper( type: Wrapper ) { gradleVersion = '1.0-milestone-3' }
b2e59c9 @evgeny-goldin Gradle 1.0-m4 adaptation
authored
9
10
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
11 buildscript {
12
13 teamCityVersion = '6.5.1'
b2e59c9 @evgeny-goldin Gradle 1.0-m4 adaptation
authored
14 groovyVersion = '1.8.1'
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
15 springVersion = '2.5.6'
16 antVersion = '1.8.2'
17 gcontractsVersion = '1.2.4'
b2e59c9 @evgeny-goldin Gradle 1.0-m4 adaptation
authored
18 spockVersion = '0.5-groovy-1.8'
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
19 junitVersion = '4.8.2'
20 gradlePluginsVersion = '0.1-RC3'
21 coberturaPluginUrl = 'https://github.com/valkolovos/gradle_cobertura/raw/master/ivy'
22 repoUrl = 'http://evgeny-goldin.org/artifactory/repo/'
23
24 repositories {
25
26 mavenRepo urls: repoUrl
27 add( new org.apache.ivy.plugins.resolver.URLResolver()) {
28 name = 'cobertura'
29 addArtifactPattern "$coberturaPluginUrl/[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
30 addIvyPattern "$coberturaPluginUrl/[organization]/[module]/[revision]/ivy.xml"
31 }
32 }
33
34 dependencies {
35 classpath "com.goldin.plugins:gradle:$gradlePluginsVersion",
36 "org.codehaus.groovy:groovy-all:$groovyVersion",
37 "junit:junit:$junitVersion",
38 "org.apache.ant:ant:$antVersion"
39 classpath ( 'gradle_cobertura:gradle_cobertura:1.0-rc4' ) { exclude module: 'groovy' }
40 }
41 }
42
43 allprojects {
44
8168407 @evgeny-goldin Back to Gradle 1.0-m3
authored
45 apply plugin: 'idea'
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
46 apply plugin: 'groovy'
47 apply plugin: 'about'
48 apply plugin: 'duplicates'
49 apply plugin: com.orbitz.gradle.cobertura.CoberturaPlugin
50
206766f @evgeny-goldin codenarc.txt => codenarc.groovy
authored
51 codenarcRuleSetFiles = [ 'codenarc.groovy' ]
02a2375 @evgeny-goldin CodeNarc ruleset - inheritance and cleanup
authored
52 codenarcPriority3Violations = 2
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
53 apply from: 'https://raw.github.com/evgeny-goldin/gradle-plugins/master/src/main/groovy/CodeNarc.gradle'
54
3c7dad6 @evgeny-goldin defaultTasks 'clean', 'codenarc', 'build'
authored
55 defaultTasks 'clean', 'codenarc', 'build'
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
56
57 group = 'com.goldin.teamcity'
58 version = '0.1-RC4'
59 sourceCompatibility = 1.6
60 targetCompatibility = 1.6
61 toolReportsDir = new File(( File ) project.buildDir, 'reports' )
62
63 repositories { mavenRepo urls: repoUrl }
64 about { dumpDependencies = true }
65 duplicates { configurations = ( System.getProperty( 'duplicates' ) ?: 'runtime' ).split( ',' )*.trim()
66 verbose = true }
67 test { testReportDir = new File(( File ) toolReportsDir, 'unit-tests' ) }
8168407 @evgeny-goldin Back to Gradle 1.0-m3
authored
68
69 ideaProject {
70 javaVersion = '1.6.0_26'
71 }
72 ideaModule {
73 downloadSources = true
74 downloadJavadoc = true
75 }
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
76 }
77
78
79 subprojects {
80
81 File teamCityDir = new File( System.getProperty( 'teamCityDir' ) ?: System.getProperty( 'user.home' ) + '/app/java/teamcity' )
82 String appName = System.getProperty( 'teamCityAppName' ) ?: 'ROOT'
83 File destinationZip = new File(( File ) project.buildDir, "${project.name}.zip" )
84 Set<String> apiPatterns = [ '**/api/**' ]
85
86 configurations {
87 provided
88 compile { extendsFrom provided }
89 }
90
91 dependencies {
92 groovy "org.codehaus.groovy:groovy-all:$groovyVersion"
93 provided "jetbrains:teamcity-openapi:$teamCityVersion",
94 "jetbrains:teamcity-openapi.util:$teamCityVersion",
95 "org.springframework:spring-webmvc:$springVersion",
96 'org.jdom:jdom:1.1', // Configuration reading
97 'javax.servlet:servlet-api:2.5'
98 compile ( "org.gcontracts:gcontracts-core:$gcontractsVersion" ) { exclude group: 'junit' }
99 compile ( 'net.sf.json-lib:json-lib:2.4:jdk15' ) { exclude group: 'commons-collections' }
b2e59c9 @evgeny-goldin Gradle 1.0-m4 adaptation
authored
100 testCompile ( "org.spockframework:spock-core:$spockVersion" ){ exclude group: 'org.codehaus.groovy' }
101 testCompile "org.spockframework:spock-spring:$spockVersion",
9c488d4 @evgeny-goldin CodeNarc upgrade and fixes
authored
102 "org.springframework:spring-test:$springVersion",
103 "org.apache.ant:ant:$antVersion",
104 "junit:junit:$junitVersion",
105 'commons-collections:commons-collections:3.2.1'
106 }
107
108 cobertura {
109 coverageSourceDirs << project.sourceSets.main.groovy.srcDirs
110 coverageReportDir = new File(( File ) toolReportsDir, 'cobertura' )
111 }
112
113
114 /**
115 * Default compilation options
116 */
117 tasks.withType( Compile ) {
118 options.debug = true
119 options.compilerArgs << '-Xlint:all'
120 }
121
122 /**
123 * Compiles API sources
124 */
125 task compileGroovyApi ( type: GroovyCompile, dependsOn: duplicates ) {
126 description = 'Compiles API sources.'
127 classpath = compileGroovy.classpath
128 source = compileGroovy.source
129 destinationDir = compileGroovy.destinationDir
130 includes = apiPatterns
131 }
132
133 /**
134 * Compiles implementation sources
135 */
136 task compileGroovyImpl ( type: GroovyCompile, dependsOn: compileGroovyApi ) {
137 description = 'Compiles implementation sources.'
138 classpath = compileGroovy.classpath
139 source = compileGroovy.source
140 destinationDir = compileGroovy.destinationDir
141 excludes = apiPatterns
142 }
143
144 /**
145 * Assembles API jar
146 */
147 task assembleApi( type: Jar, dependsOn: compileGroovyApi ) {
148 description = 'Assembles API jar.'
149 appendix = 'api'
150 includes = apiPatterns
151 from compileGroovyApi.destinationDir
152 }
153
154 /**
155 * Assembles implementation jar
156 */
157 task assembleImpl( type: Jar, dependsOn: [ classes, compileGroovyImpl ] ) {
158 description = 'Assembles implementation jar.'
159 appendix = 'impl'
160 excludes = apiPatterns + [ 'teamcity-plugin.xml', 'teamcity-plugin-descriptor.xsd' ]
161 from compileJava.destinationDir
162 from processResources.destinationDir
163 from compileGroovyImpl.destinationDir
164 }
165
166 /**
167 * Creates plugin Zip archive
168 */
169 task assemblePlugin( dependsOn: [ assembleApi, assembleImpl ] ) {
170
171 description = 'Creates plugin Zip archive.'
172
173 doFirst {
174 File tempFile = File.createTempFile( project.name, null )
175 tempFile.write( file( 'src/main/resources/teamcity-plugin.xml' ).text.
176 replaceAll( '@name@', project.name ).
177 replaceAll( '@version@', project.version ))
178
179 /**
180 * Copying all required libraries except provided ones by TeamCity server
181 */
182 File compileLibs = new File(( File ) project.buildDir, 'compile-libs' )
183
184 ( configurations.compile.files - configurations.provided.files ).each {
185 File file -> ant.copy( file: file, todir: compileLibs )
186 }
187
188 /**
189 * Creating plugin Zip archive
190 */
191 ant.zip( destfile: destinationZip ) {
192 zipfileset( file: tempFile, fullpath: 'teamcity-plugin.xml' )
193 zipfileset( file: assembleApi.archivePath, prefix : 'server' )
194 zipfileset( file: assembleImpl.archivePath, prefix : 'server' )
195 zipfileset( dir: compileLibs, prefix : 'server' )
196 }
197
198 assert tempFile.delete()
199 }
200 }
201
202 task compileGroovy ( overwrite: true, dependsOn: [ compileGroovyApi, compileGroovyImpl ] )
203 task assemble ( overwrite: true, dependsOn: [ assembleApi, assembleImpl ] )
204 build.dependsOn( duplicates, assemblePlugin )
205
206
207 /**
208 * Deploys plugin Zip to TeamCity instance
209 */
210 task deploy() {
211 description = 'Deploys plugin Zip to TeamCity instance.'
212
213 doFirst {
214 assert destinationZip.isFile() && teamCityDir.isDirectory()
215
216 def zipPath = "webapps/$appName/WEB-INF/plugins/${project.name}.zip"
217 def tcDelete = {
218 boolean deleteDir, Object[] args ->
219 args.each {
220 def file = new File( teamCityDir, ( String ) it )
221 // Delete file or whole directory
222 if ( deleteDir ){
223 project.delete( file )
224 }
225 // Delete directory files only but keep the directory intact
226 // (helpful when user edits or views some of the files, which locks the directory)
227 else if ( file.isDirectory()) {
228 file.eachFile { File f -> project.delete( f ) }
229 }
230 }
231 }
232
233 tcDelete( true, zipPath, "webapps/$appName/WEB-INF/plugins/.unpacked/${project.name}",
234 "work/Catalina/localhost/_/TC_${project.name}" )
235
236 tcDelete( false, "webapps/$appName/plugins/${project.name}" )
237
238 ant.copy( file: destinationZip, tofile: new File( teamCityDir, zipPath ))
239 }
240 }
241
242 /**
243 * Copies static resources to TeamCity instance
244 */
245 task copy () {
246 description = 'Copies static resources to TeamCity instance.'
247 def destinationDir = new File( teamCityDir, "webapps/$appName/plugins/${project.name}" )
248 def sourceDir = new File(( File ) project.projectDir, 'src/main/resources/buildServerResources' )
249
250 doFirst {
251 assert sourceDir.isDirectory() && destinationDir.isDirectory()
252
253 ant {
254 copy ( todir : destinationDir, overwrite : true ) { fileset( dir : sourceDir ) }
255 touch() { fileset( dir : destinationDir ) }
256 }
257 }
258 }
bfa072f @evgeny-goldin Gradle: separation to allprojects{ .. } and subprojects{ .. }
authored
259 }
Something went wrong with that request. Please try again.