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

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

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

Javac.getCompilerVersion介绍

[英]The implementation for this particular task.

Defaults to the build.compiler property but can be overridden via the compiler attribute.

This method does not take the fork attribute into account.
[中]此特定任务的实现。
默认为生成。编译器属性,但可以通过编译器属性重写。
此方法不考虑fork属性。

代码示例

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

/**
 * Shall we assume JDK 1.3 command line switches?
 * @return true if jdk 1.3
 * @since Ant 1.5
 */
protected boolean assumeJava13() {
  return "javac1.3".equals(attributes.getCompilerVersion());
}

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

/**
 * Shall we assume JDK 1.2 command line switches?
 * @return true if jdk 1.2
 * @since Ant 1.5
 */
protected boolean assumeJava12() {
  return "javac1.2".equals(attributes.getCompilerVersion());
}

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

/**
 * Shall we assume JDK 1.1 command line switches?
 * @return true if jdk 1.1
 * @since Ant 1.5
 */
protected boolean assumeJava11() {
  return "javac1.1".equals(attributes.getCompilerVersion());
}

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

/**
 * Shall we assume command line switches for the given version of Java?
 * @since Ant 1.8.3
 */
private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) {
  return javacXY.equals(attributes.getCompilerVersion())
    || (JavaEnvUtils.isJavaVersion(javaEnvVersionXY)
      && ("classic".equals(attributes.getCompilerVersion())
       || "modern".equals(attributes.getCompilerVersion())
       || "extJavac".equals(attributes.getCompilerVersion())));
}

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

/**
 * Shall we assume JDK 9+ command line switches?
 * @return true if JDK 9+
 * @since Ant 1.10.2
 */
protected boolean assumeJava9Plus() {
  return "javac1.9".equals(attributes.getCompilerVersion())
    || "javac9".equals(attributes.getCompilerVersion())
    || "javac10+".equals(attributes.getCompilerVersion())
    || (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)
      && ("classic".equals(attributes.getCompilerVersion())
      || "modern".equals(attributes.getCompilerVersion())
      || "extJavac".equals(attributes.getCompilerVersion())));
}

代码示例来源: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: com.sun.xml.ws/jaxws-tools

@Override
protected void checkParameters() throws BuildException {
  super.checkParameters();
  if (sourceDestDir == null) {
    throw new BuildException("destination source directory must be set", getLocation());
  }
  if (!sourceDestDir.isDirectory()) {
    throw new BuildException("destination source directory \"" + sourceDestDir + "\" does not exist or is not a directory",
        getLocation());
  }
  try {
    Matcher matcher = VERSION_PATTERN.matcher(super.getCompilerVersion());
    if (matcher.find()) {
      float version = Float.valueOf(matcher.group(1));
      if (version < 1.6) {
        throw new BuildException("Annotation processing task requires Java 1.6+", getLocation());
      }
    }
  } catch (Exception e) {
    log("Can't check version for annotation processing task");
  }
}

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

@Override
protected void checkParameters() throws BuildException {
  super.checkParameters();
  if (sourceDestDir == null) {
    throw new BuildException("destination source directory must be set", getLocation());
  }
  if (!sourceDestDir.isDirectory()) {
    throw new BuildException("destination source directory \"" + sourceDestDir + "\" does not exist or is not a directory",
        getLocation());
  }
  try {
    Matcher matcher = VERSION_PATTERN.matcher(super.getCompilerVersion());
    if (matcher.find()) {
      float version = Float.valueOf(matcher.group(1));
      if (version < 1.6) {
        throw new BuildException("Annotation processing task requires Java 1.6+", getLocation());
      }
    }
  } catch (Exception e) {
    log("Can't check version for annotation processing task");
  }
}

代码示例来源:origin: javaee/metro-jax-ws

@Override
protected void checkParameters() throws BuildException {
  super.checkParameters();
  if (sourceDestDir == null) {
    throw new BuildException("destination source directory must be set", getLocation());
  }
  if (!sourceDestDir.isDirectory()) {
    throw new BuildException("destination source directory \"" + sourceDestDir + "\" does not exist or is not a directory",
        getLocation());
  }
  try {
    Matcher matcher = VERSION_PATTERN.matcher(super.getCompilerVersion());
    if (matcher.find()) {
      float version = Float.valueOf(matcher.group(1));
      if (version < 1.6) {
        throw new BuildException("Annotation processing task requires Java 1.6+", getLocation());
      }
    }
  } catch (Exception e) {
    log("Can't check version for annotation processing task");
  }
}

代码示例来源:origin: javaee/metro-jax-ws

@Override
protected void checkParameters() throws BuildException {
  super.checkParameters();
  if (sourceDestDir == null) {
    throw new BuildException("destination source directory must be set", getLocation());
  }
  if (!sourceDestDir.isDirectory()) {
    throw new BuildException("destination source directory \"" + sourceDestDir + "\" does not exist or is not a directory",
        getLocation());
  }
  try {
    Matcher matcher = VERSION_PATTERN.matcher(super.getCompilerVersion());
    if (matcher.find()) {
      float version = Float.valueOf(matcher.group(1));
      if (version < 1.6) {
        throw new BuildException("Annotation processing task requires Java 1.6+", getLocation());
      }
    }
  } catch (Exception e) {
    log("Can't check version for annotation processing task");
  }
}

相关文章

微信公众号

最新文章

更多