File: build.gradle

package info (click to toggle)
grpc-java 1.41.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,884 kB
  • sloc: java: 203,784; xml: 1,224; sh: 1,221; cpp: 1,158; makefile: 40; python: 40
file content (167 lines) | stat: -rw-r--r-- 5,948 bytes parent folder | download | duplicates (2)
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
// Copyright 2017 The gRPC 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.

buildscript {
    // Configuration for building
    repositories {
        maven { // The google mirror is less flaky than mavenCentral()
            url "https://maven-central.storage-download.googleapis.com/maven2/" }
    }
    dependencies {
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.3.0'
        classpath 'com.squareup.okhttp:okhttp:2.7.4'
    }
}

plugins {
    id "java"
    id "war"
}

description = 'gRPC: gae interop testing (jdk8)'

repositories {
    // repositories for Jar's you access in your code
    mavenLocal()
    maven { // The google mirror is less flaky than mavenCentral()
        url "https://maven-central.storage-download.googleapis.com/maven2/" }
}

apply plugin: 'com.google.cloud.tools.appengine'  // App Engine tasks

dependencies {
    providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
    runtimeOnly 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
    implementation project(':grpc-netty')
    implementation project(":grpc-stub")
    implementation (project(':grpc-interop-testing')) {
        // Avoid grpc-netty-shaded dependency
        exclude group: 'io.grpc', module: 'grpc-alts'
        exclude group: 'io.grpc', module: 'grpc-xds'
    }
    implementation libraries.junit
    implementation libraries.protobuf
    runtimeOnly libraries.netty_tcnative
}

compileJava {
    // Disable "No processor claimed any of these annotations: org.junit.Ignore"
    options.compilerArgs += ["-Xlint:-processing"]
}

def createDefaultVersion() {
    return new java.text.SimpleDateFormat("yyyyMMdd't'HHmmss").format(new Date())
}

// [START model]
appengine {
    // App Engine tasks configuration
    run {      // local (dev_appserver) configuration (standard environments only)
        port = 8080                 // default
    }

    deploy {
        // deploy configuration
        projectId = 'GCLOUD_CONFIG'
        // default - stop the current version
        stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true
        // default - do not make this the promoted version
        promote = System.getProperty('gaePromote') ?: false
        // Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it
        version = System.getProperty('gaeDeployVersion', createDefaultVersion())
    }
}
// [END model]

group = 'io.grpc'   // Generated output GroupId
version = '1.0-SNAPSHOT'          // Version in generated output

sourceCompatibility = 1.8
targetCompatibility = 1.8

/** Returns the service name. */
String getGaeProject() {
    def stream = new ByteArrayOutputStream()
    exec {
        executable 'gcloud'
        args = [
            'config',
            'get-value',
            'project'
        ]
        standardOutput = stream
    }
    return stream.toString().trim()
}

String getService(java.nio.file.Path projectPath) {
    Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile())
    if (xml.service.isEmpty()) {
        return "default"
    } else {
        return xml.service.text()
    }
}

String getAppUrl(String project, String service, String version) {
    return "http://${version}.${service}.${project}.appspot.com"
}

task runInteropTestRemote(dependsOn: 'appengineDeploy') {
    doLast {
        // give remote app some time to settle down
        sleep(20000)

        def appUrl = getAppUrl(
                getGaeProject(),
                getService(project.getProjectDir().toPath()),
                appengine.deploy.version)
        logger.log(LogLevel.INFO, "the appURL=" + appUrl)
        def client = new com.squareup.okhttp.OkHttpClient()
        // The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
        client.setReadTimeout(30, java.util.concurrent.TimeUnit.SECONDS)
        def request = new com.squareup.okhttp.Request.Builder()
                .url("${appUrl}/long_lived_channel?jdk8").build()
        def result1 = client.newCall(request).execute()
        def result2 = client.newCall(request).execute()
        if (result1.code() != 200 || result2.code() != 200) {
            throw new GradleException("Unable to reuse same channel across requests")
        }

        // The test suite can take a while to run
        client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES)
        // The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
        def interopRequest = new com.squareup.okhttp.Request.Builder()
                .url("${appUrl}/?jdk8").build()

        // Retry in case GAE is slow and times out
        int maxRetries = 5
        String result = null
        Throwable caught = null
        for (int attempt = 0; attempt < maxRetries; attempt++) {
            try {
                def response = client.newCall(interopRequest).execute()
                result = response.body().string()
                project.println(result)
                if (response.code() == 200) {
                    return
                }
            } catch (Throwable t) {
                caught = t
                logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t)
            }
        }
        throw new GradleException("Interop test failed:\nthrowable:${caught}")
    }
}