• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
32ext.testAccessorOutputDir = file("${buildDir}/generated-src/accessorTest/java")
33ext.testAccessorOutputFile = file("${testAccessorOutputDir}/org/jf/dexlib2/AccessorTypes.java")
34
35sourceSets {
36    accessorTest {
37        java {
38            srcDir testAccessorOutputDir
39        }
40    }
41}
42
43configurations {
44    accessorTestGenerator
45    dx
46}
47
48dependencies {
49    compile project(':util')
50    compile depends.findbugs
51    compile depends.guava
52
53    testCompile depends.junit
54    testCompile depends.mockito
55
56    accessorTestGenerator project('accessorTestGenerator')
57
58    dx depends.dx
59}
60
61// You must manually execute this task to regenerate SyntheticAccessorFSM.java, after modifying the ragel file
62// e.g. ./gradlew ragel
63task ragel(type:Exec) {
64    workingDir = 'src/main/ragel'
65
66    commandLine 'ragel', '-J', '-o', file('src/main/java/org/jf/dexlib2/util/SyntheticAccessorFSM.java'),
67            'SyntheticAccessorFSM.rl'
68}
69
70task generateAccessorTestSource(type: JavaExec) {
71    file(testAccessorOutputFile.parent).mkdirs()
72    outputs.dir file(testAccessorOutputDir)
73
74    classpath = configurations.accessorTestGenerator
75    main = 'org.jf.dexlib2.AccessorTestGenerator'
76    args testAccessorOutputFile
77}
78compileAccessorTestJava.dependsOn(generateAccessorTestSource)
79
80// You must manually execute this task to regenerate src/test/resources/accessorTest.dex
81task generateAccessorTestDex(type: JavaExec, dependsOn: compileAccessorTestJava) {
82    def outputDex = file('src/test/resources/accessorTest.dex')
83    file(outputDex.parent).mkdirs()
84
85    inputs.dir(project.sourceSets.accessorTest.output.classesDir)
86    outputs.file outputDex
87
88    main 'com.android.dx.command.Main'
89    classpath = configurations.dx
90
91    args '--dex'
92    args '--no-strict'
93    args "--output=${outputDex}"
94    args sourceSets.accessorTest.output.classesDir
95}
96
97uploadArchives {
98    repositories.mavenDeployer {
99        pom.project {
100            description 'dexlib2 is a library for reading/modifying/writing Android dex files'
101            scm {
102                url 'https://github.com/JesusFreke/smali/tree/master/dexlib2'
103            }
104        }
105    }
106}