1 /*
2  * Copyright (C) 2015 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 package android.databinding.tool;
17 
18 import org.gradle.api.DefaultTask;
19 import org.gradle.api.tasks.TaskAction;
20 
21 import android.databinding.tool.processing.Scope;
22 
23 import java.io.File;
24 
25 /**
26  * Task to pass environment info to javac
27  */
28 public class DataBindingExportInfoTask extends DefaultTask {
29     private LayoutXmlProcessor xmlProcessor;
30     private File sdkDir;
31     private File xmlOutFolder;
32     private File exportClassListTo;
33     private boolean printEncodedErrors;
34     private boolean enableDebugLogs = false;
35     @TaskAction
exportInfo()36     public void exportInfo() {
37         xmlProcessor.writeInfoClass(sdkDir, xmlOutFolder, exportClassListTo, enableDebugLogs,
38                 printEncodedErrors);
39         Scope.assertNoError();
40     }
41 
getXmlProcessor()42     public LayoutXmlProcessor getXmlProcessor() {
43         return xmlProcessor;
44     }
45 
setXmlProcessor(LayoutXmlProcessor xmlProcessor)46     public void setXmlProcessor(LayoutXmlProcessor xmlProcessor) {
47         this.xmlProcessor = xmlProcessor;
48     }
49 
getSdkDir()50     public File getSdkDir() {
51         return sdkDir;
52     }
53 
setSdkDir(File sdkDir)54     public void setSdkDir(File sdkDir) {
55         this.sdkDir = sdkDir;
56     }
57 
getXmlOutFolder()58     public File getXmlOutFolder() {
59         return xmlOutFolder;
60     }
61 
setXmlOutFolder(File xmlOutFolder)62     public void setXmlOutFolder(File xmlOutFolder) {
63         this.xmlOutFolder = xmlOutFolder;
64     }
65 
getExportClassListTo()66     public File getExportClassListTo() {
67         return exportClassListTo;
68     }
69 
setExportClassListTo(File exportClassListTo)70     public void setExportClassListTo(File exportClassListTo) {
71         this.exportClassListTo = exportClassListTo;
72     }
73 
isPrintEncodedErrors()74     public boolean isPrintEncodedErrors() {
75         return printEncodedErrors;
76     }
77 
setPrintEncodedErrors(boolean printEncodedErrors)78     public void setPrintEncodedErrors(boolean printEncodedErrors) {
79         this.printEncodedErrors = printEncodedErrors;
80     }
81 
isEnableDebugLogs()82     public boolean isEnableDebugLogs() {
83         return enableDebugLogs;
84     }
85 
setEnableDebugLogs(boolean enableDebugLogs)86     public void setEnableDebugLogs(boolean enableDebugLogs) {
87         this.enableDebugLogs = enableDebugLogs;
88     }
89 }