-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
261 lines (202 loc) · 9.31 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import java.text.SimpleDateFormat
apply plugin: 'idea'
defaultTasks 'duplicates', 'clean', 'codenarc', 'build', 'install'
ext.codenarcRuleSetFiles = [ "$rootDir/codenarc.groovy" ]
ext.codenarcExtensions = [ '**/*.groovy' ]
ext.codenarcSources = project.subprojects.collect{ Project p -> [ "${ p.projectDir.name }/src/main/groovy",
"${ p.projectDir.name }/src/test/groovy" ]}.flatten()
apply from: 'file:codenarc/CodeNarc.gradle'
apply from: 'file:wrapper.gradle'
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.goldin.plugins.gradle:about:0.3.1',
'com.github.goldin.plugins.gradle:duplicates:0.3.1'
}
}
allprojects {
apply plugin: 'groovy'
repositories { jcenter() }
dependencies {
compile gradleApi(),
'org.gcontracts:gcontracts-core:1.2.12',
'org.codehaus.gpars:gpars:1.1.0',
'com.fasterxml.jackson.core:jackson-databind:2.2.3'
testCompile 'junit:junit:4.11'
testRuntime 'ch.qos.logback:logback-classic:1.0.13'
}
}
idea.project {
jdkName = '1.7'
ipr.withXml { provider -> provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git' }
}
idea.module {
excludeDirs += file( 'out' )
iml.withXml {
provider ->
provider.node.component.first().appendNode( 'orderEntry', [ type : 'library', name : 'Groovy', level: 'application' ])
}
}
task groovydocAll ( type: org.gradle.api.tasks.javadoc.Groovydoc ) {
final groovydocDir = System.getProperty( 'groovydocDir', 'build/groovydoc' )
final d = new Date()
final time = new SimpleDateFormat( "HH:mm '(GMT'Z')'", new Locale( 'en' )).format( d )
final date = new SimpleDateFormat( 'MMMM dd, yyyy', new Locale( 'en' )).format( d )
/**
* http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.javadoc.Groovydoc.html
*/
subprojects*.name.each{ source( "$it/src/main/groovy" ) }
link 'http://www.gradle.org/docs/current/javadoc/', 'org.gradle.'
link 'http://evgeny-goldin.org/javadoc/gcontracts/', 'org.gcontracts.'
link 'http://docs.oracle.com/javase/7/docs/api/', 'java.'
link 'http://evgeny-goldin.org/javadoc/spock/', 'spock.'
docTitle = 'Gradle Plugins ' + project.version
classpath = configurations.compile + project( ':common' ).configurations.compile
groovyClasspath = classpath // http://issues.gradle.org/browse/GRADLE-1391
use = true
destinationDir = file ( groovydocDir + ( project.version.contains( '-SNAPSHOT' ) ? '' : '/' + project.version ))
header = '<a href="http://evgeny-goldin.com/wiki/Gradle_Plugins">evgeny-goldin.com/wiki/Gradle_Plugins</a>'
footer = """
<a href="http://evgeny-goldin.com/">Evgeny Goldin</a>. GrovyDoc generated at $time on $date.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7925869-2']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>""".stripIndent()
doLast { logger.warn( "Done, open file:${ destinationDir.canonicalPath }/index.html" ) }
}
subprojects {
Project p ->
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'about'
apply plugin: 'duplicates'
sourceCompatibility = 1.6
group = 'com.github.goldin.plugins.gradle'
final extraFiles = ( ! p.hasProperty( 'nef' /* no extra files */ ))
clean { delete( "$rootDir/out", "$rootDir/build" ) }
about { includeDependencies = [ 'compile', 'runtime' ]
prefix = '/' }
duplicates { configurations = [ 'compile', 'runtime' ]
verbose = true }
idea.module {
downloadSources = true
downloadJavadoc = false
}
if ( extraFiles ) {
jar {
dependsOn 'about', 'createPom'
from new File(( File ) project.rootProject.projectDir, 'license.txt' )
}
}
/**
* Adding sources and groovydocs
*/
task sourcesJar( type: Jar, dependsOn: classes ) {
onlyIf { extraFiles }
dependsOn 'about'
classifier = 'sources'
from sourceSets.main.allSource
from files( "${ project.rootProject.projectDir }/license.txt" )
}
task groovydocJar( type: Jar, dependsOn: groovydoc ) {
onlyIf { extraFiles }
dependsOn 'about'
classifier = 'javadoc'
from groovydoc.destinationDir
from files( "${ project.rootProject.projectDir }/license.txt" )
}
if ( extraFiles )
{
artifacts {
archives sourcesJar
archives groovydocJar
}
}
task createPom << {
pom {
project {
name 'Gradle Plugins'
packaging 'jar'
description 'Gradle Plugins'
url 'http://evgeny-goldin.com/wiki/Gradle_Plugins'
inceptionYear '2010'
scm {
url 'git@github.com:evgeny-goldin/gradle-plugins.git'
connection 'scm:git:git@github.com:evgeny-goldin/gradle-plugins.git'
developerConnection 'scm:git:git@github.com:evgeny-goldin/gradle-plugins.git'
}
licenses { license { name 'Apache License'; distribution 'repo' }}
developers {
developer {
id 'evgenyg'
name 'Evgeny Goldin'
email 'evgenyg@gmail.com'
url 'http://evgeny-goldin.com'
roles { role 'Developer' }
timezone '+1'
}
}
}
}.writeTo( "$buildDir/pom.xml" )
}
}
project( ':common' ) {
Project p ->
p.dependencies { compile ( 'org.spockframework:spock-core:0.7-groovy-1.8' ) {
exclude group: 'junit'
exclude group: 'org.codehaus.groovy'
}}
}
subprojects.findAll{ Project p -> p.name != 'common' }.each {
Project p ->
p.dependencies { compile project( ':common' )}
p.processResources << {
Copy processResourcesTask ->
final gradleProperties = new File( processResourcesTask.destinationDir, "META-INF/gradle-plugins/${ p.name }.properties" )
updatePropertiesFile( gradleProperties,
validatePropertiesFile( p, gradleProperties ),
[ group: p.group, name: p.name, version : p.version ])
}
}
project( ':teamcity' ) {
idea.module {
excludeDirs += file( 'deploy-teamcity-artifacts/.gradle' )
excludeDirs += file( 'deploy-teamcity-artifacts/build' )
}
}
private Properties validatePropertiesFile( Project p, File gradleProperties )
{
assert gradleProperties
assert gradleProperties.file, "Properties file [$gradleProperties.canonicalPath] is not available"
final properties = new Properties()
gradleProperties.withReader { properties.load( it )}
final String implementationClass = properties[ 'implementation-class' ]
assert implementationClass, "Gradle properties [$gradleProperties.canonicalPath] contain no 'implementation-class' property"
final classFile = new File(( File ) p.compileGroovy.destinationDir,
implementationClass.replace( '.', '/' ) + '.class' )
assert classFile.file, "File [$classFile.canonicalPath] referenced by [$implementationClass] " +
"in properties file [$gradleProperties.canonicalPath] is not available"
properties
}
private void updatePropertiesFile ( File gradleProperties, Properties properties, Map<String, ?> newProperties )
{
assert gradleProperties && gradleProperties.file
assert properties && newProperties
final propertiesNames = properties.keySet()
for ( String newProperty in newProperties.keySet())
{
assert ( ! ( newProperty in (( Set<String> ) propertiesNames ))), \
"Property [$newProperty] already exists in $properties"
properties[ newProperty ] = newProperties[ newProperty ]
}
gradleProperties.withWriter { properties.store( it, null )}
}