Java Code Examples for org.gradle.api.logging.Logger

The following examples show how to use org.gradle.api.logging.Logger. These examples are extracted from open source projects. 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
static WorkResult execute(ScalaJavaJointCompileSpec spec) {
    LOGGER.info("Compiling with Zinc Scala compiler.");

    xsbti.Logger logger = new SbtLoggerAdapter();

    com.typesafe.zinc.Compiler compiler = createCompiler(spec.getScalaClasspath(), spec.getZincClasspath(), logger);
    List<String> scalacOptions = new ScalaCompilerArgumentsGenerator().generate(spec);
    List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build();
    Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(),
            scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true);
    if (LOGGER.isDebugEnabled()) {
        Inputs.debug(inputs, logger);
    }

    try {
        compiler.compile(inputs, logger);
    } catch (xsbti.CompileFailed e) {
        throw new CompilationFailedException(e);
    }

    return new SimpleWorkResult(true);
}
 
Example 2
static WorkResult execute(ScalaJavaJointCompileSpec spec) {
    LOGGER.info("Compiling with Zinc Scala compiler.");

    xsbti.Logger logger = new SbtLoggerAdapter();

    com.typesafe.zinc.Compiler compiler = createCompiler(spec.getScalaClasspath(), spec.getZincClasspath(), logger);
    List<String> scalacOptions = new ScalaCompilerArgumentsGenerator().generate(spec);
    List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build();
    Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(),
            scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true);
    if (LOGGER.isDebugEnabled()) {
        Inputs.debug(inputs, logger);
    }

    try {
        compiler.compile(inputs, logger);
    } catch (xsbti.CompileFailed e) {
        throw new CompilationFailedException(e);
    }

    return new SimpleWorkResult(true);
}
 
Example 3
static WorkResult execute(ScalaJavaJointCompileSpec spec) {
    LOGGER.info("Compiling with Zinc Scala compiler.");

    xsbti.Logger logger = new SbtLoggerAdapter();

    com.typesafe.zinc.Compiler compiler = createCompiler(spec.getScalaClasspath(), spec.getZincClasspath(), logger);
    List<String> scalacOptions = new ScalaCompilerArgumentsGenerator().generate(spec);
    List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build();
    Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(),
            scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true);
    if (LOGGER.isDebugEnabled()) {
        Inputs.debug(inputs, logger);
    }

    try {
        compiler.compile(inputs, logger);
    } catch (xsbti.CompileFailed e) {
        throw new CompilationFailedException(e);
    }

    return new SimpleWorkResult(true);
}
 
Example 4
Source Project: firebase-android-sdk   Source File: StackdriverMetrics.java    License: Apache License 2.0 6 votes vote down vote up
StackdriverMetrics(Gradle gradle, Logger logger) {
  this.logger = logger;
  globalContext = deserializeContext();

  ensureStackdriver(gradle);

  Stats.getViewManager()
      .registerView(
          View.create(
              View.Name.create("fireci/tasklatency"),
              "The latency in milliseconds",
              M_LATENCY,
              Aggregation.LastValue.create(),
              TAG_KEYS));

  Stats.getViewManager()
      .registerView(
          View.create(
              View.Name.create("fireci/tasksuccess"),
              "Indicated success or failure.",
              M_SUCCESS,
              Aggregation.LastValue.create(),
              TAG_KEYS));
}
 
Example 5
Source Project: jig   Source File: VerifyJigEnvironmentTask.java    License: Apache License 2.0 6 votes vote down vote up
@TaskAction
void verify() {
    try {
        GraphvizCmdLineEngine graphvizCmdLineEngine = new GraphvizCmdLineEngine();
        GraphvizjView.confirmInstalledGraphviz(graphvizCmdLineEngine);
    } catch(RuntimeException e) {
        Logger logger = getLogger();
        logger.warn("-- JIG ERROR -----------------------------------------------");
        logger.warn("+ 実行可能なGraphvizが見つけられませんでした。");
        logger.warn("+ dotにPATHが通っているか確認してください。");
        logger.warn("+ JIGはダイアグラムの出力にGraphvizを使用しています。");
        logger.warn("+ ");
        logger.warn("+ Graphvizは以下から入手できます。");
        logger.warn("+     https://www.graphviz.org/");
        logger.warn("------------------------------------------------------------");

        throw e;
    }
}
 
