Java Code Examples for org.gradle.api.logging.Logger#error()

The following examples show how to use org.gradle.api.logging.Logger#error() . 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: AwoInstaller.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Wait for the Android Debug Bridge to return an initial device list.
 */
protected static void waitForInitialDeviceList(final AndroidDebugBridge androidDebugBridge, Logger logger) {
    if (!androidDebugBridge.hasInitialDeviceList()) {
        logger.info("Waiting for initial device list from the Android Debug Bridge");
        long limitTime = System.currentTimeMillis() + ADB_TIMEOUT_MS;
        while (!androidDebugBridge.hasInitialDeviceList() && (System.currentTimeMillis() < limitTime)) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException("Interrupted waiting for initial device list from Android Debug Bridge");
            }
        }
        if (!androidDebugBridge.hasInitialDeviceList()) {
            logger.error("Did not receive initial device list from the Android Debug Bridge.");
        }
    }
}
 
Example 2
Source File: ProcessRealAndroidJar.java    From unmock-plugin with Apache License 2.0 6 votes vote down vote up
private static List<ClassMapping> parseClassesToMap(String[] renameClasses, Logger logger) {
    ArrayList<ClassMapping> result = new ArrayList<>();

    if (renameClasses == null) {
        return result;
    }

    for (String classRenaming : renameClasses) {
        int indexOfEquals = classRenaming.indexOf("=");
        if (indexOfEquals > 0 && indexOfEquals < classRenaming.length()) {
            String from = classRenaming.substring(0, indexOfEquals);
            String to = classRenaming.substring(indexOfEquals + 1);
            result.add(new ClassMapping(from, to));

        } else {
            logger.error("Unparseable mapping:" + classRenaming);
        }
    }

    return result;
}
 
Example 3
Source File: IgniteBaseTask.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void transcodeAllFilesInFolder(File inputFolder, File outputFolder,
        String outputClassNamePrefix, String outputFileNameExtension,
        String outputPackageName, LanguageRenderer languageRenderer,
        String templateFileName) {
    Logger logger = getLogger();

    File[] svgFiles = inputFolder.listFiles((File dir, String name) -> name.endsWith(".svg"));
    if (svgFiles == null) {
        return;
    }
    for (File file : svgFiles) {
        String svgClassName = outputClassNamePrefix
                + file.getName().substring(0, file.getName().length() - 4);
        svgClassName = svgClassName.replace('-', '_');
        svgClassName = svgClassName.replace(' ', '_');
        String classFilename =
                outputFolder + File.separator + svgClassName + outputFileNameExtension;

        logger.trace("Processing " + file.getName());

        try (Writer pw = new PrintWriter(classFilename);
             InputStream templateStream = SvgBatchBaseConverter.class
                     .getResourceAsStream(templateFileName)) {
            if (templateStream == null) {
                logger.error("Couldn't load " + templateFileName);
                return;
            }

            final CountDownLatch latch = new CountDownLatch(1);

            SvgTranscoder transcoder = new SvgTranscoder(file.toURI().toURL().toString(),
                    svgClassName, languageRenderer);
            transcoder.setPackageName(outputPackageName);
            transcoder.setListener(new TranscoderListener() {
                public Writer getWriter() {
                    return pw;
                }

                public void finished() {
                    latch.countDown();
                }
            });
            transcoder.transcode(templateStream);
            // Limit the processing to 10 seconds to prevent infinite hang
            latch.await(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            logger.error("Transcoding failed", e);
        }
    }
}
 
Example 4
Source File: GradleProjectUtilities.java    From steady with Apache License 2.0 4 votes vote down vote up
protected static String getMandatoryProjectProperty(Project project, GradleGavProperty property, Logger logger) {

        final String propertyName=property.name();

        logger.debug("Looking for property [{}] in project", propertyName);

        String propertyValue = null;

        if(project.hasProperty(propertyName)) {
            propertyValue = project.getProperties().get(propertyName).toString();
        }

        if (propertyValue == null || propertyValue.isEmpty() || propertyValue.equals("undefined")) {
            logger.error("Property [{}] is not defined, please define it!", propertyName);
            throw new GradleException();
        }

        logger.debug("Property found: {}={}", propertyName, propertyValue);

        return propertyValue;
    }
 
Example 5
Source File: AwoInstaller.java    From atlas with Apache License 2.0 4 votes vote down vote up
/**
 * no device or too many device make install fail
 *
 * @param name
 * @param patch
 * @return
 */
private static boolean installPatchIfDeviceConnected(AndroidBuilder androidBuilder, File patch, String patchPkg,
                                                     Logger logger, String name) {

    final AndroidDebugBridge androidDebugBridge = initAndroidDebugBridge(androidBuilder);

    if (!androidDebugBridge.isConnected()) {
        throw new RuntimeException("Android Debug Bridge is not connected.");
    }

    waitForInitialDeviceList(androidDebugBridge, logger);
    List<IDevice> devices = Arrays.asList(androidDebugBridge.getDevices());
    String PATCH_INSTALL_DIRECTORY = String.format("%s%s%s", PATCH_INSTALL_DIRECTORY_PREFIX, patchPkg,
                                                   PATCH_INSTALL_DIRECTORY_SUFFIX);
    if (devices.size() == 0) {
        throw new RuntimeException(String.format("%s%s%s%s%s",
                                                 "no device connected,please check whether the connection is "
                                                 + "successful or copy ", patch,
                                                 " in build/outputs/awbs/libxxx.so ", PATCH_INSTALL_DIRECTORY,
                                                 " and restart you app"));
    }
    if (devices.size() > 1) {
        throw new RuntimeException("too much devices be connected,please disconnect the others and try again");
    }
    CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
    executor.setLogger(logger);
    executor.setCaptureStdOut(true);
    executor.setCaptureStdErr(true);
    List<String> cmd = Arrays.asList("push", patch.getAbsolutePath(), PATCH_INSTALL_DIRECTORY + name);
    try {
        executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), cmd, false);
        return true;
    } catch (ExecutionException e) {
        throw new RuntimeException("Error while trying to push patch to device ", e);
    } finally {
        String errout = executor.getStandardError();
        if ((errout != null) && (errout.trim().length() > 0)) {
            logger.error(errout);
        }
    }
}