blob: b8fe78942ee2f354e682b3c9db6d6043558a059d [file] [log] [blame]
Ben Gruverf7ab3f92012-10-14 22:15:56 -07001/*
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 Gruver0f1e9952015-05-22 16:25:56 -070032ext.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
Ben Gruver2b8845b2012-11-04 22:54:06 -080043configurations {
44 accessorTestGenerator
Ben Gruverb76dee72015-03-16 19:54:57 -070045 dx
Ben Gruver2b8845b2012-11-04 22:54:06 -080046}
47
Ben Gruverf7ab3f92012-10-14 22:15:56 -070048dependencies {
Ben Gruver46cefa32013-03-03 17:58:02 -080049 compile depends.findbugs
50 compile depends.guava
Ben Gruvere2db1542012-10-20 22:58:07 -070051
Ben Gruver46cefa32013-03-03 17:58:02 -080052 testCompile depends.junit
Ben Gruver3587c6f2016-08-30 21:15:03 -070053 testCompile depends.mockito
Ben Gruver2b8845b2012-11-04 22:54:06 -080054
55 accessorTestGenerator project('accessorTestGenerator')
Ben Gruverb76dee72015-03-16 19:54:57 -070056
57 dx depends.dx
Ben Gruver2b8845b2012-11-04 22:54:06 -080058}
59
Ben Gruver2b8845b2012-11-04 22:54:06 -080060// 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) {
Ben Gruver0f1e9952015-05-22 16:25:56 -070070 file(testAccessorOutputFile.parent).mkdirs()
Ben Gruver3279a8c2015-03-01 21:56:40 -080071 outputs.dir file(testAccessorOutputDir)
Ben Gruver2b8845b2012-11-04 22:54:06 -080072
73 classpath = configurations.accessorTestGenerator
74 main = 'org.jf.dexlib2.AccessorTestGenerator'
75 args testAccessorOutputFile
76}
Ben Gruver0f1e9952015-05-22 16:25:56 -070077compileAccessorTestJava.dependsOn(generateAccessorTestSource)
Ben Gruver2b8845b2012-11-04 22:54:06 -080078
Ben Gruver0f1e9952015-05-22 16:25:56 -070079// 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()
Ben Gruver2b8845b2012-11-04 22:54:06 -080083
Ben Gruver0f1e9952015-05-22 16:25:56 -070084 inputs.dir(project.sourceSets.accessorTest.output.classesDir)
Ben Gruverb76dee72015-03-16 19:54:57 -070085 outputs.file outputDex
86
87 main 'com.android.dx.command.Main'
88 classpath = configurations.dx
89
Ben Gruverb76dee72015-03-16 19:54:57 -070090 args '--dex'
91 args '--no-strict'
92 args "--output=${outputDex}"
Ben Gruver0f1e9952015-05-22 16:25:56 -070093 args sourceSets.accessorTest.output.classesDir
Ben Gruver2b8845b2012-11-04 22:54:06 -080094}
Ben Gruver5b411f32014-01-17 02:04:07 -080095
Ben Gruver5b411f32014-01-17 02:04:07 -080096uploadArchives {
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}