Example 6
Source Project: steady   Source File: GradleProjectUtilities.java    License: Apache License 2.0 6 votes vote down vote up
protected static ProjectOutputTypes determineProjectOutputType(Project project, Logger logger) {

        ProjectOutputTypes projectOutputType = null;

        for ( String kp: knownPlugins.keySet()) {
            if (project.getPlugins().hasPlugin(kp)) {
                logger.quiet("Found plugin: " + kp);
                projectOutputType = knownPlugins.get(kp);
                break;
            }
        }

        if (projectOutputType != null) {
            logger.quiet("Project type determined: {}", projectOutputType.toString());
        }

        return projectOutputType;
    }
 
Example 7
Source Project: atlas   Source File: AwoInstaller.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * todo how know which app will be debugged?
 * just support taobao.apk now
 */
private static void notifyApppatching(AndroidBuilder androidBuilder, String patchPkg, Logger logger) {
    CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor();
    executor.setLogger(logger);
    executor.setCaptureStdOut(true);
    executor.setCaptureStdErr(true);
    //        List<String> killCmd = Arrays.asList("shell", "am", "force-stop", packageNameForPatch);
    //        List<String> startCmd = Arrays.asList("shell", "am", "start", packageNameForPatch + "/" +
    // launcherActivityForPatch);
    List<String> patchCmd = Arrays.asList("shell", "am", "broadcast", "-a", "com.taobao.atlas.intent.PATCH_APP",
                                          "-e", "pkg", patchPkg, "-n",
                                          patchPkg + "/com.taobao.atlas.update.AwoPatchReceiver");
    try {
        executor.executeCommand(androidBuilder.getSdkInfo().getAdb().getAbsolutePath(), patchCmd, false);
    } catch (Exception e) {
        throw new RuntimeException("error while restarting app,you can also restart by yourself", e);
    }
}
 
Example 8
static WorkResult execute(ScalaJavaJointCompileSpec spec) {
    LOGGER.info("Compiling with Zinc Scala compiler.");

    xsbti.Logger logger = new SbtLoggerAdapter();

    com.typesafe.zinc.Compiler compiler = createCompiler(spec.getScalaClasspath(), spec.getZincClasspath(), logger);
    List<String> scalacOptions = new ScalaCompilerArgumentsGenerator().generate(spec);
    List<String> javacOptions = new JavaCompilerArgumentsBuilder(spec).includeClasspath(false).build();
    Inputs inputs = Inputs.create(ImmutableList.copyOf(spec.getClasspath()), ImmutableList.copyOf(spec.getSource()), spec.getDestinationDir(),
            scalacOptions, javacOptions, spec.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile(), spec.getAnalysisMap(), "mixed", getIncOptions(), true);
    if (LOGGER.isDebugEnabled()) {
        Inputs.debug(inputs, logger);
    }

    try {
        compiler.compile(inputs, logger);
    } catch (xsbti.CompileFailed e) {
        throw new CompilationFailedException(e);
    }

    return new SimpleWorkResult(true);
}
 
Example 9
Source Project: atlas   Source File: TaobaoInstantRunDex.java    License: Apache License 2.0 6 votes vote down vote up
public TaobaoInstantRunDex(
        AppVariantContext variantContext,
        @NonNull InstantRunVariantScope transformVariantScope,
        DexByteCodeConverter dexByteCodeConverter,
        @NonNull DexOptions dexOptions,
        @NonNull Logger logger,
        int minSdkForDx,
        BaseVariantOutput variantOutput) {
    this.variantScope = transformVariantScope;
    this.variantContext = variantContext;
    this.dexByteCodeConverter = dexByteCodeConverter;
    this.dexOptions = dexOptions;
    this.logger = new LoggerWrapper(logger);
    this.minSdkForDx = minSdkForDx;
    this.variantOutput = variantOutput;
}
 
Example 10
Source Project: app-gradle-plugin   Source File: DevAppServerStartTask.java    License: Apache License 2.0 6 votes vote down vote up
/** Task entrypoint : start the dev appserver (non-blocking). */
@TaskAction
public void startAction() throws AppEngineException, IOException {

  // Add a listener to write to a file for non-blocking starts, this really only works
  // when the gradle daemon is running (which is default for newer versions of gradle)
  File logFile = new File(devAppServerLoggingDir, "dev_appserver.out");
  FileOutputLineListener logFileWriter = new FileOutputLineListener(logFile);

  Logger taskLogger = getLogger();
  ProcessHandler processHandler =
      LegacyProcessHandler.builder()
          .addStdOutLineListener(taskLogger::lifecycle)
          .addStdOutLineListener(logFileWriter)
          .addStdErrLineListener(taskLogger::lifecycle)
          .addStdErrLineListener(logFileWriter)
          .setExitListener(new NonZeroExceptionExitListener())
          .buildDevAppServerAsync(runConfig.getStartSuccessTimeout());

  devServers.newDevAppServer(processHandler).run(runConfig.toRunConfiguration());

  getLogger().lifecycle("Dev App Server output written to : " + logFile.getAbsolutePath());
}
 
