blob: 39a4bfb4b67610df4af4da91159b402cf891ac97 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001// Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package dx;
5
6import java.io.File;
7import java.io.IOException;
8import org.gradle.api.Action;
9import org.gradle.api.DefaultTask;
10import org.gradle.api.UncheckedIOException;
11import org.gradle.api.file.FileTree;
12import org.gradle.api.tasks.TaskAction;
13import org.gradle.process.ExecSpec;
14import utils.Utils;
15
16public class DexMerger extends DefaultTask {
17
18 private FileTree source;
19 private File destination;
20 private File dexMergerExecutable;
21 private boolean debug;
22
23 public FileTree getSource() {
24 return source;
25 }
26
27 public void setSource(FileTree source) {
28 this.source = source;
29 getInputs().file(source);
30 }
31
32 public File getDestination() {
33 return destination;
34 }
35
36 public void setDestination(File destination) {
37 this.destination = destination;
38 getOutputs().file(destination);
39 }
40
41 public File getDexMergerExecutable() {
42 return dexMergerExecutable;
43 }
44
45 public void setDexMergerExecutable(File dexMergerExecutable) {
46 this.dexMergerExecutable = dexMergerExecutable;
47 }
48
49 @TaskAction
50 void exec() {
51 getProject().exec(new Action<ExecSpec>() {
52 @Override
53 public void execute(ExecSpec execSpec) {
54 try {
55 if (dexMergerExecutable == null) {
56 dexMergerExecutable = new File("tools/" + Utils.toolsDir() + "/dx/bin/dexmerger");
57 }
58 execSpec.setExecutable(dexMergerExecutable);
59 execSpec.args(destination.getCanonicalPath());
60 execSpec.args(source.getFiles());
61 } catch (IOException e) {
62 throw new UncheckedIOException(e);
63 }
64 }
65 });
66 }
67}