org.apache.tools.ant.taskdefs.Javac.log()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中org.apache.tools.ant.taskdefs.Javac.log()方法的一些代码示例,展示了Javac.log()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Javac.log()方法的具体详情如下:
包路径:org.apache.tools.ant.taskdefs.Javac
类名称:Javac
方法名:log

Javac.log介绍

暂无

代码示例

代码示例来源:origin: org.apache.ant/ant

private void setImplicitSourceSwitch(final Commandline cmd,
                   final String target, final String source) {
  attributes.log("", Project.MSG_WARN);
  attributes.log("          WARNING", Project.MSG_WARN);
  attributes.log("", Project.MSG_WARN);
  attributes.log("The -source switch defaults to " + getDefaultSource()
          + ".",
          Project.MSG_WARN);
  attributes.log("If you specify -target " + target
          + " you now must also specify -source " + source
          + ".", Project.MSG_WARN);
  attributes.log("Ant will implicitly add -source " + source
          + " for you.  Please change your build file.",
          Project.MSG_WARN);
  cmd.createArgument().setValue("-source");
  cmd.createArgument().setValue(source);
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Logs the compilation parameters, adds the files to compile and logs the
 * "niceSourceList"
 * @param cmd the command line
 */
protected void logAndAddFilesToCompile(final Commandline cmd) {
  attributes.log("Compilation " + cmd.describeArguments(), Project.MSG_VERBOSE);
  attributes.log(String.format("%s to be compiled:",
      compileList.length == 1 ? "File" : "Files"), Project.MSG_VERBOSE);
  attributes.log(Stream.of(compileList).map(File::getAbsolutePath)
          .peek(arg -> cmd.createArgument().setValue(arg))
          .map(arg -> String.format("    %s%n", arg))
          .collect(Collectors.joining("")), Project.MSG_VERBOSE);
}

代码示例来源:origin: org.apache.ant/ant

private void lookForPackageInfos(final File srcDir, final File[] newFiles) {
  for (File f : newFiles) {
    if (!"package-info.java".equals(f.getName())) {
      continue;
    }
    final String path = FILE_UTILS.removeLeadingPath(srcDir, f)
        .replace(File.separatorChar, '/');
    final String suffix = "/package-info.java";
    if (!path.endsWith(suffix)) {
      log("anomalous package-info.java path: " + path, Project.MSG_WARN);
      continue;
    }
    final String pkg = path.substring(0, path.length() - suffix.length());
    packageInfos.put(pkg, f.lastModified());
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Ensure that every {@code package-info.java} produced a {@code package-info.class}.
 * Otherwise this task's up-to-date tracking mechanisms do not work.
 * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a>
 */
private void generateMissingPackageInfoClasses(final File dest) throws IOException {
  for (final Map.Entry<String, Long> entry : packageInfos.entrySet()) {
    final String pkg = entry.getKey();
    final Long sourceLastMod = entry.getValue();
    final File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar));
    pkgBinDir.mkdirs();
    final File pkgInfoClass = new File(pkgBinDir, "package-info.class");
    if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod) {
      continue;
    }
    log("Creating empty " + pkgInfoClass);
    try (OutputStream os = Files.newOutputStream(pkgInfoClass.toPath())) {
      os.write(PACKAGE_INFO_CLASS_HEADER);
      final byte[] name = pkg.getBytes("UTF-8");
      final int length = name.length + /* "/package-info" */ 13;
      os.write((byte) length / 256);
      os.write((byte) length % 256);
      os.write(name);
      os.write(PACKAGE_INFO_CLASS_FOOTER);
    }
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
   * Run the compilation.
   * @return true if the compiler ran with a zero exit result (ok)
   * @exception BuildException if the compilation has problems.
   */
  @Override
  public boolean execute() throws BuildException {
    attributes.log("Using modern compiler", Project.MSG_VERBOSE);
    Commandline cmd = setupModernJavacCommand();

    // Use reflection to be able to build on all JDKs >= 1.1:
    try {
      Class<?> c = Class.forName("com.sun.tools.javac.Main");
      Object compiler = c.newInstance();
      Method compile = c.getMethod("compile", String[].class);
      int result = (Integer) compile.invoke(compiler,
          (Object) cmd.getArguments());
      return result == MODERN_COMPILER_SUCCESS;
    } catch (Exception ex) {
      if (ex instanceof BuildException) {
        throw (BuildException) ex;
      }
      throw new BuildException("Error starting modern compiler",
                   ex, location);
    }
  }
}

代码示例来源:origin: org.apache.ant/ant

/**
 * The implementation for this particular task.
 *
 * <p>Defaults to the build.compiler property but can be overridden
 * via the compiler and fork attributes.</p>
 *
 * <p>If fork has been set to true, the result will be extJavac
 * and not classic or java1.2 - no matter what the compiler
 * attribute looks like.</p>
 *
 * @see #getCompilerVersion
 * @return the compiler.
 * @since Ant 1.5
 */
public String getCompiler() {
  String compilerImpl = getCompilerVersion();
  if (fork) {
    if (isJdkCompiler(compilerImpl)) {
      compilerImpl = EXTJAVAC;
    } else {
      log("Since compiler setting isn't classic or modern, ignoring fork setting.",
        Project.MSG_WARN);
    }
  }
  return compilerImpl;
}

代码示例来源:origin: org.apache.ant/ant

attributes.log("Using classic compiler", Project.MSG_VERBOSE);
Commandline cmd = setupJavacCommand(true);

代码示例来源:origin: org.apache.ant/ant

/**
 * Performs a compile using the gcj compiler.
 * @return true if the compilation succeeded
 * @throws BuildException on error
 */
@Override
public boolean execute() throws BuildException {
  attributes.log("Using gcj compiler", Project.MSG_VERBOSE);
  Commandline cmd = setupGCJCommand();
  int firstFileName = cmd.size();
  logAndAddFilesToCompile(cmd);
  return
    executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
}

代码示例来源:origin: org.apache.ant/ant

log("Compiling " + compileList.length + " source file"
  + (compileList.length == 1 ? "" : "s")
  + (destDir != null ? " to " + destDir : ""));
   log(element.getAbsolutePath());
    throw new BuildException(FAIL_MSG, getLocation());
  log(FAIL_MSG, Project.MSG_ERR);

代码示例来源:origin: org.apache.ant/ant

/**
 * Run the compilation.
 * @return true if the compilation succeeded
 * @exception BuildException if the compilation has problems.
 */
@Override
public boolean execute() throws BuildException {
  attributes.log("Using kjc compiler", Project.MSG_VERBOSE);
  Commandline cmd = setupKjcCommand();
  cmd.setExecutable("at.dms.kjc.Main");
  ExecuteJava ej = new ExecuteJava();
  ej.setJavaCommand(cmd);
  return ej.fork(getJavac()) == 0;
}

代码示例来源:origin: org.apache.ant/ant

log(getLocation()
  + "warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds",
  Project.MSG_WARN);

代码示例来源:origin: org.apache.ant/ant

/**
 * Performs a compile using the sj compiler from Symantec.
 * @return true if the compilation succeeded
 * @throws BuildException on error
 */
@Override
public boolean execute() throws BuildException {
  attributes.log("Using symantec java compiler", Project.MSG_VERBOSE);
  Commandline cmd = setupJavacCommand();
  String exec = getJavac().getExecutable();
  cmd.setExecutable(exec == null ? "sj" : exec);
  int firstFileName = cmd.size() - compileList.length;
  return
    executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
}

代码示例来源:origin: org.apache.ant/ant

attributes.log("!! the build.compiler.warnings property is " + "deprecated. !!",
    Project.MSG_WARN);
attributes.log("!! Use the nowarn attribute instead. !!", Project.MSG_WARN);
if (!Project.toBoolean(warningsProperty)) {
  cmd.createArgument().setValue("-nowarn");

代码示例来源:origin: org.apache.ant/ant

/**
 * Performs a compile using the Javac externally.
 * @return true if the compilation succeeded
 * @throws BuildException on error
 */
@Override
public boolean execute() throws BuildException {
  attributes.log("Using external javac compiler", Project.MSG_VERBOSE);
  Commandline cmd = new Commandline();
  cmd.setExecutable(getJavac().getJavacExecutable());
  if (!assumeJava11() && !assumeJava12()) {
    setupModernJavacCommandlineSwitches(cmd);
  } else {
    setupJavacCommandlineSwitches(cmd, true);
  }
  int firstFileName = assumeJava11() ? -1 : cmd.size();
  logAndAddFilesToCompile(cmd);
  //On VMS platform, we need to create a special java options file
  //containing the arguments and classpath for the javac command.
  //The special file is supported by the "-V" switch on the VMS JVM.
  if (Os.isFamily("openvms")) {
    return execOnVMS(cmd, firstFileName);
  }
  return
      executeExternalCompile(cmd.getCommandline(), firstFileName,
          true)
      == 0;
}

代码示例来源:origin: org.apache.ant/ant

if (release == null || !assumeJava9Plus()) {
  if (release != null) {
    attributes.log(
      "Support for javac --release has been added in Java9 ignoring it");
    attributes.log(
      "Ignoring source, target and bootclasspath as release has been set",
      Project.MSG_WARN);
if (assumeJava13() || assumeJava14() || assumeJava15() || assumeJava16()
    || assumeJava17()) {
  attributes.log(
    "Support for javac -h has been added in Java8, ignoring it");
} else {

代码示例来源:origin: org.apache.ant/ant

if (memoryInitialSize != null) {
  if (!attributes.isForkedJavac()) {
    attributes.log(
      "Since fork is false, ignoring memoryInitialSize setting.",
      Project.MSG_WARN);
    attributes.log(
      "Since fork is false, ignoring memoryMaximumSize setting.",
      Project.MSG_WARN);
    cmd.createArgument().setValue("-Xdepend");
  } else {
    attributes.log(
      "depend attribute is not supported by the modern compiler",
      Project.MSG_WARN);

代码示例来源:origin: org.apache.ant/ant

attributes.log("Using jikes compiler", Project.MSG_VERBOSE);
    attributes.log("Jikes doesn't support '-source " + source
        + "', will use '-source 1.3' instead");
    cmd.createArgument().setValue("1.3");

代码示例来源:origin: org.apache.ant/ant

attributes.log("Using jvc compiler", Project.MSG_VERBOSE);

代码示例来源:origin: com.sun.xml.bind/jaxb-jxc

protected void logAndAddFilesToCompile(Commandline cmd) {
    attributes.log("Compilation " + cmd.describeArguments(),
            Project.MSG_VERBOSE);
    StringBuilder niceSourceList = new StringBuilder("File");
    if (compileList.length != 1) {
      niceSourceList.append("s");
    }
    niceSourceList.append(" to be compiled:");
    niceSourceList.append(lSep);
    StringBuilder tempbuilder = new StringBuilder();
    for (File aCompileList : compileList) {
      String arg = aCompileList.getAbsolutePath();
      // cmd.createArgument().setValue(arg); --> we don't need compile list withing cmd arguments
      tempbuilder.append("    ").append(arg).append(lSep);
      niceSourceList.append(tempbuilder);
      tempbuilder.setLength(0);
    }
    attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-tools

protected void logAndAddFilesToCompile(Commandline cmd) {
    attributes.log("Compilation " + cmd.describeArguments(),
            Project.MSG_VERBOSE);
    StringBuilder niceSourceList = new StringBuilder("File");
    if (compileList.length != 1) {
      niceSourceList.append("s");
    }
    niceSourceList.append(" to be compiled:");
    niceSourceList.append(lSep);
    StringBuilder tempbuilder = new StringBuilder();
    for (File aCompileList : compileList) {
      String arg = aCompileList.getAbsolutePath();
      // cmd.createArgument().setValue(arg); --> we don't need compile list withing cmd arguments
      tempbuilder.append("    ").append(arg).append(lSep);
      niceSourceList.append(tempbuilder);
      tempbuilder.setLength(0);
    }
    attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
  }
}

相关文章