Example 11
static com.typesafe.zinc.Compiler createCompiler(Iterable<File> scalaClasspath, Iterable<File> zincClasspath, xsbti.Logger logger) {
    ScalaLocation scalaLocation = ScalaLocation.fromPath(Lists.newArrayList(scalaClasspath));
    SbtJars sbtJars = SbtJars.fromPath(Lists.newArrayList(zincClasspath));
    Setup setup = Setup.create(scalaLocation, sbtJars, Jvm.current().getJavaHome(), true);
    if (LOGGER.isDebugEnabled()) {
        Setup.debug(setup, logger);
    }
    return com.typesafe.zinc.Compiler.getOrCreate(setup, logger);
}
 
Example 12
Source Project: javaccPlugin   Source File: CompiledJavaccFileTest.java    License: MIT License 5 votes vote down vote up
@Before
public void createCompiledJavaccFile() {
    outputDirectory = new File(getClass().getResource("/compiledJavaccFile/output").getFile());
    targetDirectory = new File(getClass().getResource("/compiledJavaccFile/target").getFile());
    logger = mock(Logger.class);
    
    Set<File> sourceTree = new HashSet<File>();
    sourceTree.add(new File(getClass().getResource("/compiledJavaccFile/customAstClasses").getFile()));
    customAstClassesDirectory = mock(FileTree.class);
    when(customAstClassesDirectory.getFiles()).thenReturn(sourceTree);
}
 
Example 13
Source Project: shipkit   Source File: DefaultProcessRunner.java    License: MIT License 5 votes vote down vote up
String run(Logger log, List<String> commandLine) {
    // WARNING!!! ensure that masked command line is used for all logging!!!
    String maskedCommandLine = mask(join(commandLine, " "));
    log.lifecycle("  Executing:\n    " + maskedCommandLine);

    ProcessResult result = executeProcess(commandLine, maskedCommandLine);

    if (result.getExitValue() != 0) {
        return executionOfCommandFailed(maskedCommandLine, result);
    } else {
        String output = result.getOutput();
        LOG.info("Output from external process '{}':\n{}", maskedCommandLine, output);
        return output;
    }
}
 
Example 14
@TaskAction
public void transcode() {
    Logger logger = getLogger();

    logger.trace("Working on files in " + inputRootDirectory.getAbsolutePath());

    if (!this.inputRootDirectory.exists()) {
        return;
    }

    this.outputRootDirectory.mkdirs();

    boolean renderAsKotlinCode = ("kotlin".compareTo(outputLanguage) == 0);

    LanguageRenderer languageRenderer = renderAsKotlinCode
            ? new KotlinLanguageRenderer()
            : new JavaLanguageRenderer();
    String outputFileNameExtension = ("java".compareTo(outputLanguage) == 0) ? ".java" : ".kt";

    logger.trace("Processing " + inputRootDirectory.getAbsolutePath() + " to " + outputRootPackageName +
            " in " + outputLanguage);

    String templateFileName = "/org/pushingpixels/photon/api/transcoder/" + outputLanguage + "/"
            + "SvgTranscoderTemplate";
    templateFileName += (useResizableTemplate ? "Resizable" : "Plain");
    templateFileName += ".templ";

    processFolder(inputRootDirectory, outputRootDirectory, outputClassNamePrefix, outputFileNameExtension,
            outputRootPackageName, languageRenderer, templateFileName);
}
 
Example 15
protected void processFolder(File inputFolder, File outputFolder,
        String outputClassNamePrefix, String outputFileNameExtension,
        String outputPackageName, LanguageRenderer languageRenderer,
        String templateFile) {

    Logger logger = getLogger();
    logger.trace("Working on files in " + inputFolder.getAbsolutePath());

    // Transcode all SVG files in this folder
    transcodeAllFilesInFolder(inputFolder, outputFolder, outputClassNamePrefix, outputFileNameExtension,
            outputPackageName, languageRenderer, templateFile);

    // Now scan the folder for sub-folders
    for (File inputSubfolder : inputFolder.listFiles((File dir, String name) -> new File(dir, name).isDirectory())) {
        String subfolderName = inputSubfolder.getName();
        logger.trace("Going into sub-folder " + subfolderName);

        // Mirror the input subfolder structure to the output
        File outputSubfolder = new File(outputFolder, subfolderName);
        if (!outputSubfolder.exists()) {
            outputSubfolder.mkdir();
        }

        // And recursively process SVG content (and possible folders)
        processFolder(inputSubfolder, outputSubfolder, outputClassNamePrefix, outputFileNameExtension,
                outputPackageName + "." + subfolderName, languageRenderer,
                templateFile);
    }
    System.out.println();
}
 
