Java Code Examples for org.gradle.api.logging.Logger#warn()
The following examples show how to use
org.gradle.api.logging.Logger#warn() .
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: VerifyJigEnvironmentTask.java From jig with Apache License 2.0 | 6 votes |
@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 2
Source File: JsHint.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
@TaskAction public void doJsHint() { RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(getWorkerProcessBuilderFactory()); 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 3
Source File: JsHint.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
@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 4
Source File: LoggingUtil.java From javaide with GNU General Public License v3.0 | 4 votes |
public static void displayWarning(Logger logger, Project project, String message) { logger.warn(createWarning(project.getPath(), message)); }
Example 5
Source File: JsHint.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@TaskAction public void doJsHint() { RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(getWorkerProcessBuilderFactory()); 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 6
Source File: JsHint.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@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")); } }