本文整理了Java中org.apache.tools.ant.taskdefs.condition.Os
类的一些代码示例,展示了Os
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Os
类的具体详情如下:
包路径:org.apache.tools.ant.taskdefs.condition.Os
类名称:Os
[英]Condition that tests the OS type.
[中]测试操作系统类型的条件。
代码示例来源:origin: org.apache.ant/ant
/**
* Checks whether <code>exitValue</code> signals a failure on the current
* system (OS specific).
*
* <p><b>Note</b> that this method relies on the conventions of
* the OS, it will return false results if the application you are
* running doesn't follow these conventions. One notable
* exception is the Java VM provided by HP for OpenVMS - it will
* return 0 if successful (like on any other platform), but this
* signals a failure on OpenVMS. So if you execute a new Java VM
* on OpenVMS, you cannot trust this method.</p>
*
* @param exitValue the exit value (return code) to be checked.
* @return <code>true</code> if <code>exitValue</code> signals a failure.
*/
public static boolean isFailure(int exitValue) {
// on openvms even exit value signals failure;
// for other platforms nonzero exit value signals failure
return Os.isFamily("openvms")
? (exitValue % 2 == 0) : (exitValue != 0);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Determines if the OS on which Ant is executing matches the
* given OS name.
*
* @param name the OS name to check for
* @return true if the OS matches
* @since 1.7
*/
public static boolean isName(String name) {
return isOs(null, name, null, null);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Constructor that sets the family attribute
* @param family a String value
*/
public Os(String family) {
setFamily(family);
}
代码示例来源:origin: org.apache.ant/ant
/**
* ByteArrayOutputStream#toString doesn't seem to work reliably on
* OS/390, at least not the way we use it in the execution
* context.
*
* @param bos the output stream that one wants to read.
* @return the output stream as a string, read with
* special encodings in the case of z/os and os/400.
* @since Ant 1.5
*/
public static String toString(ByteArrayOutputStream bos) {
if (Os.isFamily("z/os")) {
try {
return bos.toString("Cp1047");
} catch (UnsupportedEncodingException e) {
// noop default encoding used
}
} else if (Os.isFamily("os/400")) {
try {
return bos.toString("Cp500");
} catch (UnsupportedEncodingException e) {
// noop default encoding used
}
}
return bos.toString();
}
代码示例来源:origin: org.apache.ant/ant
/**
* Determines if the OS on which Ant is executing matches the type of
* that set in setFamily.
* @return true if the os matches.
* @throws BuildException if there is an error.
* @see Os#setFamily(String)
*/
@Override
public boolean eval() throws BuildException {
return isOs(family, name, arch, version);
}
代码示例来源:origin: org.apache.ant/ant
if (Os.isFamily("os/2")) {
if (Os.isFamily("windows")) {
if (Os.isFamily("win9x")) {
if (Os.isFamily("z/os") || Os.isFamily("unix")) {
if (Os.isFamily("netware") || Os.isFamily("os/400")) {
if (Os.isFamily("openvms")) {
return new String[] {"show", "logical"};
代码示例来源:origin: org.apache.ant/ant
/**
* Determines if the OS on which Ant is executing matches the
* given OS version.
*
* @param version the OS version to check for
* @return true if the OS matches
* @since 1.7
*/
public static boolean isVersion(String version) {
return isOs(null, null, null, version);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Creates a new execute object.
*
* @param streamHandler the stream handler used to handle the input and
* output streams of the subprocess.
* @param watchdog a watchdog for the subprocess or <code>null</code>
* to disable a timeout for the subprocess.
*/
public Execute(ExecuteStreamHandler streamHandler,
ExecuteWatchdog watchdog) {
setStreamHandler(streamHandler);
this.watchdog = watchdog;
// By default, use the shell launcher for VMS
//
if (Os.isFamily("openvms")) {
useVMLauncher = false;
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Determines if the OS on which Ant is executing matches the
* given OS family.
* @param family the family to check for
* @return true if the OS matches
* @since 1.5
*/
public static boolean isFamily(String family) {
return isOs(family, null, null, null);
}
代码示例来源:origin: typ0520/fastdex
public void mergeJavaDirectoryResultSet(String path,JavaDirectoryDiffResultSet javaDirectoryResultSet) {
List<String> addOrModifiedClassRelativePathList = addOrModifiedClassesMap.get(javaDirectoryResultSet.projectPath);
if (addOrModifiedClassRelativePathList == null) {
addOrModifiedClassRelativePathList = new LinkedList<>();
addOrModifiedClassesMap.put(javaDirectoryResultSet.projectPath,addOrModifiedClassRelativePathList);
}
Set<PathInfo> pathInfoSet = addOrModifiedPathInfosMap.get(javaDirectoryResultSet.projectPath);
if (pathInfoSet == null) {
pathInfoSet = new HashSet<>();
addOrModifiedPathInfosMap.put(javaDirectoryResultSet.projectPath,pathInfoSet);
}
for (JavaFileDiffInfo javaFileDiffInfo : javaDirectoryResultSet.changedDiffInfos) {
switch (javaFileDiffInfo.status) {
case ADDED:
case MODIFIED:
PathInfo pathInfo = new PathInfo(path,new File(path,javaFileDiffInfo.uniqueKey),javaFileDiffInfo.uniqueKey);
addOrModifiedPathInfos.add(pathInfo);
pathInfoSet.add(pathInfo);
String classRelativePath = javaFileDiffInfo.getClassRelativePath();
addOrModifiedClassRelativePathList.add(classRelativePath + ".class");
addOrModifiedClassRelativePathList.add(classRelativePath + "$*.class");
classRelativePath = classRelativePath.replaceAll(Os.isFamily(Os.FAMILY_WINDOWS) ? "\\\\" : File.separator,"\\.");
addOrModifiedClasses.add(classRelativePath);
break;
}
}
this.changedJavaFileDiffInfos.addAll(javaDirectoryResultSet.changedDiffInfos);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Determines if the OS on which Ant is executing matches the
* given OS architecture.
*
* @param arch the OS architecture to check for
* @return true if the OS matches
* @since 1.7
*/
public static boolean isArch(String arch) {
return isOs(null, null, arch, null);
}
代码示例来源:origin: org.apache.ant/ant
if (Os.isFamily("openvms")) {
return env;
代码示例来源:origin: org.apache.ant/ant
/**
* Set the command line for the exe.
* On VMS, hands off to {@link #setupCommandLineForVMS(Execute, String[])}.
* @param exe executable.
* @param command command to execute.
*/
private void setupCommandLine(Execute exe, String[] command) {
//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.
if (Os.isFamily("openvms")) {
setupCommandLineForVMS(exe, command);
} else {
exe.setCommandline(command);
}
}
代码示例来源:origin: org.apache.ant/ant
break;
case FAMILY_DOS:
isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE);
break;
case FAMILY_MAC:
case FAMILY_UNIX:
isFamily = PATH_SEP.equals(":")
&& !isFamily(FAMILY_VMS)
&& (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x")
|| OS_NAME.contains(DARWIN));
break;
代码示例来源:origin: org.apache.ant/ant
if (osFamily != null && !Os.isFamily(osFamily)) {
return false;
代码示例来源:origin: org.apache.ant/ant
/**
* Automatically approve Unix OS's.
* @return true if a valid OS, for unix this is always true, otherwise
* use the superclasses' test (user set).
*/
@Override
protected boolean isValidOs() {
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Check if the os is valid.
* Always include unix.
* @return true if the os is valid.
*/
@Override
protected boolean isValidOs() {
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Check if the os is valid.
* Default is to allow windows
* @return true if the os is valid.
*/
@Override
protected boolean isValidOs() {
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_WINDOWS) : super.isValidOs();
}
代码示例来源:origin: org.apache.ant/ant
File f = new File(pElement,
"rpmbuild"
+ (Os.isFamily("dos") ? ".exe" : ""));
if (f.canRead()) {
return f.getAbsolutePath();
代码示例来源:origin: org.apache.ant/ant
return procEnvironment;
if (!Os.isFamily("openvms")) {
try {
procEnvironment = System.getenv();
new BufferedReader(new StringReader(toString(out)));
if (Os.isFamily("openvms")) {
procEnvironment = getVMSLogicals(in);
return procEnvironment;
内容来源于网络,如有侵权,请联系作者删除!