当前位置: 首页>>代码示例>>Java>>正文


Java JavaEnvUtils类代码示例

本文整理汇总了Java中org.apache.tools.ant.util.JavaEnvUtils的典型用法代码示例。如果您正苦于以下问题:Java JavaEnvUtils类的具体用法?Java JavaEnvUtils怎么用?Java JavaEnvUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaEnvUtils类属于org.apache.tools.ant.util包,在下文中一共展示了JavaEnvUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
    String src = getSource();
    if (src.matches("\\d+")) {
        src = "1." + src;
    }
    if (!JavaEnvUtils.isAtLeastJavaVersion(src)) {
        log("Cannot handle -source " + src + " from this VM; forking " + maybeFork, Project.MSG_WARN);
        super.setFork(true);
        super.setExecutable(maybeFork);
    }
    generatedClassesDir = new File(getDestdir().getParentFile(), getDestdir().getName() + "-generated");
    if (!usingExplicitIncludes) {
        cleanUpStaleClasses();
    }
    cleanUpDependDebris();
    super.execute();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CustomJavac.java

示例2: setup

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  javaPath = System.getProperty("javaExec", JavaEnvUtils.getJreExecutable("java"));

  heapDumpFolder = tempFolder.newFolder("heap_dumps");

  jvm = System.getProperty("jvm", "unknown-jvm");
  jarsDir = new File(System.getProperty("jarsDir", "build/libs")).getAbsoluteFile();
  dumpsDir = new File(System.getProperty("dumpsDir", "build/oom")).getAbsoluteFile();
  version = System.getProperty("version", "0.0.1-SNAPSHOT");

  if (dumpsDir.exists()) {
    if (!dumpsDir.isDirectory()) {
      throw new IllegalStateException("Dumps folder not a directory: " + dumpsDir);
    }
  } else if (!dumpsDir.mkdirs()) {
    throw new IllegalStateException("Cannot create dumps folder: " + dumpsDir);
  }
}
 
开发者ID:SAP,项目名称:java-memory-assistant,代码行数:20,代码来源:E2eITest.java

示例3: doReportAntProperties

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * Report the content of ANT_HOME/lib directory
 * @param out the stream to print the content to
 */
private static void doReportAntProperties(PrintStream out) {
    Project p = new Project();
    p.initProperties();
    out.println(MagicNames.ANT_VERSION + ": " + p.getProperty(MagicNames.ANT_VERSION));
    out.println(MagicNames.ANT_JAVA_VERSION + ": "
            + p.getProperty(MagicNames.ANT_JAVA_VERSION));
    out.println("Is this the Apache Harmony VM? "
                + (JavaEnvUtils.isApacheHarmony() ? "yes" : "no"));
    out.println("Is this the Kaffe VM? "
                + (JavaEnvUtils.isKaffe() ? "yes" : "no"));
    out.println("Is this gij/gcj? "
                + (JavaEnvUtils.isGij() ? "yes" : "no"));
    out.println(MagicNames.ANT_LIB + ": " + p.getProperty(MagicNames.ANT_LIB));
    out.println(MagicNames.ANT_HOME + ": " + p.getProperty(MagicNames.ANT_HOME));
}
 
开发者ID:apache,项目名称:ant,代码行数:20,代码来源:Diagnostics.java

示例4: configureForRedirectExtension

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * If we end up using the JDK's own TraX factory on Java 9+, then
 * set the features and attributes necessary to allow redirect
 * extensions to be used.
 * @since Ant 1.9.8
 */
