1
- /*
2
- * Copyright 2010 the original author or authors.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import org.springframework.build.Version
17
-
18
- // -----------------------------------------------------------------------------
19
- // Main gradle build file for Spring Social GitHub
20
- // @author Chris Beams
21
- // @author Craig Walls
22
- // -----------------------------------------------------------------------------
23
-
24
- // -----------------------------------------------------------------------------
25
- // Configuration for the root project
26
- // -----------------------------------------------------------------------------
27
- description = ' Spring Social GitHub'
28
- abbreviation = ' SOCIAL-GITHUB'
29
-
30
- apply plugin : ' base'
31
- apply plugin : ' idea'
32
-
33
- def buildSrcDir = " $rootDir /buildSrc"
34
- apply from : " $buildSrcDir /wrapper.gradle"
35
- apply from : " $buildSrcDir /maven-root-pom.gradle"
36
-
37
- // -----------------------------------------------------------------------------
38
- // Configuration for all projects including this one (the root project)
39
- //
40
- // @see settings.gradle for list of all subprojects
41
- // -----------------------------------------------------------------------------
42
- allprojects {
43
- // group will translate to groupId during pom generation and deployment
44
- group = ' org.springframework.social'
45
-
46
- // version will be used in maven pom generation as well as determining
47
- // where artifacts should be deployed, based on release type of snapshot,
48
- // milestone or release.
49
- // @see org.springframework.build.Version under buildSrc/ for more info
50
- // @see gradle.properties for the declaration of this property.
51
- version = new Version (springSocialGitHubVersion)
52
-
53
- // default set of maven repositories to be used when resolving dependencies
1
+ buildscript {
54
2
repositories {
55
- mavenRepo urls : ' http://maven.springframework .org/release'
56
- mavenRepo urls : ' http://maven.springframework.org/milestone '
57
- mavenRepo urls : ' http://maven.springframework.org/snapshot '
58
- mavenCentral()
3
+ maven { url ' http://repo.springsource .org/plugins- release' }
4
+ }
5
+ dependencies {
6
+ classpath ' org.springframework.build.gradle:docbook-reference-plugin:0.1.3 '
59
7
}
60
8
}
61
9
10
+ configure(allprojects) {
11
+ apply plugin : ' java'
12
+ apply plugin : ' eclipse'
13
+ apply plugin : ' idea'
62
14
63
- // -----------------------------------------------------------------------------
64
- // Create collections of subprojects - each will receive their own configuration
65
- // - all subprojects that start with spring-social-* are 'java projects'
66
- // - documentation-related subprojects are not collected here
67
- //
68
- // @see configure(*) sections below
69
- // -----------------------------------------------------------------------------
70
-
71
- javaprojects = subprojects. findAll { project ->
72
- project. path. startsWith(' :spring-social-' )
73
- }
74
-
75
- // -----------------------------------------------------------------------------
76
- // Configuration for all java subprojects
77
- // -----------------------------------------------------------------------------
78
- configure(javaprojects) {
79
-
80
- apply plugin : ' java' // tasks for conventional java lifecycle
81
- apply plugin : ' maven' // `gradle install` to push jars to local .m2 cache
82
- apply plugin : ' eclipse' // `gradle eclipse` to generate .classpath/.project
83
- apply plugin : ' idea' // `gradle idea` to generate .ipr/.iml
84
-
85
- // set up dedicated directories for jars and source jars.
86
- // this makes it easier when putting together the distribution
87
- libsBinDir = new File (libsDir, ' bin' )
88
- libsSrcDir = new File (libsDir, ' src' )
89
-
90
- // add tasks for creating source jars and generating poms etc
91
- apply from : " $buildSrcDir /maven-deployment.gradle"
15
+ group = ' org.springframework.social'
92
16
93
- // add tasks for finding and publishing .xsd files
94
- apply from : " $b uildSrcDir /schema-publication.gradle "
17
+ sourceCompatibility = 1.5
18
+ targetCompatibility = 1.5
95
19
96
- springSocialVersion = ' 1.0.0.BUILD-SNAPSHOT'
20
+ springSocialVersion = ' 1.0.0.BUILD-SNAPSHOT'
97
21
jacksonVersion = ' 1.9.2'
98
22
junitVersion = ' 4.8.2'
99
23
mockitoVersion = ' 1.8.5'
100
24
springVersion = ' 3.1.0.RELEASE'
101
25
102
- sourceSets {
103
- main {
104
- resources {
105
- srcDirs = [ ' src/main/java ' ]
106
- }
107
- }
108
- test {
109
- resources {
110
- srcDirs = [ ' src/test/java ' ]
111
- }
112
- }
26
+ [compileJava, compileTestJava] * . options * . compilerArgs = [ ' -Xlint:none ' ]
27
+
28
+ sourceSets . test . resources . srcDirs = [ ' src/test/ resources' , ' src/test/java ' ]
29
+
30
+ test . systemProperty( " java.awt.headless " , " true " )
31
+
32
+ repositories {
33
+ maven { url " http://repo.springsource.org/libs-release " }
34
+ maven { url " http://repo.springsource.org/libs-milestone " }
35
+ maven { url " http://repo.springsource.org/libs-snapshot " }
36
+ maven { url " http://repo.springsource.org/ebr-maven-external " }
113
37
}
114
38
115
- // dependencies that are common across all java projects
116
39
dependencies {
117
40
testCompile " junit:junit:$junitVersion "
118
41
testCompile " org.mockito:mockito-all:$mockitoVersion "
119
42
testCompile " org.springframework:spring-test:$springVersion "
120
43
}
121
44
122
- // enable all compiler warnings (GRADLE-1077)
123
- [compileJava, compileTestJava]* . options* . compilerArgs = [' -Xlint:all' ]
124
-
125
- // generate .classpath files without GRADLE_CACHE variable (GRADLE-1079)
126
- eclipseClasspath. variables = [:]
45
+ // servlet-api (2.5) and tomcat-servlet-api (3.0) classpath entries should not be
46
+ // exported to dependent projects in Eclipse to avoid false compilation errors due
47
+ // to changing APIs across these versions
48
+ eclipse. classpath. file. whenMerged { classpath ->
49
+ classpath. entries. findAll { entry -> entry. path. contains(' servlet-api' ) }* . exported = false
50
+ }
127
51
}
128
52
53
+ configure(subprojects) { subproject ->
54
+ apply from : " ${ rootProject.projectDir} /publish-maven.gradle"
55
+
56
+ jar {
57
+ manifest. attributes[' Implementation-Title' ] = subproject. name
58
+ manifest. attributes[' Implementation-Version' ] = subproject. version
59
+
60
+ from(" ${ rootProject.projectDir} /src/dist" ) {
61
+ include " license.txt"
62
+ include " notice.txt"
63
+ into " META-INF"
64
+ expand(copyright : new Date (). format(' yyyy' ), version : project. version)
65
+ }
66
+ }
129
67
130
- // -----------------------------------------------------------------------------
131
- // Configuration for each individual core java subproject
132
- //
133
- // @see configure(javaprojects) above for general config
134
- // -----------------------------------------------------------------------------
68
+ javadoc {
69
+ options. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel . PROTECTED
70
+ options. author = true
71
+ options. header = project. name
72
+ // options.overview = "${projectDir}/src/main/java/overview.html"
73
+ }
74
+
75
+ task sourcesJar(type : Jar , dependsOn :classes) {
76
+ classifier = ' sources'
77
+ from sourceSets. main. allJava
78
+ }
79
+
80
+ task javadocJar(type : Jar ) {
81
+ classifier = ' javadoc'
82
+ from javadoc
83
+ }
84
+
85
+ artifacts {
86
+ archives sourcesJar
87
+ archives javadocJar
88
+ }
89
+ }
135
90
136
91
project(' spring-social-github' ) {
137
92
description = ' Github API'
@@ -142,12 +97,153 @@ project('spring-social-github') {
142
97
}
143
98
}
144
99
145
- // -----------------------------------------------------------------------------
146
- // Configuration for the docs subproject
147
- // -----------------------------------------------------------------------------
148
- project(' docs' ) {
149
- apply from : " $buildSrcDir /docs.gradle"
100
+ configure(rootProject) {
101
+ description = ' Spring Social GitHub'
102
+
103
+ apply plugin : ' docbook-reference'
104
+
105
+ reference {
106
+ sourceDir = file(' src/reference/docbook' )
107
+ }
108
+
109
+ // don't publish the default jar for the root project
110
+ configurations. archives. artifacts. clear()
111
+
112
+ dependencies { // for integration tests
113
+ }
114
+
115
+ task api(type : Javadoc ) {
116
+ group = ' Documentation'
117
+ description = ' Generates aggregated Javadoc API documentation.'
118
+ title = " ${ rootProject.description} ${ version} API"
119
+ options. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel . PROTECTED
120
+ options. author = true
121
+ options. header = rootProject. description
122
+ options. overview = ' src/api/overview.html'
123
+ options. links(
124
+ ' http://docs.jboss.org/jbossas/javadoc/4.0.5/connector'
125
+ )
126
+ source subprojects. collect { project ->
127
+ project. sourceSets. main. allJava
128
+ }
129
+ destinationDir = new File (buildDir, " api" )
130
+ classpath = files(subprojects. collect { project ->
131
+ project. sourceSets. main. compileClasspath
132
+ })
133
+ maxMemory = ' 1024m'
134
+ }
135
+
136
+ task docsZip(type : Zip ) {
137
+ group = ' Distribution'
138
+ classifier = ' docs'
139
+ description = " Builds -${ classifier} archive containing api and reference " +
140
+ " for deployment at static.springframework.org/spring-social/docs."
141
+
142
+ from(' src/dist' ) {
143
+ include ' changelog.txt'
144
+ }
145
+
146
+ from (api) {
147
+ into ' api'
148
+ }
149
+
150
+ from (reference) {
151
+ into ' reference'
152
+ }
153
+ }
154
+
155
+ task schemaZip(type : Zip ) {
156
+ group = ' Distribution'
157
+ classifier = ' schema'
158
+ description = " Builds -${ classifier} archive containing all " +
159
+ " XSDs for deployment at static.springframework.org/schema."
160
+
161
+ subprojects. each { subproject ->
162
+ def Properties schemas = new Properties ();
163
+
164
+ subproject. sourceSets. main. resources. find {
165
+ it. path. endsWith(' META-INF/spring.schemas' )
166
+ }?. withInputStream { schemas. load(it) }
167
+
168
+ for (def key : schemas. keySet()) {
169
+ def shortName = key. replaceAll(/ http.*schema.(.*).spring-.*/ , ' $1' )
170
+ assert shortName != key
171
+ File xsdFile = subproject. sourceSets. main. resources. find {
172
+ it. path. endsWith(schemas. get(key))
173
+ }
174
+ assert xsdFile != null
175
+ into (shortName) {
176
+ from xsdFile. path
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ task distZip(type : Zip , dependsOn : [docsZip, schemaZip]) {
183
+ group = ' Distribution'
184
+ classifier = ' dist'
185
+ description = " Builds -${ classifier} archive, containing all jars and docs, " +
186
+ " suitable for community download page."
187
+
188
+ baseDir = " ${ project.name} -${ project.version} " ;
189
+
190
+ from(' src/dist' ) {
191
+ include ' readme.txt'
192
+ include ' license.txt'
193
+ include ' notice.txt'
194
+ into " ${ baseDir} "
195
+ expand(copyright : new Date (). format(' yyyy' ), version : project. version)
196
+ }
197
+
198
+ from(zipTree(docsZip. archivePath)) {
199
+ into " ${ baseDir} /docs"
200
+ }
201
+
202
+ from(zipTree(schemaZip. archivePath)) {
203
+ into " ${ baseDir} /schema"
204
+ }
205
+
206
+ subprojects. each { subproject ->
207
+ into (" ${ baseDir} /libs" ) {
208
+ from subproject. jar
209
+ if (subproject. tasks. findByPath(' sourcesJar' )) {
210
+ from subproject. sourcesJar
211
+ }
212
+ if (subproject. tasks. findByPath(' javadocJar' )) {
213
+ from subproject. javadocJar
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ artifacts {
220
+ archives docsZip
221
+ // archives schemaZip
222
+ archives distZip
223
+ }
224
+
225
+ task wrapper(type : Wrapper ) {
226
+ description = ' Generates gradlew[.bat] scripts'
227
+ gradleVersion = ' 1.0-milestone-8a'
228
+ }
229
+
230
+ }
231
+
232
+ task updateRootDocs << {
233
+ copy {
234
+ from ' src/dist'
235
+ into " ${ rootProject.projectDir} "
236
+ include ' notice.txt'
237
+ expand(copyright : new Date (). format(' yyyy' ), version : project. version)
238
+ rename { filename -> ' NOTICE' }
239
+ }
240
+
241
+ copy {
242
+ from ' src/dist'
243
+ into " ${ rootProject.projectDir} "
244
+ include ' license.txt'
245
+ rename { filename -> ' LICENSE' }
246
+ }
150
247
}
151
248
152
- apply from : " $buildSrcDir /dist.gradle"
153
- apply from : " $buildSrcDir /checks.gradle"
249
+ build. dependsOn(' updateRootDocs' )
0 commit comments