-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
164 lines (141 loc) · 5.07 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
plugins {
id 'groovy'
id 'idea'
}
afterEvaluate {
plugins.apply 'xapi-schema'
}
import net.wti.gradle.internal.api.ProjectView
import net.wti.gradle.system.spi.GradleServiceFinder
import org.gradle.internal.jvm.Jvm
group = 'net.wetheinter'
apply from: "$rootDir/gradle/xapi-env.gradle"
version = findProperty('xapiVersion')
tasks.create 'publishRequired', { req ->
allprojects {
def pub = tasks.findByName('xapiPublish')
if (pub) {
req.dependsOn pub
}
}
}
File mvnRepo = new File(rootDir, 'repo')
File indexRoot = new File(rootDir, 'build/xindex')
gradle.beforeProject {
Project p ->
if (p.group != 'net.wetheinter') {
p.logger.info "gradle.beforeProject group was: $p.group"
p.group = 'net.wetheinter'
}
if (p.buildscript.repositories.empty) {
p.buildscript.repositories.maven {
name = 'xapiLocal'
url = new File(rootDir, 'repo')
}
// TODO make this obsolete by priming all external dependencies to xapiLocal
p.buildscript.repositories.mavenCentral()
}
}
gradle.beforeProject {
Project p ->
if (p.group != 'net.wetheinter') {
p.logger.info "allprojects group was $p.group"
p.group = 'net.wetheinter'
}
p.version = findProperty('xapiVersion')
final boolean isModern = p.findProperty('xapiModern') == 'true' ||
(
p.file('gradle.properties').exists() &&
p.file('gradle.properties').text.contains("xapiModern=true")
)
if (isModern) {
p.logger.info("Modern project: {}", p.path)
} else {
p.logger.info("Legacy project: {}", p.path)
p.plugins.apply 'idea'
p.plugins.apply 'xapi-schema'
}
p.repositories {
maven {
name = 'xapiExternal'
File repo = new File("$project.rootDir/repoMvn".toString())
if (!repo.exists()) {
repo = new File("$project.rootDir.parent/xapi/repoMvn".toString())
}
url = repo.toURI()
metadataSources { sources ->
sources.mavenPom()
}
}
mavenCentral()
}
p.with {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
// explicitly empty sourcepath.
// If we want to recompile anything that isn't ours, we'll do so explicitly.
options.sourcepath = files()
}
tasks.withType(Test).configureEach {
Test test ->
test.systemProperty('xapi.mvn.repo', mvnRepo.absolutePath)
if (!test.maxHeapSize) {
test.maxHeapSize = '1G'
}
String compileForTest = "compile${test.name - "test" - "Main"}TestJava"
JavaCompile javac = project.tasks.findByName(compileForTest)
if (javac) {
File metaDir = javac.destinationDir
test.systemProperty('xapi.injector.cache', metaDir.absolutePath)
test.doFirst {
new File(metaDir, 'META-INF/singletons').mkdirs()
new File(metaDir, 'META-INF/instances').mkdirs()
}
} else {
test.logger.info "Could not find $compileForTest in $project.path"
}
}
if (path != ':schema' && !isModern) {
plugins.apply 'xapi-schema'
plugins.apply 'maven-publish'
plugins.apply 'xapi-publish'
tasks.create 'testJar', Jar, {
Jar jar ->
jar.archiveClassifier.set 'test'
jar.from sourceSets.test.output
}
// Gwt.maybeInstall(p)
File tools = Jvm.current().toolsJar
if (tools) {
p.dependencies.add JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME,
p.files(tools)
p.dependencies.add JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME,
p.files(tools)
}
// artifacts {
// testRuntime testJar
// }
}
return
}
}
GradleServiceFinder.getService(project).configureWrapper(project)
idea {
module {
excludeDirs = [mvnRepo, indexRoot] as Set
}
}
tasks.register('projectInfo') {
Task t ->
t.doLast {
t.logger.quiet("Total projects: " + allprojects.size())
// perhaps get some xapi schema stats about realized modules to print here?
}
}
gradle.projectsEvaluated {
project(':base').tasks.named('compileTestJava').configure {
enabled = false
}
}