protected void configureForRedirectExtension() {
    XSLTProcess.Factory factory = createFactory();
    String factoryName = factory.getName();
    if (factoryName == null) {
        try {
            factoryName = TransformerFactory.newInstance().getClass().getName();
        } catch (TransformerFactoryConfigurationError exc) {
            throw new BuildException(exc);
        }
    }
    if (JDK_INTERNAL_FACTORY.equals(factoryName)
        && JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
        factory.addFeature(new XSLTProcess.Factory.Feature(
            "http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions",
            true));
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:AggregateTransformer.java

示例5: compile

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * Performs the actual compilation.
 * @param javah the calling javah task.
 * @return true if the compilation was successful.
 * @throws BuildException if there is an error.
 */
@Override
public boolean compile(Javah javah) throws BuildException {
    Commandline cmd = SunJavah.setupJavahCommand(javah);
    Project project = javah.getProject();
    String executable = JavaEnvUtils.getJdkExecutable("javah");
    javah.log("Running " + executable, Project.MSG_VERBOSE);
    cmd.setExecutable(executable);

    //set up the args
    String[] args = cmd.getCommandline();

    try {
        Execute exe = new Execute(new LogStreamHandler(javah,
                Project.MSG_INFO,
                Project.MSG_WARN));
        exe.setAntRun(project);
        exe.setWorkingDirectory(project.getBaseDir());
        exe.setCommandline(args);
        exe.execute();
        return !exe.isFailure();
    } catch (IOException exception) {
        throw new BuildException("Error running " + executable
                + " -maybe it is not on the path", exception);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:32,代码来源:ForkingJavah.java

示例6: setupCommandLineForVMS

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * On VMS platform, we need to create a special java options file
 * containing the arguments and classpath for the java command.
 * The special file is supported by the "-V" switch on the VMS JVM.
 *
 * @param exe the Execute instance to alter.
 * @param command the command-line.
 */
public static void setupCommandLineForVMS(Execute exe, String[] command) {
    //Use the VM launcher instead of shell launcher on VMS
    exe.setVMLauncher(true);
    File vmsJavaOptionFile = null;
    try {
        String[] args = new String[command.length - 1];
        System.arraycopy(command, 1, args, 0, command.length - 1);
        vmsJavaOptionFile = JavaEnvUtils.createVmsJavaOptionFile(args);
        //we mark the file to be deleted on exit.
        //the alternative would be to cache the filename and delete
        //after execution finished, which is much better for long-lived runtimes
        //though spawning complicates things...
        vmsJavaOptionFile.deleteOnExit();
        String[] vmsCmd = {command[0], "-V", vmsJavaOptionFile.getPath()};
        exe.setCommandline(vmsCmd);
    } catch (IOException e) {
        throw new BuildException("Failed to create a temporary file for \"-V\" switch");
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:28,代码来源:ExecuteJava.java

示例7: execOnVMS

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * helper method to execute our command on VMS.
 * @param cmd Commandline
 * @param firstFileName int
 * @return boolean
 */
private boolean execOnVMS(Commandline cmd, int firstFileName) {
    File vmsFile = null;
    try {
        vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments());
        String[] commandLine = {cmd.getExecutable(),
                                "-V",
                                vmsFile.getPath()};
        return 0 == executeExternalCompile(commandLine,
                        firstFileName,
                        true);

    } catch (IOException e) {
        throw new BuildException(
            "Failed to create a temporary file for \"-V\" switch");
    } finally {
        FileUtils.delete(vmsFile);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:25,代码来源:JavacExternal.java

示例8: eval

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * Evaluate the condition.
 * @return true if there enough free space.
 * @throws BuildException if there is a problem.
 */
@Override
public boolean eval() throws BuildException {
    validate();
    try {
        if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
            //reflection to avoid bootstrap/build problems
            File fs = new File(partition);
            ReflectWrapper w = new ReflectWrapper(fs);
            long free = w.<Long> invoke("getFreeSpace").longValue();
            return free >= StringUtils.parseHumanSizes(needed);
        }
        throw new BuildException(
            "HasFreeSpace condition not supported on Java5 or less.");
    } catch (Exception e) {
        throw new BuildException(e);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:HasFreeSpace.java

示例9: assumedJavaVersion

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
private String assumedJavaVersion() {
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
        return JAVAC14;
    }
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
        return JAVAC15;
    }
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
        return JAVAC16;
    }
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
        return JAVAC17;
    }
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
        return JAVAC18;
    }
    if (JavaEnvUtils.isAtLeastJavaVersion("10")) {
        return JAVAC10_PLUS;
    }
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
        return JAVAC9;
    }
    return CLASSIC;
}
 
开发者ID:apache,项目名称:ant,代码行数:25,代码来源:Javac.java

示例10: testFieldRefDepend

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
public void testFieldRefDepend() {
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)
        || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
        || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) {
        return;
    }
    
    String class1 = "mod.fieldrefdepend.ClassDependsOnReferenceInFieldDeclaration";
    String class2 = "mod.dummy.DummyClass";
    expectDesignCheckFailure("testFieldRefDepend", Design.getErrorMessage(class1, class2));
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:12,代码来源:VerifyDesignTest.java

示例11: testLocalVarRefDepend

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
public void testLocalVarRefDepend() {
    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)
        || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
        || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) {
        return;
    }
    String class1 = "mod.localvarrefdepend.ClassDependsOnLocalVariableReference";
    String class2 = "mod.dummy.DummyInterface";
    expectDesignCheckFailure("testLocalVarRefDepend", Design.getErrorMessage(class1, class2));
}
 
开发者ID:cniweb,项目名称:ant-contrib,代码行数:11,代码来源:VerifyDesignTest.java

