我刚刚开始使用jpackage,它是一个非常好的工具。只要迈出一步,我就需要做大量的工作。我越是惊讶于一些看起来硬编码又不能定制的东西?
JPackage自动生成启动程序(lib/<application>.desktop文件),deb包会自动安装它,以便所有用户都可以启动应用程序。但一旦启动,另一个图标就会出现在一个统一的地方。我希望现有的图标被标记为正在运行。
根据Ubuntu安装程序使所有Java应用程序都具有相同的图标,我们只需要确保.desktop文件包含正确的StartupWMClass。使用xprop,我发现这个值是基于对窗口负责的完全限定的类名--这是绝对有意义的。
那么,如何告诉jpackage在生成的StartupWMClass文件中设置哪个.desktop呢?
编辑:为了补充Bodo的评论,我将展示如何调用jpackage。实际上,我不是自己运行命令行,而是使用maven插件,配置为:
<plugin>
<groupId>com.github.akman</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jpackage</goal>
</goals>
<configuration>
<dest>target</dest>
<name>OoliteCommunicator</name>
<type>PLATFORM</type>
<appversion>${project.version}</appversion>
<description>Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)</description>
<vendor>Hiran</vendor>
<icon>target/classes/com/mycompany/oolitecommunicator/ui/Communicator_Logo_Icon.png</icon>
<input>target/dist</input>
<mainjar>OoliteCommunicator-${project.version}.jar</mainjar>
<mainclass>com.mycompany.oolitecommunicator.Main</mainclass>
</configuration>
</execution>
</executions>
</plugin>在maven构建过程中,我看到的是这个输出,我认为它是插件调用jpackage时内部生成的命令行。最后一行可能已经是调用,每当我在构建后检查时,就没有文件/home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts.。我只能假设它的内容就在之前被记录下来了。
# jpackage
--dest /home/hiran/NetBeansProjects/OoliteCommunicator/target
--app-version '1.0-20211220-090022'
--description 'Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)'
--name 'OoliteCommunicator'
--vendor 'Hiran'
--icon /home/hiran/NetBeansProjects/OoliteCommunicator/target/classes/com/mycompany/oolitecommunicator/ui/Communicator_Logo_Icon.png
--input /home/hiran/NetBeansProjects/OoliteCommunicator/target/dist
--main-jar 'OoliteCommunicator-1.0-20211220-090022.jar'
--main-class com.mycompany.oolitecommunicator.Main
/usr/lib/jvm/java-16-openjdk-amd64/bin/jpackage @/home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts最后,我得到了一个带有这个桌面文件的deb包:
[Desktop Entry]
Name=OoliteCommunicator
Comment=Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)
Exec=/opt/oolitecommunicator/bin/OoliteCommunicator
Icon=/opt/oolitecommunicator/lib/OoliteCommunicator.png
Terminal=false
Type=Application
Categories=Unknown
MimeType=我通过手动添加行来修复bhaviour
StartupWMClass=com-mycompany-oolitecommunicator-Main因此,我的解决办法是将这一行添加到这两个
在deb被安装之后。不像我想的那样简单.
发布于 2022-01-20 23:05:03
因此,我终于找到了一个可能有正确的包装。
您需要覆盖JPackage内部模板并提供您自己的.desktop文件。这可以由覆盖JPackage资源来完成。
这意味着您创建了一个包含正确.desktop文件的资源文件夹,指定了JPackage命令行上的资源文件夹,并将创建正确的包。
https://stackoverflow.com/questions/70420618
复制相似问题