Search in sources :

Example 1 with FileUtil

use of com.google.devtools.j2objc.util.FileUtil in project j2objc by google.

the class Options method getPathArgument.

private List<String> getPathArgument(String argument, boolean expandAarFiles, boolean expandWildcard) {
    List<String> entries = new ArrayList<>();
    for (String entry : Splitter.on(File.pathSeparatorChar).split(argument)) {
        if (entry.startsWith("~/")) {
            // Expand bash/csh tildes, which don't get expanded by the shell
            // first if in the middle of a path string.
            entry = System.getProperty("user.home") + entry.substring(1);
        }
        File f = new File(entry);
        if (f.getName().equals("*") && expandWildcard) {
            File parent = f.getParentFile() == null ? new File(".") : f.getParentFile();
            FileFilter jarFilter = file -> file.getName().endsWith(".jar");
            File[] files = parent.listFiles(jarFilter);
            if (files != null) {
                for (File jar : files) {
                    entries.add(jar.toString());
                }
            }
            continue;
        }
        if (entry.endsWith(".aar") && expandAarFiles) {
            // Extract classes.jar from Android library AAR file.
            f = fileUtil().extractClassesJarFromAarFile(f);
        }
        if (f.exists()) {
            entries.add(f.toString());
        }
    }
    return entries;
}
Also used : ExternalAnnotations(com.google.devtools.j2objc.util.ExternalAnnotations) Arrays(java.util.Arrays) URL(java.net.URL) GenerationUnit(com.google.devtools.j2objc.gen.GenerationUnit) Mappings(com.google.devtools.j2objc.util.Mappings) PackageInfoLookup(com.google.devtools.j2objc.util.PackageInfoLookup) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Files(com.google.common.io.Files) NameTable(com.google.devtools.j2objc.util.NameTable) PackagePrefixes(com.google.devtools.j2objc.util.PackagePrefixes) Version(com.google.devtools.j2objc.util.Version) Splitter(com.google.common.base.Splitter) EnumSet(java.util.EnumSet) SourceVersion(com.google.devtools.j2objc.util.SourceVersion) ImmutableSet(com.google.common.collect.ImmutableSet) Properties(java.util.Properties) Iterator(java.util.Iterator) Resources(com.google.common.io.Resources) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Set(java.util.Set) IOException(java.io.IOException) Logger(java.util.logging.Logger) Sets(com.google.common.collect.Sets) File(java.io.File) List(java.util.List) FileFilter(java.io.FileFilter) HeaderMap(com.google.devtools.j2objc.util.HeaderMap) Preconditions(com.google.common.base.Preconditions) APPEND(com.google.common.io.FileWriteMode.APPEND) VisibleForTesting(com.google.common.annotations.VisibleForTesting) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) Pattern(java.util.regex.Pattern) Handler(java.util.logging.Handler) ErrorUtil(com.google.devtools.j2objc.util.ErrorUtil) Collections(java.util.Collections) FileUtil(com.google.devtools.j2objc.util.FileUtil) ArrayList(java.util.ArrayList) FileFilter(java.io.FileFilter) File(java.io.File)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Splitter (com.google.common.base.Splitter)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 APPEND (com.google.common.io.FileWriteMode.APPEND)1 Files (com.google.common.io.Files)1 Resources (com.google.common.io.Resources)1 GenerationUnit (com.google.devtools.j2objc.gen.GenerationUnit)1 ErrorUtil (com.google.devtools.j2objc.util.ErrorUtil)1 ExternalAnnotations (com.google.devtools.j2objc.util.ExternalAnnotations)1 FileUtil (com.google.devtools.j2objc.util.FileUtil)1 HeaderMap (com.google.devtools.j2objc.util.HeaderMap)1 Mappings (com.google.devtools.j2objc.util.Mappings)1 NameTable (com.google.devtools.j2objc.util.NameTable)1 PackageInfoLookup (com.google.devtools.j2objc.util.PackageInfoLookup)1 PackagePrefixes (com.google.devtools.j2objc.util.PackagePrefixes)1 SourceVersion (com.google.devtools.j2objc.util.SourceVersion)1 Version (com.google.devtools.j2objc.util.Version)1 File (java.io.File)1