1/*
2 * Copyright (C) 2017 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
17apply plugin: 'java'
18apply plugin: 'org.anarres.jarjar'
19apply plugin: 'maven'
20
21ext {
22    flatbuffersDir = '../../flatbuffers'
23    noDocs = true
24}
25
26buildscript {
27    repositories {
28        maven { url '../../../prebuilts/tools/common/m2/repository' }
29    }
30
31    dependencies {
32        classpath 'org.anarres.jarjar:jarjar-gradle:1.0.0'
33    }
34}
35
36sourceSets {
37    main {
38        java.srcDirs = ['src/java', "${flatbuffersDir}/java"]
39    }
40}
41
42def tmpJarDir = new File(buildDir, "tmpjar")
43def jarName = "noto-emoji-compat-java"
44
45task createFatJar(type: Jar) {
46    // create a fat jar that includes FlatBuffers classes
47    archiveName = "${jarName}-all.jar"
48    destinationDir = tmpJarDir
49    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
50    with jar {
51        archiveName = "${jarName}-base.jar"
52        destinationDir = tmpJarDir
53    }
54}
55
56task repackage(type: Copy, dependsOn: createFatJar) {
57    from jarjar.repackage {
58        from files("${tmpJarDir}/${jarName}-all.jar")
59        classRename 'com.google.flatbuffers.**', 'android.support.text.emoji.flatbuffer.@1'
60        destinationName "${jarName}-repacked.jar"
61    }
62    into tmpJarDir
63}
64
65task repackageJar(type: Jar, dependsOn: repackage) {
66    archiveName = "${jarName}.jar"
67    from zipTree("${tmpJarDir}/${jarName}-repacked.jar")
68}
69
70configurations {
71    parser
72}
73
74artifacts {
75    archives repackageJar
76    parser repackageJar
77}
78
79