Example 16
Source Project: radiance   Source File: IgniteTask.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@TaskAction
public void transcode() {
    Logger logger = getLogger();

    logger.trace("Working on files in " + inputDirectory.getAbsolutePath());

    if (!this.inputDirectory.exists()) {
        return;
    }

    this.outputDirectory.mkdirs();

    boolean renderAsKotlinCode = ("kotlin".compareTo(outputLanguage) == 0);

    LanguageRenderer languageRenderer = renderAsKotlinCode
            ? new KotlinLanguageRenderer()
            : new JavaLanguageRenderer();
    String outputFileNameExtension = ("java".compareTo(outputLanguage) == 0) ? ".java" : ".kt";

    logger.trace("Processing " + inputDirectory.getAbsolutePath() + " to " + outputPackageName +
            " in " + outputLanguage);

    String templateFileName = "/org/pushingpixels/photon/api/transcoder/" + outputLanguage + "/"
            + "SvgTranscoderTemplate";
    templateFileName += (useResizableTemplate ? "Resizable" : "Plain");
    templateFileName += ".templ";

    this.transcodeAllFilesInFolder(inputDirectory, outputDirectory,
            outputClassNamePrefix, outputFileNameExtension,
            outputPackageName, languageRenderer, templateFileName);
}
 
Example 17
static com.typesafe.zinc.Compiler createCompiler(Iterable<File> scalaClasspath, Iterable<File> zincClasspath, xsbti.Logger logger) {
    ScalaLocation scalaLocation = ScalaLocation.fromPath(Lists.newArrayList(scalaClasspath));
    SbtJars sbtJars = SbtJars.fromPath(Lists.newArrayList(zincClasspath));
    Setup setup = Setup.create(scalaLocation, sbtJars, Jvm.current().getJavaHome(), true);
    if (LOGGER.isDebugEnabled()) {
        Setup.debug(setup, logger);
    }
    return com.typesafe.zinc.Compiler.getOrCreate(setup, logger);
}
 
Example 18
Source Project: javaccPlugin   Source File: CompiledJavaccFilesDirectoryFactory.java    License: MIT License 5 votes vote down vote up
public CompiledJavaccFilesDirectory getCompiledJavaccFilesDirectory(File outputDirectory, FileTree customAstClassesDirectory, File targetDirectory, Logger logger) {
    if ((outputDirectory == null) || !outputDirectory.exists() || !outputDirectory.isDirectory()) {
        throw new IllegalArgumentException("outputDirectory [" + outputDirectory + "] must be an existing directory");
    }
    
    if (customAstClassesDirectory == null) {
        throw new IllegalArgumentException("customAstClassesDirectory [" + outputDirectory + "] must not be null");
    }
    
    if ((targetDirectory == null) || !targetDirectory.exists() || !targetDirectory.isDirectory()) {
        throw new IllegalArgumentException("targetDirectory [" + targetDirectory + "] must be an existing directory");
    }
    
    return new CompiledJavaccFilesDirectory(outputDirectory, customAstClassesDirectory, targetDirectory, logger);
}
 
Example 19
static com.typesafe.zinc.Compiler createCompiler(Iterable<File> scalaClasspath, Iterable<File> zincClasspath, xsbti.Logger logger) {
    ScalaLocation scalaLocation = ScalaLocation.fromPath(Lists.newArrayList(scalaClasspath));
    SbtJars sbtJars = SbtJars.fromPath(Lists.newArrayList(zincClasspath));
    Setup setup = Setup.create(scalaLocation, sbtJars, Jvm.current().getJavaHome(), true);
    if (LOGGER.isDebugEnabled()) {
        Setup.debug(setup, logger);
    }
    return com.typesafe.zinc.Compiler.getOrCreate(setup, logger);
}
 
