如何在 ant 中获取系统用户(在 eclipse 中)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/838617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get system user in ant (within eclipse)?
提问by r?ph
How can I access the name of the system user (which eclipse also uses for the javadoc author tag) in my ant build file?
如何在我的 ant 构建文件中访问系统用户的名称(eclipse 也用于 javadoc author 标签)?
I'm trying to show some information about the current program version in my java application. I decided to use jreleaseinfowhich passes variables from my ant build script to my java classes (to show them in a window). With svnantI'm even capable of accessing the latest revision number and build date from svn within my build.xml.
我试图在我的 java 应用程序中显示有关当前程序版本的一些信息。我决定使用jreleaseinfo它将变量从我的 ant 构建脚本传递到我的 java 类(以在窗口中显示它们)。使用svnant,我什至能够在我的 build.xml 中从 svn 访问最新的修订号和构建日期。
Now: The last thing I need is to show who made that build!
现在:我需要做的最后一件事是展示谁制作了这个版本!
回答by Persimmonium
This will work anywhere. It uses the java system property user.name.
这将在任何地方工作。它使用 java 系统属性user.name。
<property environment="env" />
<echo message="user: ${user.name}" />
回答by coobird
user.name
can be used:
user.name
可以使用:
<echo>User is: ${user.name}</echo>
Results in:
结果是:
[echo] User is: coobird