Ben Gruver | f7ab3f9 | 2012-10-14 22:15:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012, Google Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are |
| 7 | * met: |
| 8 | * |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above |
| 12 | * copyright notice, this list of conditions and the following disclaimer |
| 13 | * in the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * * Neither the name of Google Inc. nor the names of its |
| 16 | * contributors may be used to endorse or promote products derived from |
| 17 | * this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 32 | ext.testAccessorOutputDir = file("${buildDir}/generated-src/accessorTest/java") |
| 33 | ext.testAccessorOutputFile = file("${testAccessorOutputDir}/org/jf/dexlib2/AccessorTypes.java") |
| 34 | |
| 35 | sourceSets { |
| 36 | accessorTest { |
| 37 | java { |
| 38 | srcDir testAccessorOutputDir |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 43 | configurations { |
| 44 | accessorTestGenerator |
Ben Gruver | b76dee7 | 2015-03-16 19:54:57 -0700 | [diff] [blame] | 45 | dx |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Ben Gruver | f7ab3f9 | 2012-10-14 22:15:56 -0700 | [diff] [blame] | 48 | dependencies { |
Ben Gruver | 46cefa3 | 2013-03-03 17:58:02 -0800 | [diff] [blame] | 49 | compile depends.findbugs |
| 50 | compile depends.guava |
Ben Gruver | e2db154 | 2012-10-20 22:58:07 -0700 | [diff] [blame] | 51 | |
Ben Gruver | 46cefa3 | 2013-03-03 17:58:02 -0800 | [diff] [blame] | 52 | testCompile depends.junit |
Ben Gruver | 3587c6f | 2016-08-30 21:15:03 -0700 | [diff] [blame] | 53 | testCompile depends.mockito |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 54 | |
| 55 | accessorTestGenerator project('accessorTestGenerator') |
Ben Gruver | b76dee7 | 2015-03-16 19:54:57 -0700 | [diff] [blame] | 56 | |
| 57 | dx depends.dx |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 58 | } |
| 59 | |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 60 | // You must manually execute this task to regenerate SyntheticAccessorFSM.java, after modifying the ragel file |
| 61 | // e.g. ./gradlew ragel |
| 62 | task ragel(type:Exec) { |
| 63 | workingDir = 'src/main/ragel' |
| 64 | |
| 65 | commandLine 'ragel', '-J', '-o', file('src/main/java/org/jf/dexlib2/util/SyntheticAccessorFSM.java'), |
| 66 | 'SyntheticAccessorFSM.rl' |
| 67 | } |
| 68 | |
| 69 | task generateAccessorTestSource(type: JavaExec) { |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 70 | file(testAccessorOutputFile.parent).mkdirs() |
Ben Gruver | 3279a8c | 2015-03-01 21:56:40 -0800 | [diff] [blame] | 71 | outputs.dir file(testAccessorOutputDir) |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 72 | |
| 73 | classpath = configurations.accessorTestGenerator |
| 74 | main = 'org.jf.dexlib2.AccessorTestGenerator' |
| 75 | args testAccessorOutputFile |
| 76 | } |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 77 | compileAccessorTestJava.dependsOn(generateAccessorTestSource) |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 78 | |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 79 | // You must manually execute this task to regenerate src/test/resources/accessorTest.dex |
| 80 | task generateAccessorTestDex(type: JavaExec, dependsOn: compileAccessorTestJava) { |
| 81 | def outputDex = file('src/test/resources/accessorTest.dex') |
| 82 | file(outputDex.parent).mkdirs() |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 83 | |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 84 | inputs.dir(project.sourceSets.accessorTest.output.classesDir) |
Ben Gruver | b76dee7 | 2015-03-16 19:54:57 -0700 | [diff] [blame] | 85 | outputs.file outputDex |
| 86 | |
| 87 | main 'com.android.dx.command.Main' |
| 88 | classpath = configurations.dx |
| 89 | |
Ben Gruver | b76dee7 | 2015-03-16 19:54:57 -0700 | [diff] [blame] | 90 | args '--dex' |
| 91 | args '--no-strict' |
| 92 | args "--output=${outputDex}" |
Ben Gruver | 0f1e995 | 2015-05-22 16:25:56 -0700 | [diff] [blame] | 93 | args sourceSets.accessorTest.output.classesDir |
Ben Gruver | 2b8845b | 2012-11-04 22:54:06 -0800 | [diff] [blame] | 94 | } |
Ben Gruver | 5b411f3 | 2014-01-17 02:04:07 -0800 | [diff] [blame] | 95 | |
Ben Gruver | 5b411f3 | 2014-01-17 02:04:07 -0800 | [diff] [blame] | 96 | uploadArchives { |
| 97 | repositories.mavenDeployer { |
| 98 | pom.project { |
| 99 | description 'dexlib2 is a library for reading/modifying/writing Android dex files' |
| 100 | scm { |
| 101 | url 'https://github.com/JesusFreke/smali/tree/master/dexlib2' |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |