-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
137 lines (114 loc) · 4.25 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
/*
* Copyright © 2018 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency
final TEST_FIXTURES_DEPENDENCY_SUFFIX = '-testFixtures'
buildscript {
if (!repositories) {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
}
dependencies {
classpath "io.servicetalk:servicetalk-gradle-plugin-internal:0.2.0-SNAPSHOT"
}
}
// Composite builds do not correctly substitute test fixtures dependencies
// because they target a custom configuration (namely: testFixturesRuntime).
// We work around this problem by replacing test fixtures artifact dependencies
// by module dependencies using the appropriate configuration.
// Note that this workaround may not be required in the future, as the composite
// build feature evolves and improves in Gradle.
ext.replaceTestFixtures = { includedBuild, name ->
def config = includedBuild.configuredBuild.rootProject.configurations.findByName(name)
if (config) {
config.dependencies.findAll { it.name.endsWith TEST_FIXTURES_DEPENDENCY_SUFFIX }.each {
def projectDependency =
new DefaultExternalModuleDependency(
it.group,
it.name.substring(0, it.name.length() - TEST_FIXTURES_DEPENDENCY_SUFFIX.length()),
it.version,
'testFixturesRuntime')
config.dependencies.add(projectDependency)
config.dependencies.remove(it)
}
}
}
gradle.includedBuilds.each {
replaceTestFixtures(it, 'testImplementation')
replaceTestFixtures(it, 'testFixturesImplementation')
}
project.configure(project) {
io.servicetalk.gradle.plugin.internal.ServiceTalkLibraryPlugin.applyIdeaPlugin(gradle.rootProject)
io.servicetalk.gradle.plugin.internal.ServiceTalkLibraryPlugin.applyEclipsePlugin(gradle.rootProject)
io.servicetalk.gradle.plugin.internal.ServiceTalkCorePlugin.applyLicensePlugin(gradle.rootProject)
}
ext.findTasks = { taskName, excludedBuilds = [] ->
gradle.includedBuilds.findAll { !excludedBuilds.contains(it.name) }.collect { it.task(taskName) }
}
// Add tasks for composite:
task clean {
dependsOn gradle.includedBuilds*.task(':clean')
}
task javadoc {
dependsOn gradle.includedBuilds*.task(':javadoc')
}
task 'package' {
dependsOn findTasks(':package', ['servicetalk-examples'])
}
task test {
dependsOn gradle.includedBuilds*.task(':test')
}
task check {
dependsOn gradle.includedBuilds*.task(':check')
}
task build {
dependsOn gradle.includedBuilds*.task(':build')
}
task checkstyle {
dependsOn findTasks(':checkstyle',
['servicetalk-bom-internal', 'servicetalk-examples', 'servicetalk-gradle-plugin-internal'])
}
task pmd {
dependsOn findTasks(':pmd',
['servicetalk-bom-internal', 'servicetalk-examples', 'servicetalk-gradle-plugin-internal'])
}
task spotbugs {
dependsOn findTasks(':spotbugs',
['servicetalk-bom-internal', 'servicetalk-examples', 'servicetalk-gradle-plugin-internal'])
}
task quality {
dependsOn findTasks(':quality',
['servicetalk-bom-internal', 'servicetalk-examples', 'servicetalk-gradle-plugin-internal'])
}
task bintrayUpload {
dependsOn findTasks(':bintrayUpload', ['servicetalk-benchmarks', 'servicetalk-examples'])
}
// Override behavior for existing tasks:
task publish(overwrite: true) {
dependsOn findTasks(':publish', ['servicetalk-benchmarks'])
}
task publishToMavenLocal(overwrite: true) {
dependsOn findTasks(':publishToMavenLocal', ['servicetalk-benchmarks', 'servicetalk-examples'])
}
task license(overwrite: true) {
dependsOn licenseRoot
dependsOn gradle.includedBuilds*.task(':license')
}
task licenseFormat(overwrite: true) {
dependsOn licenseFormatRoot
dependsOn gradle.includedBuilds*.task(':licenseFormat')
}