com.android.build.api.transform.DirectoryInput Java Examples

The following examples show how to use com.android.build.api.transform.DirectoryInput. 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: AbstractTransform.java    From SocialSdkLibrary with Apache License 2.0 6 votes vote down vote up
@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");
}
 
Example #2
Source File: RSymbols.java    From shrinker with Apache License 2.0 5 votes vote down vote up
private Stream<Path> toStream(DirectoryInput dir) {
    try {
        return Files.walk(dir.getFile().toPath()).filter(Files::isRegularFile);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #3
Source File: ProGuardPercentPrinter.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NonNull
private static Path getOutputPath(@NonNull TransformOutputProvider outputProvider,
        @NonNull QualifiedContent content) {
    return outputProvider.getContentLocation(content.getName(),
            content.getContentTypes(),
            content.getScopes(),
            content instanceof DirectoryInput ? Format.DIRECTORY : Format.JAR).toPath();
}
 
Example #4
Source File: TransformInputUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static DirectoryInput makeDirectoryInput(File file, AppVariantContext variantContext) {
    return new DirectoryInput() {
        @Override
        public Map<File, Status> getChangedFiles() {
            return ImmutableMap.of(file, Status.CHANGED);
        }

        @Override
        public String getName() {
            return "folder";
        }

        @Override
        public File getFile() {
            return file;
        }

        @Override
        public Set<QualifiedContent.ContentType> getContentTypes() {
            return ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES);
        }

        @Override
        public Set<? super QualifiedContent.Scope> getScopes() {
            return ImmutableSet.of(Scope.EXTERNAL_LIBRARIES);
        }
    };

}
 
Example #5
Source File: DirectoryContentProvider.java    From EasyRouter with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accepted(QualifiedContent qualifiedContent) {
    return qualifiedContent instanceof DirectoryInput;
}
 
Example #6
Source File: TransformContext.java    From EasyRouter with Apache License 2.0 4 votes vote down vote up
public Collection<DirectoryInput> getAllDirs() {
    return Collections.unmodifiableCollection(allDirs);
}