简体   繁体   English

Java-在导出期间设置应用程序捆绑包版本

[英]Java - Set application bundle version during export

So I have a String that represents the version of the program I'm working on that's static. 所以我有一个String,它表示我正在处理的程序版本是静态的。 I use it in many places which is why I made one global variable. 我在很多地方都使用它,这就是为什么我做了一个全局变量。

Question: When exporting my project as a Mac application bundle, is it possible to set the CFBundleVersion in the info.plist to that string? 问题:将我的项目导出为Mac应用程序捆绑包时,是否可以将info.plist中的CFBundleVersion设置为该字符串? If not, can I set it to anything during the export or must it be done manually afterwards? 如果没有,我可以在导出过程中将其设置为任何内容,还是必须在之后手动进行?

Thanks in advance 提前致谢

You could use the Maven resource filtering mechanism to export a variable to certain files: http://www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-description.html 您可以使用Maven资源过滤机制将变量导出到某些文件: http : //www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-description.html

I use it to export the current version and the date the project was built: 我用它来导出当前版本和项目创建的日期:

  1. I have a file named "release.properties" in "D:\\workspace\\...\\src\\main\\resources" which contains some variables 我在"D:\\workspace\\...\\src\\main\\resources"中有一个名为"release.properties"的文件,其中包含一些变量

     # release version version=${project.version}_${svninfo.committedRevision} # date when the current release was built build_date=${buildDate} 
  2. In my pom.xml I have declared a set of resources that Maven will parse and fill the variables with according values 在我的pom.xml中,我声明了一组资源,Maven将解析这些资源并根据相应的值填充变量

     <resources> <resource> <directory>D:\\workspace\\...\\src\\test\\resources</directory> </resource> <resource> <filtering>true</filtering> <directory>D:\\workspace\\...\\src\\main\\resources</directory> <includes> <include>**/release.properties</include> </includes> </resource> <resource> <filtering>false</filtering> <directory>D:\\workspace\\...\\src\\main\\resources</directory> <excludes> <exclude>**/release.properties</exclude> </excludes> </resource> </resources> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM