com.android.utils.ILogger Java Examples

The following examples show how to use com.android.utils.ILogger. 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: SkippingWarning1Parser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String sourcePath = m.group(2);
    // Certain files can safely be skipped without marking the project as having errors.
    // See isHidden() in AaptAssets.cpp:
    String type = m.group(1);
    if (type.equals("backup")         // main.xml~, etc
            || type.equals("hidden")      // .gitignore, etc
            || type.equals("index")) {    // thumbs.db, etc
        return true;
    }
    Message msg = createMessage(Message.Kind.WARNING, line, sourcePath,
            null, "", logger);
    messages.add(msg);
    return true;
}
 
Example #2
Source File: DataSet.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Update the DataSet with a given file.
 *
 * @param sourceFolder the sourceFile containing the changedFile
 * @param changedFile The changed file
 * @param fileStatus the change state
 * @return true if the set was properly updated, false otherwise
 * @throws MergingException if something goes wrong
 */
public boolean updateWith(File sourceFolder, File changedFile, FileStatus fileStatus,
                          ILogger logger)
        throws MergingException {
    switch (fileStatus) {
        case NEW:
            return handleNewFile(sourceFolder, changedFile, logger);
        case CHANGED:
            return handleChangedFile(sourceFolder, changedFile);
        case REMOVED:
            F dataFile = mDataFileMap.get(changedFile);

            if (dataFile == null) {
                return false;
            }

            // flag all resource items are removed
            for (I dataItem : dataFile.getItems()) {
                dataItem.setRemoved();
            }
            return true;
    }

    return false;
}
 
Example #3
Source File: ArgvParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public ArgvParser(ILogger logger) {
    super(logger, ACTIONS);

    // The following defines the parameters of the actions defined in mAction.

    // --- merge manifest ---

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "o", KEY_OUT,                           //$NON-NLS-1$
            "Output path (where to write the merged manifest). Use - for stdout.", null);

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "1", KEY_MAIN,                          //$NON-NLS-1$
            "Path of the main manifest (what to merge *into*)", null);

    define(Mode.STRING_ARRAY, true,
            VERB_MERGE, NO_VERB_OBJECT, "2", KEY_LIBS,                          //$NON-NLS-1$
            "Paths of library manifests to be merged into the main one.",
            null);
}
 
Example #4
Source File: JsonEncodedGradleMessageParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line,
                     @NonNull OutputLineReader reader,
                     @NonNull List<Message> messages,
                     @NonNull ILogger logger) throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String json = m.group(1);
    if (json.trim().isEmpty()) {
        return false;
    }

    GsonBuilder gsonBuilder = new GsonBuilder();
    MessageJsonSerializer.registerTypeAdapters(gsonBuilder);
    Gson gson = gsonBuilder.create();
    try {
        Message msg = gson.fromJson(json, Message.class);
        messages.add(msg);
        return true;
    } catch (JsonParseException e) {
        throw new ParsingFailedException(e);
    }
}
 
Example #5
Source File: ArgvParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public ArgvParser(ILogger logger) {
    super(logger, ACTIONS);

    // The following defines the parameters of the actions defined in mAction.

    // --- merge manifest ---

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "o", KEY_OUT,                           //$NON-NLS-1$
            "Output path (where to write the merged manifest). Use - for stdout.", null);

    define(Mode.STRING, true,
            VERB_MERGE, NO_VERB_OBJECT, "1", KEY_MAIN,                          //$NON-NLS-1$
            "Path of the main manifest (what to merge *into*)", null);

    define(Mode.STRING_ARRAY, true,
            VERB_MERGE, NO_VERB_OBJECT, "2", KEY_LIBS,                          //$NON-NLS-1$
            "Paths of library manifests to be merged into the main one.",
            null);
}
 
Example #6
Source File: AvdManager.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public AvdInfo updateAvd(AvdInfo avd,
        Map<String, String> newProperties,
        AvdStatus status,
        ILogger log) throws IOException {
    // now write the config file
    File configIniFile = new File(avd.getDataFolderPath(), CONFIG_INI);
    writeIniFile(configIniFile, newProperties, true);

    // finally create a new AvdInfo for this unbroken avd and add it to the list.
    // instead of creating the AvdInfo object directly we reparse it, to detect other possible
    // errors
    // FIXME: We may want to create this AvdInfo by reparsing the AVD instead. This could detect other errors.
    AvdInfo newAvd = new AvdInfo(
            avd.getName(),
            avd.getIniFile(),
            avd.getDataFolderPath(),
            avd.getTargetHash(),
            avd.getTarget(),
            avd.getTag(),
            avd.getAbiType(),
            newProperties);

    replaceAvd(avd, newAvd);

    return newAvd;
}
 
Example #7
Source File: ManifestMerger2.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private ManifestMerger2(
        @NonNull ILogger logger,
        @NonNull File mainManifestFile,
        @NonNull ImmutableList<Pair<String, File>> libraryFiles,
        @NonNull ImmutableList<File> flavorsAndBuildTypeFiles,
        @NonNull ImmutableList<Invoker.Feature> optionalFeatures,
        @NonNull Map<String, Object> placeHolderValues,
        @NonNull KeyBasedValueResolver<SystemProperty> systemPropertiesResolver,
        @NonNull MergeType mergeType,
        @NonNull Optional<File> reportFile) {
    this.mSystemPropertyResolver = systemPropertiesResolver;
    this.mPlaceHolderValues = placeHolderValues;
    this.mManifestFile = mainManifestFile;
    this.mLogger = logger;
    this.mLibraryFiles = libraryFiles;
    this.mFlavorsAndBuildTypeFiles = flavorsAndBuildTypeFiles;
    this.mOptionalFeatures = optionalFeatures;
    this.mMergeType = mergeType;
    this.mReportFile = reportFile;
}
 
Example #8
Source File: CommandLineParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new command-line processor.
 *
 * @param logger An SDK logger object. Must not be null.
 * @param actions The list of actions recognized on the command-line.
 *                See the javadoc of {@link #mActions} for more details.
 *
 * @see #mActions
 */
public CommandLineParser(ILogger logger, String[][] actions) {
    mLog = logger;
    mActions = actions;

    /*
     * usage should fit in 80 columns, including the space to print the options:
     * "  -v --verbose  7890123456789012345678901234567890123456789012345678901234567890"
     */

    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "v", KEY_VERBOSE,
                       "Verbose mode, shows errors, warnings and all messages.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "s", KEY_SILENT,
                       "Silent mode, shows errors only.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "h", KEY_HELP,
                       "Help on a specific command.",
                       false);
}
 
Example #9
Source File: ManifestMerger2.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private ManifestMerger2(
        @NonNull ILogger logger,
        @NonNull File mainManifestFile,
        @NonNull ImmutableList<Pair<String, File>> libraryFiles,
        @NonNull ImmutableList<File> flavorsAndBuildTypeFiles,
        @NonNull ImmutableList<Invoker.Feature> optionalFeatures,
        @NonNull Map<String, Object> placeHolderValues,
        @NonNull KeyBasedValueResolver<SystemProperty> systemPropertiesResolver,
        @NonNull MergeType mergeType,
        @NonNull Optional<File> reportFile) {
    this.mSystemPropertyResolver = systemPropertiesResolver;
    this.mPlaceHolderValues = placeHolderValues;
    this.mManifestFile = mainManifestFile;
    this.mLogger = logger;
    this.mLibraryFiles = libraryFiles;
    this.mFlavorsAndBuildTypeFiles = flavorsAndBuildTypeFiles;
    this.mOptionalFeatures = optionalFeatures;
    this.mMergeType = mergeType;
    this.mReportFile = reportFile;
}
 
Example #10
Source File: Error5Parser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    for (Pattern pattern : MSG_PATTERNS) {
        Matcher m = pattern.matcher(line);
        if (m.matches()) {
            String sourcePath = m.group(1);
            String lineNumber = m.group(2);
            String msgText = m.group(3);
            Message.Kind kind = Message.Kind.ERROR;
            if (msgText.startsWith("warning: ")) {
                // NDK warning also matches this regexp
                kind = Message.Kind.WARNING;
            }
            if (sourcePath.endsWith(SdkConstants.DOT_JAVA)) {
                return false;
            }
            Message msg = createMessage(kind, msgText, sourcePath, lineNumber, "", logger);
            messages.add(msg);
            return true;
        }
    }
    return false;
}
 
Example #11
Source File: Error3Parser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean parse(@NonNull String line, @NonNull OutputLineReader reader, @NonNull List<Message> messages, @NonNull ILogger logger)
        throws ParsingFailedException {
    Matcher m = MSG_PATTERN.matcher(line);
    if (!m.matches()) {
        return false;
    }
    String sourcePath = m.group(1);
    String lineNumber = m.group(2);
    String msgText = m.group(3);

    Message msg = createMessage(Message.Kind.ERROR, msgText, sourcePath,
            lineNumber, "", logger);
    messages.add(msg);
    return true;
}
 
Example #12
Source File: BuildToolInfo.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the build-tool is valid by verifying that the expected binaries
 * are actually present. This checks that all known paths point to a valid file
 * or directory.
 *
 * @param log An optional logger. If non-null, errors will be printed there.
 * @return True if the build-tool folder contains all the expected tools.
 */
public boolean isValid(@Nullable ILogger log) {
    for (Map.Entry<PathId, String> entry : mPaths.entrySet()) {
        File f = new File(entry.getValue());
        // check if file is missing. It's only ok if the revision of the build-tools
        // is lower than the min rev of the element.
        if (!f.exists() && entry.getKey().isPresentIn(mRevision)) {
            if (log != null) {
                log.warning("Build-tool %1$s is missing %2$s at %3$s",  //$NON-NLS-1$
                        mRevision.toString(),
                        entry.getKey(), f.getAbsolutePath());
            }
            return false;
        }
    }
    return true;
}
 
Example #13
Source File: ResourceSet.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void readSourceFolder(File sourceFolder, ILogger logger)
        throws MergingException {
    List<Message> errors = Lists.newArrayList();
    File[] folders = sourceFolder.listFiles();
    if (folders != null) {
        for (File folder : folders) {
            if (folder.isDirectory() && !isIgnored(folder)) {
                FolderData folderData = getFolderData(folder);
                if (folderData != null) {
                    try {
                        parseFolder(sourceFolder, folder, folderData, logger);
                    } catch (MergingException e) {
                        errors.addAll(e.getMessages());
                    }
                }
            }
        }
    }
    MergingException.throwIfNonEmpty(errors);
}
 
Example #14
Source File: ResourceSet.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Reads the content of a typed resource folder (sub folder to the root of res folder), and
 * loads the resources from it.
 *
 *
 * @param sourceFolder the main res folder
 * @param folder the folder to read.
 * @param folderData the folder Data
 * @param logger a logger object
 *
 * @throws MergingException if something goes wrong
 */
private void parseFolder(File sourceFolder, File folder, FolderData folderData, ILogger logger)
        throws MergingException {
    File[] files = folder.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            if (!file.isFile() || isIgnored(file)) {
                continue;
            }

            ResourceFile resourceFile = createResourceFile(file, folderData, logger);
            if (resourceFile != null) {
                processNewDataFile(sourceFolder, resourceFile, true /*setTouched*/);
            }
        }
    }
}
 
Example #15
Source File: TBIncrementalVisitor.java    From atlas with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static boolean isClassTargetingNewerPlatform(
        int targetApiLevel,
        @NonNull Type targetApiAnnotationType,
        @NonNull AsmUtils.ClassReaderProvider locator,
        @NonNull ClassNode classNode,
        @NonNull ILogger logger) throws IOException {

    List<AnnotationNode> invisibleAnnotations =
            AsmUtils.getInvisibleAnnotationsOnClassOrOuterClasses(locator, classNode, logger);
    for (AnnotationNode classAnnotation : invisibleAnnotations) {
        if (classAnnotation.desc.equals(targetApiAnnotationType.getDescriptor())) {
            int valueIndex = 0;
            List values = classAnnotation.values;
            while (valueIndex < values.size()) {
                String name = (String) values.get(valueIndex);
                if (name.equals("value")) {
                    Object value = values.get(valueIndex + 1);
                    return Integer.class.cast(value) > targetApiLevel;
                }
                valueIndex = valueIndex + 2;
            }
        }
    }
    return false;
}
 
Example #16
Source File: CommandLineParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a new command-line processor.
 *
 * @param logger An SDK logger object. Must not be null.
 * @param actions The list of actions recognized on the command-line.
 *                See the javadoc of {@link #mActions} for more details.
 *
 * @see #mActions
 */
public CommandLineParser(ILogger logger, String[][] actions) {
    mLog = logger;
    mActions = actions;

    /*
     * usage should fit in 80 columns, including the space to print the options:
     * "  -v --verbose  7890123456789012345678901234567890123456789012345678901234567890"
     */

    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "v", KEY_VERBOSE,
                       "Verbose mode, shows errors, warnings and all messages.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "s", KEY_SILENT,
                       "Silent mode, shows errors only.",
                       false);
    define(Mode.BOOLEAN, false, GLOBAL_FLAG_VERB, NO_VERB_OBJECT, "h", KEY_HELP,
                       "Help on a specific command.",
                       false);
}
 
Example #17
Source File: LocalSdkParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Scan the build-tool/folders and register valid as well as broken build tool packages.
 */
private void scanBuildTools(
        SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File buildToolRoot = new File(sdkManager.getLocation(), SdkConstants.FD_BUILD_TOOLS);

    // The build-tool root folder contains a list of revisioned folders.
    for (File buildToolDir : listFilesNonNull(buildToolRoot)) {
        if (buildToolDir.isDirectory() && !visited.contains(buildToolDir)) {
            visited.add(buildToolDir);

            // Ignore empty directories
            File[] srcFiles = buildToolDir.listFiles();
            if (srcFiles != null && srcFiles.length > 0) {
                Properties props =
                    parseProperties(new File(buildToolDir, SdkConstants.FN_SOURCE_PROP));

                try {
                    Package pkg = BuildToolPackage.create(buildToolDir, props);
                    packages.add(pkg);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}
 
Example #18
Source File: LocalSdkParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Try to find a platform-tools package at the given location.
 * Returns null if not found.
 */
private Package scanPlatformTools(File platformToolsFolder, ILogger log) {
    // Can we find some properties?
    Properties props = parseProperties(new File(platformToolsFolder,
            SdkConstants.FN_SOURCE_PROP));

    // We're not going to check that all tools are present. At the very least
    // we should expect to find adb, aidl, aapt and dx (adapted to the current OS).

    if (platformToolsFolder.listFiles() == null) {
        // ListFiles is null if the directory doesn't even exist.
        // Not going to find anything in there...
        return null;
    }

    // Create our package. use the properties if we found any.
    try {
        Package pkg = PlatformToolPackage.create(
                null,                           //source
                props,                          //properties
                0,                              //revision
                null,                           //license
                "Platform Tools",               //description
                null,                           //descUrl
                platformToolsFolder.getPath()   //archiveOsPath
                );

        return pkg;
    } catch (Exception e) {
        log.error(e, null);
    }
    return null;
}
 
Example #19
Source File: AssetSet.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void readFiles(@NonNull File sourceFolder, @NonNull File folder, @NonNull ILogger logger)
        throws MergingException {
    File[] files = folder.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            if (!isIgnored(file)) {
                if (file.isFile()) {
                    handleNewFile(sourceFolder, file, logger);
                } else if (file.isDirectory()) {
                    readFiles(sourceFolder, file, logger);
                }
            }
        }
    }
}
 
Example #20
Source File: AbstractAaptOutputParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Locates a resource value definition in a given file for a given key, and returns the
 * corresponding line number, or -1 if not found. For example, given the key
 * "string/group2_string" it will locate an element {@code <string name="group2_string">} or
 * {@code <item type="string" name="group2_string"}
 */
public static SourcePosition findResourceLine(@NonNull File file, @NonNull String key, @NonNull ILogger logger) {
    int slash = key.indexOf('/');
    if (slash == -1) {
        assert false : slash; // invalid key format
        return SourcePosition.UNKNOWN;
    }

    final String type = key.substring(0, slash);
    final String name = key.substring(slash + 1);

    return findValueDeclaration(file, type, name, logger);
}
 
Example #21
Source File: TBIncrementalSupportVisitor.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public IncrementalVisitor build(
        @NonNull ClassNode classNode,
        @NonNull List<ClassNode> parentNodes,
        @NonNull ClassVisitor classVisitor,
        @NonNull ILogger logger) {
    return new TBIncrementalSupportVisitor(classNode, parentNodes, classVisitor, logger);
}
 
Example #22
Source File: LocalSdkParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The sdk manager only lists valid addons. However here we also want to find "broken"
 * addons, i.e. addons that failed to load for some reason.
 * <p/>
 * Find any other sub-directories under the /add-ons root that hasn't been visited yet
 * and assume they contain broken addons.
 */
private void scanMissingAddons(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File addons = new File(new File(sdkManager.getLocation()), SdkConstants.FD_ADDONS);

    for (File dir : listFilesNonNull(addons)) {
        if (dir.isDirectory() && !visited.contains(dir)) {
            Pair<Map<String, String>, String> infos =
                parseAddonProperties(dir, sdkManager.getTargets(), log);
            Properties sourceProps =
                parseProperties(new File(dir, SdkConstants.FN_SOURCE_PROP));

            Map<String, String> addonProps = infos.getFirst();
            String error = infos.getSecond();
            try {
                Package pkg = AddonPackage.createBroken(dir.getAbsolutePath(),
                                                        sourceProps,
                                                        addonProps,
                                                        error);
                packages.add(pkg);
                visited.add(dir);
            } catch (Exception e) {
                log.error(e, null);
            }
        }
    }
}
 
Example #23
Source File: AvdManager.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the path to the skin, as a relative path to the SDK.
 * @param skinName The name of the skin to find. Case-sensitive.
 * @param target The target where to find the skin.
 * @param log the log object to receive action logs. Cannot be null.
 */
@Deprecated
private String getSkinRelativePath(@NonNull String skinName,
                                   @NonNull IAndroidTarget target,
                                   @NonNull ILogger log) {
    if (log == null) {
        throw new IllegalArgumentException("log cannot be null");
    }

    // first look to see if the skin is in the target
    File skin = getSkinFolder(skinName, target);

    // skin really does not exist!
    if (skin.exists() == false) {
        log.error(null, "Skin '%1$s' does not exist.", skinName);
        return null;
    }

    // get the skin path
    String path = skin.getAbsolutePath();

    // make this path relative to the SDK location

    String sdkLocation = myLocalSdk.getPath();
    if (path.startsWith(sdkLocation) == false) {
        // this really really should not happen.
        log.error(null, "Target location is not inside the SDK.");
        assert false;
        return null;
    }

    path = path.substring(sdkLocation.length());
    if (path.charAt(0) == File.separatorChar) {
        path = path.substring(1);
    }
    return path;
}
 
Example #24
Source File: DataSet.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected boolean handleChangedFile(
        @NonNull File sourceFolder,
        @NonNull File changedFile,
        @NonNull ILogger logger) throws MergingException {
    F dataFile = mDataFileMap.get(changedFile);
    for (I item : dataFile.getItems()) {
        item.setTouched();
    }
    return true;
}
 
Example #25
Source File: AvdManager.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Updates an AVD with new path to the system image folders.
 * @param avd the AVD to update.
 * @param log the log object to receive action logs. Cannot be null.
 * @throws IOException
 */
public AvdInfo updateAvd(AvdInfo avd, ILogger log) throws IOException {
    // get the properties. This is a unmodifiable Map.
    Map<String, String> oldProperties = avd.getProperties();

    // create a new map
    Map<String, String> properties = new HashMap<String, String>();
    if (oldProperties != null) {
        properties.putAll(oldProperties);
    }

    AvdStatus status;

    // create the path to the new system images.
    if (setImagePathProperties(avd.getTarget(),
                               avd.getTag(),
                               avd.getAbiType(),
                               properties,
                               log)) {
        if (properties.containsKey(AVD_INI_IMAGES_1)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_1,
                    properties.get(AVD_INI_IMAGES_1));
        }

        if (properties.containsKey(AVD_INI_IMAGES_2)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_2,
                    properties.get(AVD_INI_IMAGES_2));
        }

        status = AvdStatus.OK;
    } else {
        log.error(null, "Unable to find non empty system images folders for %1$s",
                avd.getName());
        //FIXME: display paths to empty image folders?
        status = AvdStatus.ERROR_IMAGE_DIR;
    }

    return updateAvd(avd, properties, status, log);
}
 
Example #26
Source File: LocalSdkParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find any other directory in the given "root" directory that hasn't been visited yet
 * and assume they contain extra packages. This is <em>not</em> a recursive search.
 */
private void scanExtrasDirectory(String extrasRoot,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File root = new File(extrasRoot);

    for (File dir : listFilesNonNull(root)) {
        if (dir.isDirectory() && !visited.contains(dir)) {
            Properties props = parseProperties(new File(dir, SdkConstants.FN_SOURCE_PROP));
            if (props != null) {
                try {
                    Package pkg = ExtraPackage.create(
                            null,                       //source
                            props,                      //properties
                            null,                       //vendor
                            dir.getName(),              //path
                            0,                          //revision
                            null,                       //license
                            null,                       //description
                            null,                       //descUrl
                            dir.getPath()               //archiveOsPath
                            );

                    packages.add(pkg);
                    visited.add(dir);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}
 
Example #27
Source File: WorkQueue.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new queue, with a number of dedicated threads to process
 * the queue's jobs.
 *
 * @param logger to log messages
 * @param queueName a meaningful descriptive name.
 * @param workforce the number of dedicated threads for this queue.
 * @param growthTriggerRatio the ratio between outstanding requests and worker threads that
 *                           should trigger a growth in worker threads.
 */
public WorkQueue(
        @NonNull ILogger logger,
        @NonNull QueueThreadContext<T> queueThreadContext,
        @NonNull String queueName,
        int workforce,
        float growthTriggerRatio) {

    this.mLogger = logger;
    this.mName = queueName;
    this.mGrowthTriggerRation = growthTriggerRatio;
    this.mMWorkforceIncrement = workforce;
    this.mQueueThreadContext = queueThreadContext;
}
 
Example #28
Source File: ResourceSet.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private static ResourceFile createResourceFile(File file, FolderData folderData, ILogger logger)
        throws MergingException {
    if (folderData.type != null) {
        int pos;// get the resource name based on the filename
        String name = file.getName();
        pos = name.indexOf('.');
        if (pos >= 0) {
            name = name.substring(0, pos);
        }

        return new ResourceFile(
                file,
                new ResourceItem(name, folderData.type, null),
                folderData.qualifiers);
    } else {
        try {
            ValueResourceParser2 parser = new ValueResourceParser2(file);
            List<ResourceItem> items = parser.parseFile();

            return new ResourceFile(file, items, folderData.qualifiers);
        } catch (MergingException e) {
            e.setFile(file);
            logger.error(e, "Failed to parse %s", file.getAbsolutePath());
            throw e;
        }
    }
}
 
Example #29
Source File: AssetSet.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private void readFiles(File sourceFolder, File folder, ILogger logger)
        throws MergingException {
    File[] files = folder.listFiles();
    if (files != null && files.length > 0) {
        for (File file : files) {
            if (!isIgnored(file)) {
                if (file.isFile()) {
                    handleNewFile(sourceFolder, file, logger);
                } else if (file.isDirectory()) {
                    readFiles(sourceFolder, file, logger);
                }
            }
        }
    }
}
 
Example #30
Source File: QueuedCruncher.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link QueuedCruncher} or return an existing one
 * based on the underlying AAPT executable location.
 * @param aaptLocation the APPT executable location.
 * @param logger the logger to use
 * @return a new of existing instance of the {@link QueuedCruncher}
 */
public QueuedCruncher newCruncher(
        @NonNull String aaptLocation,
        @NonNull ILogger logger) {
    synchronized (sLock) {
        logger.info("QueuedCruncher is using %1$s", aaptLocation);
        if (!sInstances.containsKey(aaptLocation)) {
            QueuedCruncher queuedCruncher = new QueuedCruncher(aaptLocation, logger);
            sInstances.put(aaptLocation, queuedCruncher);
        }
        return sInstances.get(aaptLocation);
    }
}