Example 20
Source Project: atlas   Source File: ResourcesShrinker.java    License: Apache License 2.0 5 votes vote down vote up
public ResourcesShrinker(ShrinkResourcesTransform resourcesTransform, @NonNull BaseVariantData variantData,
                         @NonNull FileCollection uncompressedResources,
                         @NonNull File compressedResources,
                         @NonNull AaptGeneration aaptGeneration,
                         @NonNull FileCollection splitListInput,
                         @NonNull Logger logger,
                         AppVariantContext variantContext) {

    this.variantContext = variantContext;
    this.resourcesTransform = resourcesTransform;
    VariantScope variantScope = variantData.getScope();
    GlobalScope globalScope = variantScope.getGlobalScope();
    GradleVariantConfiguration variantConfig = variantData.getVariantConfiguration();

    this.variantData = variantData;
    this.logger = logger;

    this.sourceDir = variantScope.getRClassSourceOutputDir();
    this.resourceDir = variantScope.getOutput(TaskOutputHolder.TaskOutputType.MERGED_NOT_COMPILED_RES);
    this.mappingFileSrc =
            variantScope.hasOutput(TaskOutputHolder.TaskOutputType.APK_MAPPING)
                    ? variantScope.getOutput(TaskOutputHolder.TaskOutputType.APK_MAPPING)
                    : null;
    this.mergedManifests = variantScope.getOutput(TaskOutputHolder.TaskOutputType.MERGED_MANIFESTS);
    this.uncompressedResources = uncompressedResources;
    this.splitListInput = splitListInput;

    this.aaptGeneration = aaptGeneration;
    this.aaptOptions = globalScope.getExtension().getAaptOptions();
    this.variantType = variantData.getType();
    this.isDebuggableBuildType = variantConfig.getBuildType().isDebuggable();
    this.multiOutputPolicy = variantData.getOutputScope().getMultiOutputPolicy();
    this.compressedResources = compressedResources;
}
 
Example 21
public GradleBuildComparison(
        ComparableGradleBuildExecuter sourceBuildExecuter,
        ComparableGradleBuildExecuter targetBuildExecuter,
        Logger logger,
        ProgressLogger progressLogger,
        Gradle gradle) {
    this.sourceBuildExecuter = sourceBuildExecuter;
    this.targetBuildExecuter = targetBuildExecuter;
    this.logger = logger;
    this.progressLogger = progressLogger;
    this.gradle = gradle;
}
 
Example 22
Source Project: javaccPlugin   Source File: CompiledJavaccFile.java    License: MIT License 5 votes vote down vote up
CompiledJavaccFile(File file, File outputDirectory, FileTree customAstClassesDirectory, File targetDirectory, Logger logger) {
    this.compiledJavaccFile = file;
    this.outputDirectory = outputDirectory;
    this.customAstClassesDirectory = customAstClassesDirectory;
    this.targetDirectory = targetDirectory;
    this.logger = logger;
}
 
Example 23
Source Project: javaide   Source File: ProductFlavorFactory.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ProductFlavorFactory(@NonNull Instantiator instantiator,
                            @NonNull Project project,
                            @NonNull Logger logger) {
    this.instantiator = instantiator;
    this.project = project;
    this.logger = logger;
}
 
Example 24
Source Project: javaccPlugin   Source File: JavaccSourceFileCompilerTest.java    License: MIT License 4 votes vote down vote up
private Logger givenLogger() {
    return mock(Logger.class);
}
 
Example 25
Source Project: pygradle   Source File: PipInstallAction.java    License: Apache License 2.0 4 votes vote down vote up
@Override
Logger getLogger() {
    return logger;
}
 
Example 26
public DeviceFarmClientFactory(final Logger logger) {
    this.pluginVersion = readPluginVersion();
    logger.lifecycle("AWS Device Farm Plugin version " + pluginVersion);
}
 
