Home | History | Annotate | Download | only in emoji-compat
      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 
     17 apply plugin: 'java'
     18 apply plugin: 'org.anarres.jarjar'
     19 apply plugin: 'maven'
     20 
     21 ext {
     22     flatbuffersDir = '../../flatbuffers'
     23     noDocs = true
     24 }
     25 
     26 buildscript {
     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 
     36 sourceSets {
     37     main {
     38         java.srcDirs = ['src/java', "${flatbuffersDir}/java"]
     39     }
     40 }
     41 
     42 def tmpJarDir = new File(buildDir, "tmpjar")
     43 def jarName = "noto-emoji-compat-java"
     44 
     45 task 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 
     56 task 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 
     65 task repackageJar(type: Jar, dependsOn: repackage) {
     66     archiveName = "${jarName}.jar"
     67     from zipTree("${tmpJarDir}/${jarName}-repacked.jar")
     68 }
     69 
     70 configurations {
     71     parser
     72 }
     73 
     74 artifacts {
     75     archives repackageJar
     76     parser repackageJar
     77 }
     78 
     79