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
55    accessorTestGenerator project('accessorTestGenerator')
56
57    dx depends.dx
58}
59
60// You must manually execute this task to regenerate SyntheticAccessorFSM.java, after modifying the ragel file
61// e.g. ./gradlew ragel
62task 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
69task generateAccessorTestSource(type: JavaExec) {
70    file(testAccessorOutputFile.parent).mkdirs()
71    outputs.dir file(testAccessorOutputDir)
72
73    classpath = configurations.accessorTestGenerator
74    main = 'org.jf.dexlib2.AccessorTestGenerator'
75    args testAccessorOutputFile
76}
77compileAccessorTestJava.dependsOn(generateAccessorTestSource)
78
79// You must manually execute this task to regenerate src/test/resources/accessorTest.dex
80task generateAccessorTestDex(type: JavaExec, dependsOn: compileAccessorTestJava) {
81    def outputDex = file('src/test/resources/accessorTest.dex')
82    file(outputDex.parent).mkdirs()
83
84    inputs.dir(project.sourceSets.accessorTest.output.classesDir)
85    outputs.file outputDex
86
87    main 'com.android.dx.command.Main'
88    classpath = configurations.dx
89
90    args '--dex'
91    args '--no-strict'
92    args "--output=${outputDex}"
93    args sourceSets.accessorTest.output.classesDir
94}
95
96uploadArchives {
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}