【问题标题】:Eclipse Formatter does not shutdown if started from command line如果从命令行启动 Eclipse Formatter 不会关闭
【发布时间】:2016-10-26 21:47:27
【问题描述】:

Stefan Frankes post 的启发,关于在命令行上使用 Eclipse 格式化程序(例如,用于预提交格式化),我尝试使用 Eclipse Mars 的库。使用这些库,格式化程序正在运行,但不会关闭。

我使用了以下 config.ini:

osgi.instance.area.default=./workspace
osgi.bundles.defaultStartLevel=4
eclipse.application=org.eclipse.jdt.core.JavaCodeFormatter
osgi.bundles= \
  org.eclipse.core.runtime_3.11.1.v20150903-1804.jar@start ,\
  org.eclipse.core.jobs_3.7.0.v20150330-2103.jar ,\
  org.eclipse.core.contenttype_3.5.0.v20150421-2214.jar ,\
  org.eclipse.equinox.registry_3.6.0.v20150318-1503.jar ,\
  org.eclipse.equinox.preferences_3.5.300.v20150408-1437.jar ,\
  org.eclipse.equinox.common_3.7.0.v20150402-1709.jar ,\
  org.eclipse.equinox.app_1.3.300.v20150423-1356.jar ,\
  org.eclipse.jdt.core_3.11.2.v20160128-0629.jar ,\
  org.eclipse.core.resources_3.10.1.v20150725-1910.jar ,\
  org.eclipse.core.filesystem_1.5.0.v20150725-1910.jar ,\
  org.eclipse.core.commands_3.7.0.v20150422-0725.jar ,\
  org.eclipse.core.expressions_3.5.0.v20150421-2214.jar ,\
  org.eclipse.text_3.5.400.v20150505-1044.jar ,\
  com.ibm.icu_54.1.1.v201501272100.jar ,\
  org.eclipse.core.filesystem.win32.x86_1.4.0.v20140124-1940.jar ,\
  org.eclipse.core.resources.win32.x86_3.5.100.v20140124-1940.jar ,\

开始使用

java -jar plugins\org.eclipse.osgi_3.10.102.v20160118-1700.jar -config fmt.ini %*

远程调试显示应用处于空闲状态。 调用 eclipse 二进制文件是因为所需的环境不是我的选择。

有什么想法可以在工作完成后让它停下来吗?

【问题讨论】:

    标签: java eclipse osgi equinox


    【解决方案1】:

    我自己找到了一个可行的解决方案,但我不知道它是否是最好的;-)

    我创建了一个新包,其中仅包含一个 Activator 和一个扩展 CodeFormatterApplication 的应用程序,只需添加一个调用即可

    Activator.getContext().getBundle( 0 ).stop();
    

    转至原代码:

    public Object start( IApplicationContext context )
        throws Exception
    {
        Object result = super.start( context );
    
        Activator.getContext().getBundle( 0 ).stop();
    
        return result;
    }
    

    这会关闭系统包,导致应用程序(和进程)关闭。

    这个想法来自this 帖子。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-21
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      相关资源
      最近更新 更多