我有一个基于 Maven 的 Netbeans 应用程序。默认情况下,应用程序窗口标题采用以下格式:
<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 的应用程序中自动设置版本号?
在您的品牌模块中使用 Bundle.properties 中的 Maven 占位符,在 pom 中.xml通过 maven-resources-plugin 过滤捆绑包。
注意:默认情况下,Netbeans 会忽略以下某些文件,因此您可能需要添加这些文件以保留更改。
src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties:
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.properties:
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.properties:
LBL_ProductInformation=My app ${project.version}
绒球.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 梦之队成员所回答的那样。