eclipse:覆盖 config.ini 中的 user.name

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/359351/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:26:41  来源:igfitidea点击:

eclipse: overriding user.name in config.ini

eclipseconfiguration

提问by Luca Tettamanti

I have a multi-user eclipse (3.4) installation with a shared master configuration area. Users need to override user.namewith their full name and the usual method (adding -Duser.name=... to eclipse.ini) is not suitable since the override must be per-user. I've tried setting user.name in config.ini (inside each user's configurationdirectory):

我有一个带有共享主配置区域的多用户 eclipse (3.4) 安装。用户需要user.name使用他们的全名进行覆盖,通常的方法(将 -Duser.name=... 添加到 eclipse.ini)是不合适的,因为覆盖必须是每个用户的。我试过在 config.ini 中设置 user.name (在每个用户的configuration目录中):

user.name=Luca Tettamanti

but it does work, eclipse still retains the login name. The strange thing is that:

但它确实有效,eclipse 仍然保留登录名。奇怪的是:

user.foobar=Luca Tettamanti

is correctly picked up. Is it possible to somehow override user.name in this configuration?

正确拾取。是否可以在此配置中以某种方式覆盖 user.name?

采纳答案by VonC

This has been reported beforeindeed.

这确实之前已经报道过

Why would you not use use a custom eclipse launcher (a script .cmd), which would modify the eclipse.ini, and then call eclipse.exe ?

为什么不使用自定义 eclipse 启动器(脚本.cmd),它会修改 eclipse.ini,然后调用 eclipse.exe ?

That script could retrieve the full name with a comand like:

该脚本可以使用如下命令检索全名:

net user %username% /domain | find /i "full"


That way, in Windows, your custom launcher would run eclipse with:

这样,在 Windows 中,您的自定义启动器将使用以下命令运行 eclipse:

eclipse.exe -clean --launcher.ini shared\eclipse.ini -vmargs -Duser.name=%FULL_NAME%

using the shared eclipse.ini, but specifying the user.namevalue.

使用共享的 eclipse.ini,但指定user.name值。



In Linux, to relay the contents of the shell variable USERto Eclipse, you need to do this:

在 Linux 中,要将 shell 变量的内容中继USER到 Eclipse,您需要执行以下操作:

exec eclipse -clean --launcher.ini shared/eclipse.ini -vmargs -Duser.name=`eval "echo $USER"`

回答by jamesh

I'm a little bit unclear as to your intention.

我有点不清楚你的意图。

The System property user.nameis significant as it should reflect the username of who ever invoked the JVM.

System 属性user.name很重要,因为它应该反映调用 JVM 的用户名。

If you're doing this for display purposes, and you have control of the plugin that is consuming it, then you should probably use your own method of discovering the display name.

如果您这样做是为了显示目的,并且您可以控制使用它的插件,那么您可能应该使用自己的方法来发现显示名称。

A custom config.ini or shortcut as described by @VonC would be suitable for this.

@VonC 描述的自定义 config.ini 或快捷方式将适用于此。