aboutsummaryrefslogtreecommitdiff
path: root/alts/build.gradle
blob: 82454bf903069bc1f14e3e69548daf37d01c57b8 (plain)
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
plugins {
    id "java-library"
    id "maven-publish"

    id "com.github.johnrengelman.shadow"
    id "com.google.protobuf"
    id "ru.vyarus.animalsniffer"
}

description = "gRPC: ALTS"

dependencies {
    api project(':grpc-core')
    implementation project(':grpc-auth'),
            project(':grpc-grpclb'),
            project(':grpc-protobuf'),
            project(':grpc-stub'),
            libraries.protobuf.java,
            libraries.conscrypt,
            libraries.guava.jre, // JRE required by protobuf-java-util from grpclb
            libraries.google.auth.oauth2Http
    def nettyDependency = implementation project(':grpc-netty')
    compileOnly libraries.javax.annotation

    shadow configurations.implementation.getDependencies().minus(nettyDependency)
    shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')

    testImplementation project(':grpc-testing'),
            testFixtures(project(':grpc-core')),
            project(':grpc-testing-proto'),
            libraries.guava,
            libraries.junit,
            libraries.mockito.core,
            libraries.truth

    testImplementation (libraries.guava.testlib) {
        exclude group: 'junit', module: 'junit'
    }
    testRuntimeOnly libraries.netty.tcnative,
            libraries.netty.tcnative.classes
    testRuntimeOnly (libraries.netty.transport.epoll) {
        artifact {
            classifier = "linux-x86_64"
        }
    }
    signature libraries.signature.java
}

configureProtoCompilation()

import net.ltgt.gradle.errorprone.CheckSeverity

[tasks.named("compileJava"), tasks.named("compileTestJava")]*.configure {
    // protobuf calls valueof. Will be fixed in next release (google/protobuf#4046)
    options.compilerArgs += [
        "-Xlint:-deprecation"
    ]
    // ALTS returns a lot of futures that we mostly don't care about.
    options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF)
}

tasks.named("javadoc").configure {
    exclude 'io/grpc/alts/internal/**'
    exclude 'io/grpc/alts/Internal*'
}

tasks.named("jar").configure {
    // Must use a different archiveClassifier to avoid conflicting with shadowJar
    archiveClassifier = 'original'
}

// We want to use grpc-netty-shaded instead of grpc-netty. But we also want our
// source to work with Bazel, so we rewrite the code as part of the build.
tasks.named("shadowJar").configure {
    archiveClassifier = null
    dependencies {
        exclude(dependency {true})
    }
    relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty'
    relocate 'io.netty', 'io.grpc.netty.shaded.io.netty'
}

publishing {
    publications {
        maven(MavenPublication) {
            // We want this to throw an exception if it isn't working
            def originalJar = artifacts.find { dep -> dep.classifier == 'original'}
            artifacts.remove(originalJar)

            pom.withXml {
                def dependenciesNode = new Node(null, 'dependencies')
                project.configurations.shadow.allDependencies.each { dep ->
                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', dep.group)
                    dependencyNode.appendNode('artifactId', dep.name)
                    dependencyNode.appendNode('version', dep.version)
                    dependencyNode.appendNode('scope', 'compile')
                }
                asNode().dependencies[0].replaceNode(dependenciesNode)
            }
        }
    }
}