Java Code Examples for com.android.build.api.transform.TransformInvocation#getInputs()
The following examples show how to use
com.android.build.api.transform.TransformInvocation#getInputs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataLoaderTransform.java From DataLoader with Apache License 2.0 | 6 votes |
private void process(TransformInvocation transformInvocation) throws IOException { List<LoaderInfo> loaderInfoList = new ArrayList<>(); for (TransformInput input : transformInvocation.getInputs()) { for (JarInput jarInput : input.getJarInputs()) { File file = jarInput.getFile(); JarFile jarFile = new JarFile(file); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (isLoaderInfoEntry(entry)) { System.out.println(TAG + "entry name: " + entry.getName()); String content = GradleUtils.getContent(jarFile, entry); System.out.println(TAG + "content: " + content); Type type = new TypeToken<List<LoaderInfo>>() { }.getType(); List<LoaderInfo> loaderInfos = gson.fromJson(content, type); if (loaderInfos != null) { loaderInfoList.addAll(loaderInfos); } } } } } String json = gson.toJson(loaderInfoList); generateInitClass(transformInvocation, json); }
Example 2
Source File: AbstractTransform.java From SocialSdkLibrary with Apache License 2.0 | 6 votes |
@Override public void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException { super.transform(transformInvocation); UtilX.log("start transform"); long startTime = System.currentTimeMillis(); // 获取输入 Collection<TransformInput> inputs = transformInvocation.getInputs(); final TransformOutputProvider outputProvider = transformInvocation.getOutputProvider(); // 删除之前的输出 if (outputProvider != null) { outputProvider.deleteAll(); } for (TransformInput transformInput : inputs) { for (DirectoryInput directoryInput : transformInput.getDirectoryInputs()) { onEachDirectory(directoryInput, outputProvider); } for (JarInput jarInput : transformInput.getJarInputs()) { onEachJar(jarInput, outputProvider); } } long endTime = System.currentTimeMillis(); UtilX.log("end transform cost time " + (endTime - startTime) / 1000 + " s"); }