示例12: forkeExecute

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
public boolean forkeExecute() throws Exception {
          Commandline cmd = new Commandline();
   F3AntTask task = (F3AntTask)getJavac();
          String executable = getJavac().getExecutable();
          if (executable != null) {
              cmd.setExecutable(executable);
              if (((F3AntTask) getJavac()).compilerClassPath != null) {
                  getJavac().log("Ignoring attribute compilerclasspath, because executable is set.", Project.MSG_WARN);
              }
          } else {
              cmd.setExecutable(JavaEnvUtils.getJdkExecutable("java"));
              if (memoryInitialSize != null) {
                  cmd.createArgument().setValue("-Xms" + memoryInitialSize);
                  memoryInitialSize = null; // don't include it in setupJavacCommandlineSwitches()
              }
              if (memoryMaximumSize != null) {
                  cmd.createArgument().setValue("-Xmx" + memoryMaximumSize);
                  memoryMaximumSize = null; // don't include it in setupJavacCommandlineSwitches()
              }
if (task.jdwpPort != 0) {
                  cmd.createArgument().setValue("-Xrunjdwp:transport=dt_socket,address=" + task.jdwpPort+",server=y,suspend=y");
}
if (task.enableAssertions) {
                  cmd.createArgument().setValue("-ea");
}
              String cp = "-Xbootclasspath/p:" +
                      ((F3AntTask) getJavac()).compilerClassPath.toString();
              cmd.createArgument().setValue(cp);
              cmd.createArgument().setValue(F3_ENTRY_POINT);
          }
          String profile = ((F3AntTask) getJavac()).profile;
          if (profile != null) {
              cmd.createArgument().setLine("-profile " + profile);
          }
          setupJavacCommandlineSwitches(cmd, true);
          int firstFileName = cmd.size();
          logAndAddFilesToCompile(cmd);
          return executeExternalCompile(cmd.getCommandline(), firstFileName, true) == 0;
      }
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:40,代码来源:F3AntTask.java

示例13: run

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
public void run() throws InterruptedException, IOException {
    String javaPath = JavaEnvUtils.getJreExecutable("java");
    String classpath = System.getProperty("java.class.path");

    String[] processArguments = {javaPath, "-cp", classpath, clazz.getName()}; // These are needed to run the specified class
    processArguments = combine(processArguments, arguments); // Add the arguments that the specified class should have

    ProcessBuilder processBuilder = new ProcessBuilder(processArguments);

    Process process = processBuilder.start();
    boolean processFinishedInTime = process.waitFor(millisToWait, TimeUnit.MILLISECONDS);
    if (processFinishedInTime) {
        StringWriter stdout = new StringWriter();
        StringWriter stderr = new StringWriter();

        IOUtils.copy(process.getInputStream(), stdout);
        IOUtils.copy(process.getErrorStream(), stderr);
        // This writer contains the error output stream as well. This means that any exceptions thrown will muddled in with the other output

        if (listener != null) {
            listener.acceptOutputFromOtherJvm(new ExecutionResult(stdout.toString(), stderr.toString(), process.exitValue()));
        }
    } else {
        process.destroyForcibly();
        if (listener != null) {
            listener.otherJvmTimedOut();
        }
    }
}
 
开发者ID:eriklarko,项目名称:robopong,代码行数:30,代码来源:Jvm.java

示例14: addJavaLibraries

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * add any libraries that come with different java versions
 * here
 */
public void addJavaLibraries() {
    final Vector<String> packages = JavaEnvUtils.getJrePackages();
    final Enumeration<String> e = packages.elements();
    while (e.hasMoreElements()) {
        final String packageName = e.nextElement();
        addSystemPackageRoot(packageName);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:13,代码来源:AntClassLoader.java

示例15: setJavaVersionProperty

import org.apache.tools.ant.util.JavaEnvUtils; //导入依赖的package包/类
/**
 * Set the <code>ant.java.version</code> property and tests for
 * unsupported JVM versions. If the version is supported,
 * verbose log messages are generated to record the Java version
 * and operating system name.
 *
 * @exception BuildException if this Java version is not supported.
 *
 * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion
 */
public void setJavaVersionProperty() throws BuildException {
    final String javaVersion = JavaEnvUtils.getJavaVersion();
    setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);

    // sanity check
    if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_8))  {
        throw new BuildException("Ant cannot work on Java prior to 1.8");
    }
    log("Detected Java version: " + javaVersion + " in: "
        + System.getProperty("java.home"), MSG_VERBOSE);

    log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:Project.java


注:本文中的org.apache.tools.ant.util.JavaEnvUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。