1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package util.build; 18 19 import com.android.jill.Jill; 20 import com.android.jill.Main; 21 import com.android.jill.Options; 22 23 import java.io.File; 24 25 public class JillBuildStep extends BuildStep { 26 JillBuildStep(BuildFile inputFile, BuildFile outputFile)27 JillBuildStep(BuildFile inputFile, BuildFile outputFile) { 28 super(inputFile, outputFile); 29 } 30 31 @Override build()32 boolean build() { 33 if (super.build()) { 34 35 File outDir = outputFile.fileName.getParentFile(); 36 if (!outDir.exists() && !outDir.mkdirs()) { 37 System.err.println("failed to create output dir: " 38 + outDir.getAbsolutePath()); 39 return false; 40 } 41 42 int args = 3; 43 String[] commandLine = new String[args]; 44 commandLine[0] = "--output"; 45 commandLine[1] = outputFile.fileName.getAbsolutePath(); 46 commandLine[2] = inputFile.fileName.getAbsolutePath(); 47 48 try { 49 Options options = Main.getOptions(commandLine); 50 Jill.process(options); 51 } catch (Throwable ex) { 52 ex.printStackTrace(); 53 return false; 54 } 55 56 return true; 57 } 58 return false; 59 } 60 61 @Override equals(Object obj)62 public boolean equals(Object obj) { 63 if (super.equals(obj)) { 64 JillBuildStep other = (JillBuildStep) obj; 65 66 return inputFile.equals(other.inputFile) && outputFile.equals(other.outputFile); 67 } 68 return false; 69 } 70 71 @Override hashCode()72 public int hashCode() { 73 return inputFile.hashCode() ^ outputFile.hashCode(); 74 } 75 } 76