在 Netbeans 应用程序上显示 Maven 项目版本 window

Display Maven Project version on Netbeans Application window

我有一个基于 Maven 的 Netbeans 应用程序。默认情况下,应用程序 window 标题采用以下格式:

<Application Name>{0}

其中 {0} 在运行时被替换为它出现的 IDE 构建日期。有没有办法让它自动成为项目的 Maven 版本?

现在我需要在每个版本上手动更改它。只是容易出错。

更新 将以下内容添加到 POM,但它似乎没有任何效果,Netbeans 显示红色图标,因为没有找到我在模块中的帮助集的一些文件。

        <resources>
            <resource>
                <directory>${basedir}/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

有两种方法可以设置帮助...关于对话框中显示的版本号。

The easy way is to set the system property netbeans.buildnumber to some value in your application.
The harder way is to put this key/value currentVersion=My Product 1.2.3 into the file named "branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties" below your suite, then rebuild and run.
In NB 6.5 and later is the file location different: "branding/core/core.jar/org/netbeans/core/startup/Bundle.properties" 

如何在 maven-based 个应用程序中自动设置版本号?

在您的 branding-module 中使用 Maven 占位符 Bundle.properties 并在 pom.xml 中通过 maven-resources-plugin.

过滤包

注意: Netbeans 在版本控制中默认忽略下面的一些文件,因此您可能需要添加它们以保留更改。

src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.属性:

currentVersion=My app ${project.version}
LBL_splash_window_title=Starting My app ${project.version}

src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.属性:

CTL_MainWindow_Title=My app ${project.version}
CTL_MainWindow_Title_No_Project=My app ${project.version}

src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.属性:

LBL_ProductInformation=My app ${project.version}

pom.xml:

<build>
    <resources>
        <resource>
            <directory>${basedir}/src/main/nbm-branding</directory>
            <!-- f.e. allow replacing ${project.version} in all property files below src/main/nbm-branding -->
            <includes>
                <include>**/*.properties</include>
            </includes>
            <filtering>true</filtering>
            <targetPath>${basedir}/target/filtered-nbm-branding</targetPath>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>nbm-maven-plugin</artifactId>
            <configuration>
                <!-- use previously filtered branding sources -->
                <brandingSources>${basedir}/target/filtered-nbm-branding</brandingSources>
            </configuration>
        </plugin>
        <!-- ... -->
    </plugins>
</build>

正如 Netbeans Dream Team 会员的回答。