blob: caaa116663116f3fc172198d04db3e6001406ebd [file] [log] [blame]
Alexander Dorokhineeb39d4d2020-04-06 16:10:36 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17buildscript {
18 boolean unbundleBuild = (new File('unbundled-build')).exists()
19 repositories {
20 maven { url '../../../prebuilts/androidx/external' }
21 if (unbundleBuild) {
22 jcenter()
23 }
24 }
25 dependencies {
26 classpath('gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.8')
Alexander Dorokhinefc49cb42020-04-06 16:17:09 -070027 classpath('org.anarres.jarjar:jarjar-gradle:1.0.1')
Alexander Dorokhineeb39d4d2020-04-06 16:10:36 -070028 }
29}
30
31apply plugin: 'java-library'
32apply plugin: 'com.google.protobuf'
Alexander Dorokhinefc49cb42020-04-06 16:17:09 -070033apply plugin: 'org.anarres.jarjar'
Alexander Dorokhineeb39d4d2020-04-06 16:10:36 -070034apply plugin: 'idea'
35
36sourceSets {
37 main {
38 proto {
39 srcDir '..'
40 include '**/*.proto'
41 }
42 }
43}
44
Alexander Dorokhinefc49cb42020-04-06 16:17:09 -070045compileJava {
46 sourceCompatibility = JavaVersion.VERSION_1_7
47 targetCompatibility = JavaVersion.VERSION_1_7
48}
49
Alexander Dorokhineeb39d4d2020-04-06 16:10:36 -070050dependencies {
Alexander Dorokhinefc49cb42020-04-06 16:17:09 -070051 implementation('com.google.protobuf:protobuf-javalite:3.10.0')
Alexander Dorokhineeb39d4d2020-04-06 16:10:36 -070052}
53
54protobuf {
55 protoc {
56 artifact = 'com.google.protobuf:protoc:3.10.0'
57 }
58
59 generateProtoTasks {
60 all().each { task ->
61 task.builtins {
62 java {
63 option 'lite'
64 }
65 }
66 }
67 }
68}
Alexander Dorokhinefc49cb42020-04-06 16:17:09 -070069
70jarjar.repackage('jarjarTask') {
71 destinationName "icing-java-jarjar.jar"
72 from 'com.google.protobuf:protobuf-javalite:3.10.0'
73 from files(sourceSets.main.output.classesDirs)
74 dependsOn sourceSets.main.output
75 classRename 'com.google.protobuf.**', 'com.google.android.icing.protobuf.@1'
76}
77
78configurations {
79 jarjarConf
80}
81
82artifacts {
83 jarjarConf(jarjarTask.destinationPath) {
84 name 'icing-java-jarjar'
85 type 'jar'
86 builtBy jarjarTask
87 }
88}