/** * Logs a message through the project object if one has been provided. * * @param message The message to log. * Should not be <code>null</code>. * * @param priority The logging priority of the message. */ protected void log(String message, int priority) { if (project != null) { project.log(message, priority); } }
/** * Write a message to the log with the default log level * of MSG_INFO . * @param message The text to log. Should not be <code>null</code>. */ public void log(final String message) { log(message, MSG_INFO); }
/** * Write a project level message to the log with the given log level. * @param message The text to log. Should not be <code>null</code>. * @param msgLevel The log priority level to use. */ public void log(final String message, final int msgLevel) { log(message, null, msgLevel); }
/** * Write a target level message to the log with the given log level. * @param target The target to use in the log. * Must not be <code>null</code>. * @param message The text to log. Should not be <code>null</code>. * @param msgLevel The log priority level to use. */ public void log(final Target target, final String message, final int msgLevel) { log(target, message, null, msgLevel); }
private static void log(final Project project, final String message, final int level) { if (project == null) { System.out.println(message); } else { project.log(message, level); } }
/** * Add a reference to the project. * * @param referenceName The name of the reference. Must not be <code>null</code>. * @param value The value of the reference. */ public void addReference(final String referenceName, final Object value) { final Object old = ((AntRefTable) references).getReal(referenceName); if (old == value) { // no warning, this is not changing anything return; } if (old != null && !(old instanceof UnknownElement)) { log("Overriding previous definition of reference to " + referenceName, MSG_VERBOSE); } log("Adding reference: " + referenceName, MSG_DEBUG); references.put(referenceName, value); }
/** * Logs a message through the project object if one has been provided. * * @param message The message to log. * Should not be <code>null</code>. * * @param priority The logging priority of the message. */ protected void log(final String message, final int priority) { if (project != null) { project.log(message, priority); } else if (priority < Project.MSG_INFO) { System.err.println(message); } }
@Override public void startFileAnalysis(DataSource dataSource) { project.log("Processing file " + dataSource.getNiceFileName(false, inputPaths), Project.MSG_VERBOSE); }
/** * Utility method that will throw a {@link BuildException} * if {@link #failOnError} is true else it just displays * a warning. */ private void missingExtension() { final String message = "Unable to resolve extension to a file"; if (failOnError) { throw new BuildException(message); } getProject().log(message, Project.MSG_ERR); }
/** * Add a target to the project, or replaces one with the same * name. * * @param targetName The name to use for the target. * Must not be <code>null</code>. * @param target The target to be added or replaced in the project. * Must not be <code>null</code>. */ public void addOrReplaceTarget(final String targetName, final Target target) { final String msg = " +Target: " + targetName; log(msg, MSG_DEBUG); target.setProject(this); targets.put(targetName, target); }
private void applyReflectionHackForExtensionMethods() { // Jigsaw doesn't allow reflection to work, so we can stop trying if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { try { // #51668, #52382 final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); _isNotSecureProcessing.setAccessible(true); _isNotSecureProcessing.set(tfactory, Boolean.TRUE); } catch (final Exception x) { if (project != null) { project.log(x.toString(), Project.MSG_DEBUG); } } } }
private void setupClassLoader() { try { if (auxClasspath != null) { project.log("Using auxclasspath: " + auxClasspath, Project.MSG_VERBOSE); configuration.prependClasspath(auxClasspath.toString()); } } catch (IOException ioe) { throw new BuildException(ioe.getMessage(), ioe); } }
private void logRulesUsed(RuleSets rules) { project.log("Using these rulesets: " + configuration.getRuleSets(), Project.MSG_VERBOSE); RuleSet[] ruleSets = rules.getAllRuleSets(); for (RuleSet ruleSet : ruleSets) { for (Rule rule : ruleSet.getRules()) { project.log("Using rule " + rule.getName(), Project.MSG_VERBOSE); } } } }
/** * Prints the description of a project (if there is one) to * <code>System.out</code>. * * @param project The project to display a description of. * Must not be <code>null</code>. */ private static void printDescription(final Project project) { if (project.getDescription() != null) { project.log(project.getDescription()); } }
private static OutputStream getOutputStream(final Resource resource, final boolean append, final Project project) throws IOException { if (append) { final Appendable a = resource.as(Appendable.class); if (a != null) { return a.getAppendOutputStream(); } String msg = "Appendable OutputStream not available for non-appendable resource " + resource + "; using plain OutputStream"; if (project != null) { project.log(msg, Project.MSG_VERBOSE); } else { System.out.println(msg); } } return resource.getOutputStream(); }
/** * Demultiplex output so that each task receives the appropriate * messages. If the current thread is not currently executing a task, * the message is logged directly. * * @param output Message to handle. Should not be <code>null</code>. * @param isWarning Whether the text represents an warning (<code>true</code>) * or information (<code>false</code>). */ public void demuxOutput(final String output, final boolean isWarning) { final Task task = getThreadTask(Thread.currentThread()); if (task == null) { log(output, isWarning ? MSG_WARN : MSG_INFO); } else if (isWarning) { task.handleErrorOutput(output); } else { task.handleOutput(output); } }
/** * Logs a message with the given priority. This delegates * the actual logging to the project. * * @param msg The message to be logged. Should not be <code>null</code>. * @param msgLevel The message priority at which this message is to * be logged. */ public void log(String msg, int msgLevel) { if (getProject() == null) { super.log(msg, msgLevel); } else { getProject().log(this, msg, msgLevel); } }
/** * Logs a message with the given priority. This delegates * the actual logging to the project. * * @param msg The message to be logged. Should not be <code>null</code>. * @param t The exception to be logged. May be <code>null</code>. * @param msgLevel The message priority at which this message is to * be logged. * @since 1.7 */ public void log(String msg, Throwable t, int msgLevel) { if (getProject() == null) { super.log(msg, msgLevel); } else { getProject().log(this, msg, t, msgLevel); } }
private ResourceLoader setupResourceLoader() { if (classpath == null) { classpath = new Path(project); } /* * 'basedir' is added to the path to make sure that relative paths such * as "<ruleset>resources/custom_ruleset.xml</ruleset>" still work when * ant is invoked from a different directory using "-f" */ classpath.add(new Path(null, project.getBaseDir().toString())); project.log("Using the AntClassLoader: " + classpath, Project.MSG_VERBOSE); // must be true, otherwise you'll get ClassCastExceptions as classes // are loaded twice // and exist in multiple class loaders final boolean parentFirst = true; return new ResourceLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(), project, classpath, parentFirst)); }
/** * @since Ant 1.10.3 */ @Override protected boolean areIiopAndIdlSupported() { boolean supported = !JavaEnvUtils.isAtLeastJavaVersion("11"); if (!supported && getRmic().getExecutable() != null) { getRmic().getProject() .log("Allowing -iiop and -idl for forked rmic even though this version of Java doesn't support it.", Project.MSG_INFO); return true; } return supported; }