Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | buildscript { |
| 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 Dorokhine | fc49cb4 | 2020-04-06 16:17:09 -0700 | [diff] [blame] | 27 | classpath('org.anarres.jarjar:jarjar-gradle:1.0.1') |
Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | |
| 31 | apply plugin: 'java-library' |
| 32 | apply plugin: 'com.google.protobuf' |
Alexander Dorokhine | fc49cb4 | 2020-04-06 16:17:09 -0700 | [diff] [blame] | 33 | apply plugin: 'org.anarres.jarjar' |
Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 34 | apply plugin: 'idea' |
| 35 | |
| 36 | sourceSets { |
| 37 | main { |
| 38 | proto { |
Alexander Dorokhine | 0647e78 | 2020-06-09 16:11:53 -0700 | [diff] [blame] | 39 | srcDir '../proto' |
Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 40 | include '**/*.proto' |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
Alexander Dorokhine | fc49cb4 | 2020-04-06 16:17:09 -0700 | [diff] [blame] | 45 | compileJava { |
| 46 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 47 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 48 | } |
| 49 | |
Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 50 | dependencies { |
Alexander Dorokhine | fc49cb4 | 2020-04-06 16:17:09 -0700 | [diff] [blame] | 51 | implementation('com.google.protobuf:protobuf-javalite:3.10.0') |
Alexander Dorokhine | eb39d4d | 2020-04-06 16:10:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | protobuf { |
| 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 Dorokhine | fc49cb4 | 2020-04-06 16:17:09 -0700 | [diff] [blame] | 69 | |
| 70 | jarjar.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 | |
| 78 | configurations { |
| 79 | jarjarConf |
| 80 | } |
| 81 | |
| 82 | artifacts { |
| 83 | jarjarConf(jarjarTask.destinationPath) { |
| 84 | name 'icing-java-jarjar' |
| 85 | type 'jar' |
| 86 | builtBy jarjarTask |
| 87 | } |
| 88 | } |