org.apache.tools.ant.taskdefs.condition.Os类的使用及代码示例

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

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

Os介绍

[英]Condition that tests the OS type.
[中]测试操作系统类型的条件。

代码示例

代码示例来源: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. * Determines if the OS on which Ant is executing matches the
  3. * given OS name.
  4. *
  5. * @param name the OS name to check for
  6. * @return true if the OS matches
  7. * @since 1.7
  8. */
  9. public static boolean isName(String name) {
  10. return isOs(null, name, null, null);
  11. }

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

  1. /**
  2. * Constructor that sets the family attribute
  3. * @param family a String value
  4. */
  5. public Os(String family) {
  6. setFamily(family);
  7. }

代码示例来源: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. /**
  2. * Determines if the OS on which Ant is executing matches the type of
  3. * that set in setFamily.
  4. * @return true if the os matches.
  5. * @throws BuildException if there is an error.
  6. * @see Os#setFamily(String)
  7. */
  8. @Override
  9. public boolean eval() throws BuildException {
  10. return isOs(family, name, arch, version);
  11. }

代码示例来源: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. * Determines if the OS on which Ant is executing matches the
  3. * given OS version.
  4. *
  5. * @param version the OS version to check for
  6. * @return true if the OS matches
  7. * @since 1.7
  8. */
  9. public static boolean isVersion(String version) {
  10. return isOs(null, null, null, version);
  11. }

代码示例来源: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: org.apache.ant/ant

  1. /**
  2. * Determines if the OS on which Ant is executing matches the
  3. * given OS family.
  4. * @param family the family to check for
  5. * @return true if the OS matches
  6. * @since 1.5
  7. */
  8. public static boolean isFamily(String family) {
  9. return isOs(family, null, null, null);
  10. }

代码示例来源: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. /**
  2. * Determines if the OS on which Ant is executing matches the
  3. * given OS architecture.
  4. *
  5. * @param arch the OS architecture to check for
  6. * @return true if the OS matches
  7. * @since 1.7
  8. */
  9. public static boolean isArch(String arch) {
  10. return isOs(null, null, arch, null);
  11. }

代码示例来源: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;

相关文章

Os类方法