代码之家  ›  专栏  ›  技术社区  ›  limc

EclipseRCP:如何以编程方式从产品文件中获取版本号?

  •  1
  • limc  · 技术社区  · 14 年前

    我目前在属性文件中对版本号进行了硬编码,我希望能够通过编程直接从RCP产品文件中获取版本号。这样,我不需要在两个地方指定版本号。我找不到有关这样做的文章。我正在使用EclipseRCP 3.x。

    这是可行的吗?

    谢谢。

    3 回复  |  直到 9 年前
        1
  •  0
  •   Jan Schiefer    14 年前

    customBuildCallbacks = buildCustomization.xml
    

     <?xml version="1.0"?>
    
    <project name="product_customization" default="pre.@dot">
        <target name="pre.@dot" if="buildtag" description="Patch buildtag (if it exists) into plugin.xml">
            <replace file="plugin.xml" token="$DEVELOPER$" value="${buildtag}" />
        </target>
    </project>
    

        2
  •  1
  •   Koss    9 年前

    1. String version = Display.getAppVersion().toString();
    2. String version = Platform.getProduct().getDefiningBundle().getVersion().toString();
    3. String version = Platform.getProduct().getDefiningBundle().getHeaders().get("Bundle-Version");

    System.out.println(Platform.getProduct().getProperty("version"));

        3
  •  0
  •   titou10    9 年前

    import org.osgi.framework.FrameworkUtil; 
    import org.osgi.framework.Version; 
    
    Version v = FrameworkUtil.getBundle(SomeClass.class).getVersion(); 
    String version = String.format("Version %d.%d.%d", v.getMajor(), v.getMinor(), v.getMicro());
    

    SomeClass