org.apache.tools.ant.taskdefs.condition.Os.isFamily()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(247)

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

Os.isFamily介绍

[英]Determines if the OS on which Ant is executing matches the given OS family.
[中]确定Ant正在执行的操作系统是否与给定的操作系统系列匹配。

代码示例

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

  1. /**
  2. * Checks whether <code>exitValue</code> signals a failure on the current
  3. * system (OS specific).
  4. *
  5. * <p><b>Note</b> that this method relies on the conventions of
  6. * the OS, it will return false results if the application you are
  7. * running doesn't follow these conventions. One notable
  8. * exception is the Java VM provided by HP for OpenVMS - it will
  9. * return 0 if successful (like on any other platform), but this
  10. * signals a failure on OpenVMS. So if you execute a new Java VM
  11. * on OpenVMS, you cannot trust this method.</p>
  12. *
  13. * @param exitValue the exit value (return code) to be checked.
  14. * @return <code>true</code> if <code>exitValue</code> signals a failure.
  15. */
  16. public static boolean isFailure(int exitValue) {
  17. // on openvms even exit value signals failure;
  18. // for other platforms nonzero exit value signals failure
  19. return Os.isFamily("openvms")
  20. ? (exitValue % 2 == 0) : (exitValue != 0);
  21. }

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

  1. /**
  2. * ByteArrayOutputStream#toString doesn't seem to work reliably on
  3. * OS/390, at least not the way we use it in the execution
  4. * context.
  5. *
  6. * @param bos the output stream that one wants to read.
  7. * @return the output stream as a string, read with
  8. * special encodings in the case of z/os and os/400.
  9. * @since Ant 1.5
  10. */
  11. public static String toString(ByteArrayOutputStream bos) {
  12. if (Os.isFamily("z/os")) {
  13. try {
  14. return bos.toString("Cp1047");
  15. } catch (UnsupportedEncodingException e) {
  16. // noop default encoding used
  17. }
  18. } else if (Os.isFamily("os/400")) {
  19. try {
  20. return bos.toString("Cp500");
  21. } catch (UnsupportedEncodingException e) {
  22. // noop default encoding used
  23. }
  24. }
  25. return bos.toString();
  26. }

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

  1. if (Os.isFamily("os/2")) {
  2. if (Os.isFamily("windows")) {
  3. if (Os.isFamily("win9x")) {
  4. if (Os.isFamily("z/os") || Os.isFamily("unix")) {
  5. if (Os.isFamily("netware") || Os.isFamily("os/400")) {
  6. if (Os.isFamily("openvms")) {
  7. return new String[] {"show", "logical"};

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

  1. /**
  2. * Creates a new execute object.
  3. *
  4. * @param streamHandler the stream handler used to handle the input and
  5. * output streams of the subprocess.
  6. * @param watchdog a watchdog for the subprocess or <code>null</code>
  7. * to disable a timeout for the subprocess.
  8. */
  9. public Execute(ExecuteStreamHandler streamHandler,
  10. ExecuteWatchdog watchdog) {
  11. setStreamHandler(streamHandler);
  12. this.watchdog = watchdog;
  13. // By default, use the shell launcher for VMS
  14. //
  15. if (Os.isFamily("openvms")) {
  16. useVMLauncher = false;
  17. }
  18. }

代码示例来源:origin: typ0520/fastdex

  1. public void mergeJavaDirectoryResultSet(String path,JavaDirectoryDiffResultSet javaDirectoryResultSet) {
  2. List<String> addOrModifiedClassRelativePathList = addOrModifiedClassesMap.get(javaDirectoryResultSet.projectPath);
  3. if (addOrModifiedClassRelativePathList == null) {
  4. addOrModifiedClassRelativePathList = new LinkedList<>();
  5. addOrModifiedClassesMap.put(javaDirectoryResultSet.projectPath,addOrModifiedClassRelativePathList);
  6. }
  7. Set<PathInfo> pathInfoSet = addOrModifiedPathInfosMap.get(javaDirectoryResultSet.projectPath);
  8. if (pathInfoSet == null) {
  9. pathInfoSet = new HashSet<>();
  10. addOrModifiedPathInfosMap.put(javaDirectoryResultSet.projectPath,pathInfoSet);
  11. }
  12. for (JavaFileDiffInfo javaFileDiffInfo : javaDirectoryResultSet.changedDiffInfos) {
  13. switch (javaFileDiffInfo.status) {
  14. case ADDED:
  15. case MODIFIED:
  16. PathInfo pathInfo = new PathInfo(path,new File(path,javaFileDiffInfo.uniqueKey),javaFileDiffInfo.uniqueKey);
  17. addOrModifiedPathInfos.add(pathInfo);
  18. pathInfoSet.add(pathInfo);
  19. String classRelativePath = javaFileDiffInfo.getClassRelativePath();
  20. addOrModifiedClassRelativePathList.add(classRelativePath + ".class");
  21. addOrModifiedClassRelativePathList.add(classRelativePath + "$*.class");
  22. classRelativePath = classRelativePath.replaceAll(Os.isFamily(Os.FAMILY_WINDOWS) ? "\\\\" : File.separator,"\\.");
  23. addOrModifiedClasses.add(classRelativePath);
  24. break;
  25. }
  26. }
  27. this.changedJavaFileDiffInfos.addAll(javaDirectoryResultSet.changedDiffInfos);
  28. }

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

  1. if (Os.isFamily("openvms")) {
  2. return env;

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

  1. /**
  2. * Set the command line for the exe.
  3. * On VMS, hands off to {@link #setupCommandLineForVMS(Execute, String[])}.
  4. * @param exe executable.
  5. * @param command command to execute.
  6. */
  7. private void setupCommandLine(Execute exe, String[] command) {
  8. //On VMS platform, we need to create a special java options file
  9. //containing the arguments and classpath for the java command.
  10. //The special file is supported by the "-V" switch on the VMS JVM.
  11. if (Os.isFamily("openvms")) {
  12. setupCommandLineForVMS(exe, command);
  13. } else {
  14. exe.setCommandline(command);
  15. }
  16. }

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

  1. break;
  2. case FAMILY_DOS:
  3. isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE);
  4. break;
  5. case FAMILY_MAC:
  6. case FAMILY_UNIX:
  7. isFamily = PATH_SEP.equals(":")
  8. && !isFamily(FAMILY_VMS)
  9. && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x")
  10. || OS_NAME.contains(DARWIN));
  11. break;

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

  1. if (osFamily != null && !Os.isFamily(osFamily)) {
  2. return false;

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

  1. /**
  2. * Automatically approve Unix OS's.
  3. * @return true if a valid OS, for unix this is always true, otherwise
  4. * use the superclasses' test (user set).
  5. */
  6. @Override
  7. protected boolean isValidOs() {
  8. return getOs() == null && getOsFamily() == null
  9. ? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
  10. }
  11. }

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

  1. /**
  2. * Check if the os is valid.
  3. * Always include unix.
  4. * @return true if the os is valid.
  5. */
  6. @Override
  7. protected boolean isValidOs() {
  8. return getOs() == null && getOsFamily() == null
  9. ? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
  10. }
  11. }

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

  1. /**
  2. * Check if the os is valid.
  3. * Default is to allow windows
  4. * @return true if the os is valid.
  5. */
  6. @Override
  7. protected boolean isValidOs() {
  8. return getOs() == null && getOsFamily() == null
  9. ? Os.isFamily(Os.FAMILY_WINDOWS) : super.isValidOs();
  10. }

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

  1. File f = new File(pElement,
  2. "rpmbuild"
  3. + (Os.isFamily("dos") ? ".exe" : ""));
  4. if (f.canRead()) {
  5. return f.getAbsolutePath();

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

  1. return procEnvironment;
  2. if (!Os.isFamily("openvms")) {
  3. try {
  4. procEnvironment = System.getenv();
  5. new BufferedReader(new StringReader(toString(out)));
  6. if (Os.isFamily("openvms")) {
  7. procEnvironment = getVMSLogicals(in);
  8. return procEnvironment;

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

  1. /**
  2. * Get the attribute type-value
  3. *
  4. * @param cmd containing the command line string with or
  5. * without the type-value
  6. */
  7. private void getTypeValueCommand(Commandline cmd) {
  8. String typevl = getTypeValue();
  9. if (typevl != null) {
  10. if (Os.isFamily("windows")) {
  11. typevl = "\\\"" + typevl + "\\\""; // Windows quoting of the value
  12. } else {
  13. typevl = "\"" + typevl + "\"";
  14. }
  15. cmd.createArgument().setValue(typevl);
  16. }
  17. }

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

  1. getEnvironment(), workingDirectory,
  2. useVMLauncher);
  3. if (Os.isFamily("windows")) {
  4. try {
  5. Thread.sleep(ONE_SECOND);

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

  1. Project.MSG_INFO,
  2. Project.MSG_WARN));
  3. if (Os.isFamily("openvms")) {

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

  1. if (!Os.isFamily("windows")) {
  2. log("Using listcab/libcabinet", Project.MSG_VERBOSE);

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

  1. /**
  2. * Performs a compile using the Javac externally.
  3. * @return true if the compilation succeeded
  4. * @throws BuildException on error
  5. */
  6. @Override
  7. public boolean execute() throws BuildException {
  8. attributes.log("Using external javac compiler", Project.MSG_VERBOSE);
  9. Commandline cmd = new Commandline();
  10. cmd.setExecutable(getJavac().getJavacExecutable());
  11. if (!assumeJava11() && !assumeJava12()) {
  12. setupModernJavacCommandlineSwitches(cmd);
  13. } else {
  14. setupJavacCommandlineSwitches(cmd, true);
  15. }
  16. int firstFileName = assumeJava11() ? -1 : cmd.size();
  17. logAndAddFilesToCompile(cmd);
  18. //On VMS platform, we need to create a special java options file
  19. //containing the arguments and classpath for the javac command.
  20. //The special file is supported by the "-V" switch on the VMS JVM.
  21. if (Os.isFamily("openvms")) {
  22. return execOnVMS(cmd, firstFileName);
  23. }
  24. return
  25. executeExternalCompile(cmd.getCommandline(), firstFileName,
  26. true)
  27. == 0;
  28. }

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

  1. : new ExecuteWatchdog(timeout));
  2. exe.setAntRun(pc.getProject());
  3. if (Os.isFamily("openvms")) {
  4. setupCommandLineForVMS(exe, cmdl.getCommandline());
  5. } else {

相关文章

Os类方法