Example 27
@SuppressWarnings("UnusedDeclaration")
@TaskAction
void compare() {
    GradleBuildInvocationSpec sourceBuild = getSourceBuild();
    GradleBuildInvocationSpec targetBuild = getTargetBuild();

    if (sourceBuild.equals(targetBuild)) {
        getLogger().warn("The source build and target build are identical. Set '{}.targetBuild.gradleVersion' if you want to compare with a different Gradle version.", getName());
    }

    ComparableGradleBuildExecuter sourceBuildExecuter = new ComparableGradleBuildExecuter(sourceBuild);
    ComparableGradleBuildExecuter targetBuildExecuter = new ComparableGradleBuildExecuter(targetBuild);

    Logger logger = getLogger();
    ProgressLogger progressLogger = getProgressLoggerFactory().newOperation(getClass());
    progressLogger.setDescription("Gradle Build Comparison");
    progressLogger.setShortDescription(getName());

    GradleBuildComparison comparison = new GradleBuildComparison(
            sourceBuildExecuter, targetBuildExecuter,
            logger, progressLogger,
            getProject().getGradle()
    );

    comparison.registerType(
            GeneratedArchiveBuildOutcome.class,
            new GeneratedArchiveBuildOutcomeComparator(),
            new GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer(),
            new GeneratedArchiveBuildOutcomeHtmlRenderer()
    );

    comparison.registerType(
            UnknownBuildOutcome.class,
            new UnknownBuildOutcomeComparator(),
            new UnknownBuildOutcomeComparisonResultHtmlRenderer(),
            new UnknownBuildOutcomeHtmlRenderer()
    );

    File fileStoreTmpBase = getFileResolver().resolve(String.format(TMP_FILESTORAGE_PREFIX + "-%s-%s", getName(), System.currentTimeMillis()));
    FileStore<String> fileStore = new PathNormalisingKeyFileStore(fileStoreTmpBase);

    Map<String, String> hostAttributes = new LinkedHashMap<String, String>(4);
    hostAttributes.put("Project", getProject().getRootDir().getAbsolutePath());
    hostAttributes.put("Task", getPath());
    hostAttributes.put("Gradle version", GradleVersion.current().getVersion());
    hostAttributes.put("Executed at", new SimpleDateFormat().format(new Date()));

    BuildComparisonResult result = comparison.compare(fileStore, getReportDir(), hostAttributes);
    communicateResult(result);
}
 
Example 28
protected Logger getLogger() {
    return logger;
}
 
Example 29
Source Project: Pushjet-Android   Source File: JsHint.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@TaskAction
public void doJsHint() {
    RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);

    LogLevel logLevel = getProject().getGradle().getStartParameter().getLogLevel();
    RhinoWorkerHandle<JsHintResult, JsHintSpec> rhinoHandle = handleFactory.create(getRhinoClasspath(), createWorkerSpec(), logLevel, new Action<JavaExecSpec>() {
        public void execute(JavaExecSpec javaExecSpec) {
            javaExecSpec.setWorkingDir(getProject().getProjectDir());
        }
    });

    JsHintSpec spec = new JsHintSpec();
    spec.setSource(getSource().getFiles()); // flatten because we need to serialize
    spec.setEncoding(getEncoding());
    spec.setJsHint(getJsHint().getSingleFile());

    JsHintResult result = rhinoHandle.process(spec);
    setDidWork(true);

    // TODO - this is all terribly lame. We need some proper reporting here (which means implementing Reporting).

    Logger logger = getLogger();
    boolean anyErrors = false;

    Map<String, Map<?, ?>> reportData = new LinkedHashMap<String, Map<?, ?>>(result.getResults().size());
    for (Map.Entry<File, Map<String, Object>> fileEntry: result.getResults().entrySet()) {
        File file = fileEntry.getKey();
        Map<String, Object> data = fileEntry.getValue();

        reportData.put(file.getAbsolutePath(), data);

        if (data.containsKey("errors")) {
            anyErrors = true;

            URI projectDirUri = getProject().getProjectDir().toURI();
            @SuppressWarnings("unchecked") Map<String, Object> errors = (Map<String, Object>) data.get("errors");
            if (!errors.isEmpty()) {
                URI relativePath = projectDirUri.relativize(file.toURI());
                logger.warn("JsHint errors for file: {}", relativePath.getPath());
                for (Map.Entry<String, Object> errorEntry : errors.entrySet()) {
                    @SuppressWarnings("unchecked") Map<String, Object> error = (Map<String, Object>) errorEntry.getValue();
                    int line = Float.valueOf(error.get("line").toString()).intValue();
                    int character = Float.valueOf(error.get("character").toString()).intValue();
                    String reason = error.get("reason").toString();

                    logger.warn("  {}:{} > {}", new Object[] {line, character, reason});
                }
            }
        }
    }

    File jsonReportFile = getJsonReport();
    if (jsonReportFile != null) {
        try {
            FileWriter reportWriter = new FileWriter(jsonReportFile);
            new GsonBuilder().setPrettyPrinting().create().toJson(reportData, reportWriter);
            reportWriter.close();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    if (anyErrors) {
        throw new TaskExecutionException(this, new GradleException("JsHint detected errors"));
    }
}
 
Example 30
public Logger getLogger() {
    return LOGGER;
}