-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
231 lines (185 loc) · 10.1 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
buildscript {
repositories {
// The plugin depends on the graphql-maven-plugin, whose snapshot versions are on the local maven repository.
// So, for development reason, we need to access to the local maven repository. It's useless for standard use of the plugin
mavenLocal()
mavenCentral()
}
dependencies {
// The version number is not used in this multi-module project: the included build of graphql-gradle-plugin
// will replace this declaration. But this dummy declaration is needed!
//
// Of course, for a real use of the plugin in your project, you'll have to replace by the last plugin's version,
// or better: put this version number in the gradle.properties file, to use it for both the plugin and the dependencies version
classpath 'com.graphql-java-generator:graphql-gradle-plugin:dummy'
classpath 'com.graphql-java-generator:graphql-gradle-plugin3:dummy'
}
}
plugins {
// Let's set the asciidoctor version for the docs module
id 'org.asciidoctor.convert' version '1.5.6' apply false
// The GraphQL plugin is activated here only to check its version
id 'com.graphql-java-generator.graphql-gradle-plugin'
id 'com.graphql-java-generator.graphql-gradle-plugin3'
}
// Let's get the group and version for this project
//apply from: 'graphql-gradle-plugin/gradle.properties'
def graphQLplugin = getPlugins().getPlugin('com.graphql-java-generator.graphql-gradle-plugin')
if (graphQLplugin == null) {
throw new ProjectConfigurationException("[Internal error] The GraphQL plugin should have been added to the main build")
}
def graphQLplugin3 = getPlugins().getPlugin('com.graphql-java-generator.graphql-gradle-plugin3')
if (graphQLplugin3 == null) {
throw new ProjectConfigurationException("[Internal error] The GraphQL plugin 3 should have been added to the main build")
}
println "graphQLplugin version is " + graphQLplugin.getVersion()
println "graphQLplugin3 version is " + graphQLplugin3.getVersion()
println "project version is ${project.version}"
if (graphQLplugin.getVersion() != "${project.version}") {
throw new GradleException(
"The plugin version and the project version should be identical, but plugin version is '"
+ graphQLplugin.getVersion()+ "' whereas the project version is '${project.version}'")
}
if (graphQLplugin3.getVersion() != "${project.version}") {
throw new GradleException(
"The plugin3 version and the project version should be identical, but plugin version is '"
+ graphQLplugin3.getVersion()+ "' whereas the project version is '${project.version}'")
}
subprojects {
// The '-parameters' compiler parameter allows to keep the parameter names in the generated code. It's useful for some tests.
// It has no impact on the plugin, as it is in a separate build.
tasks.withType(JavaCompile) {
options.compilerArgs << '-parameters'
}
/**
* For samples project, we add the copySamplesFromMavenPlugin task.
*
* This tasks allows to copy the code (main and test, java and resources) from the maven module of the same name into the gradle one.
* This allow to test the gradle plugin in the same way, as the maven plugin is.
*/
if (project.name.contains('samples') && System.properties['graphqlGradlePlugin.graphqlMavenPluginProject.path'] != null) {
task cleanSamplesCode() {
group = "Preparation"
description = "Delete the src folder (to allow fresh copy of the sources from the GraphQL maven sample code)"
// The action for this task is to delete the src folder
doLast {
delete 'src'
}
}
task copySamplesFromMavenPlugin(type: Copy) {
group = "Preparation"
description = "Copy the sources from the GraphQL maven plugin to the Gradle plugin"
doLast {
println "copy from: " + System.properties['graphqlGradlePlugin.graphqlMavenPluginProject.path'] +'/graphql-maven-plugin-samples/' + project.name.replace('gradle', 'maven')
println "copy into: ${project.projectDir}"
}
// Please set the systemProp.graphqlGradlePlugin.graphqlMavenPluginProject.path in the gradle.properties to the
// full path for the graphql-maven-plugin-project folder
// OR IGNORE IF YOU JUST BUILD THE GRADLE PLUGIN as a standalone
//
// Let's the source files from the graphql-maven-plugin-samples-XXX folder into the current project
from(System.properties['graphqlGradlePlugin.graphqlMavenPluginProject.path'] +'/graphql-maven-plugin-samples/' + project.name.replace('gradle', 'maven')) {
include "/src/**"
}
into "${project.projectDir}"
dependsOn cleanSamplesCode
mustRunAfter cleanSamplesCode
}
}
}
task cleanPlugin3Code() {
group = 'Preparation'
description = "Delete the graphql-gradle-plugin3/src folder (to allow fresh copy of the sources from the graphql-gradle-plugin's code)"
// The action for this task is to delete the src folder
doLast {
delete 'graphql-gradle-plugin3/src'
}
}
/**
* This task copies the code and dependencies version (in the gradle.properties file) from this project into the graphql-gradle-plugin3 folder
*/
task copyPluginCodeToPlugin3(type: Copy) {
group = 'Preparation'
description = 'Copy the plugin code from the graphql-gradle-plugin to the graphql-gradle-plugin3 folder'
doLast {
println 'Coping the src folder (and gradle.properties) from graphql-gradle-plugin to graphql-gradle-plugin3'
}
from('graphql-gradle-plugin') {
include "gradle.properties"
include "src/**"
}
into 'graphql-gradle-plugin3'
dependsOn cleanPlugin3Code
mustRunAfter cleanPlugin3Code
}
task cleanAll {
dependsOn clean
dependsOn(gradle.includedBuild('graphql-gradle-plugin').task(':clean'))
dependsOn(gradle.includedBuild('graphql-gradle-plugin3').task(':clean'))
}
task publishPlugins {
dependsOn(gradle.includedBuild('graphql-gradle-plugin').task(':publishPlugins'))
dependsOn(gradle.includedBuild('graphql-gradle-plugin3').task(':publishPlugins'))
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// TASKS THAT STARTS AND STOPS THE GRAPHQL SERVERS TO ALLOW INTEGRATION TESTS ////////
////// This part includes the dependencies for the other tasks ////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Let's import the custom plugin we defined in buildSrc of the root project
import com.graphql_java_generator.gradle_task.StartApp
import com.graphql_java_generator.gradle_task.StopApp
gradle.sharedServices.registerIfAbsent("startApp", com.graphql_java_generator.gradle_task.ProcessesService.class, service -> {/*No action*/})
task startAllGraphQLCasesServer(type: StartApp) {
// Let's start the server that matches the current client project
jarFile = file("graphql-gradle-plugin-samples-allGraphQLCases-server/build/libs/graphql-gradle-plugin-samples-allGraphQLCases-server-${project.version}.jar")
url = 'http://localhost:8180/helloworld.html'
// The next lines insures that the relevant server project is built before starting the integration test from this client module.
dependsOn ":graphql-gradle-plugin-samples-allGraphQLCases-server:bootJar"
// The stopWebApp must be attached here. And must run after tests
finalizedBy 'stopAllGraphQLCasesServer'
}
task stopAllGraphQLCasesServer(type: StopApp) {
// The line blow is executed during configuration phase. So the process is unknown.
// We just define the Task object. The StopApp task will read the process id at execution time
startAppTaskPath = tasks["startAllGraphQLCasesServer"].path
// The stopWebApp is attached to startWebApp, and must run after tests
dependsOn 'startAllGraphQLCasesServer'
mustRunAfter ":graphql-gradle-plugin-samples-allGraphQLCases-client:test"
mustRunAfter ":graphql-gradle-plugin-samples-Forum-client:test"
}
task startForumServer(type: StartApp) {
// Let's start the server that matches the current client project
jarFile = file("graphql-gradle-plugin-samples-Forum-server/build/libs/graphql-gradle-plugin-samples-Forum-server-${project.version}.jar")
url = 'http://localhost:8182/graphiql'
// The next lines insures that the relevant server project is built before starting the integration test from this client module.
dependsOn ":graphql-gradle-plugin-samples-Forum-server:bootJar"
// The stopForumServer must be attached here. And must run after tests
finalizedBy 'stopForumServer'
}
task stopForumServer(type: StopApp) {
// The line blow is executed during configuration phase. So the process is unknown.
// We just define the Task object. The StopApp task will read the process id at execution time
startAppTaskPath = tasks["startForumServer"].path
// The stopForumServer is attached to startForumServer, and must run after tests
dependsOn 'startForumServer'
mustRunAfter ":graphql-gradle-plugin-samples-allGraphQLCases-client:test"
mustRunAfter ":graphql-gradle-plugin-samples-Forum-client:test"
}
task startAuthorizationServer(type: StartApp) {
// Let's start the server that matches the current client project
jarFile = file("graphql-gradle-plugin-samples-OAuth-authorization-server/build/libs/graphql-gradle-plugin-samples-OAuth-authorization-server-${project.version}.jar")
url = 'http://localhost:8181/helloworld.html'
// The next lines insures that the relevant server project is built before starting the integration test from this client module.
dependsOn ":graphql-gradle-plugin-samples-OAuth-authorization-server:bootJar"
// The stopWebApp must be attached here. And must run after tests
finalizedBy 'stopAuthorizationServer'
}
task stopAuthorizationServer(type: StopApp) {
// The line blow is executed during configuration phase. So the process is unknown.
// We just define the Task object. The StopApp task will read the process id at execution time
startAppTaskPath = tasks["startAuthorizationServer"].path
// The stopWebApp is attached to startWebApp, and must run after tests
dependsOn 'startAuthorizationServer'
mustRunAfter ":graphql-gradle-plugin-samples-allGraphQLCases-client:test"
mustRunAfter ":graphql-gradle-plugin-samples-Forum-client:test"
}