New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose jpackage's --resource-dir in Gradle DSL #1843
Conversation
Hints on how to test this (and directly use it in our next Briar Desktop release) are highly appreciated! |
@AltNico I'm not sure I like the idea of mixing packaging resources and app resources. Just to be clear, I'm not strongly against it either. That's why there are two |
jpackage provides the option `--resource-dir` that allows to override > resources used by jpackage, such as background images and template > files for properties and scripts. https://docs.oracle.com/en/java/javase/17/jpackage/override-jpackage-resources.html This includes files like `preinst` and `postinst` that are used by .deb files to allow modifications of the installation process. When looking at the .deb file generated by jpackage, the default `preinst` and `postinst` scripts land in the _control.tar.xz_ archive of the .deb file. However, with the .deb files produced by the `packageDeb` task, one can see that the files from the source's `appResourcesRootDir` (specified in `build.gradle.kts`) land in _/opt/briar-desktop/lib/app/resources/_ inside the _data.tar.xz_ archive. Looking at the jpackage parameters used during `packageDeb`, one can see that it uses _compose/tmp/resources_: ``` --resource-dir "/home/dev/Documents/briar-desktop/build/compose/tmp/resources" ``` [project root]/build/compose/tmp/packageDeb.args.txt Looking at that directory, it is empty. However, inside _compose/tmp/main/resources_ the files provided in source's `appResourcesRootDir` are found: ``` $ ls -l compose/tmp/main/resources/ total 8 -rwxr-xr-x 1 dev dev 9 Feb 14 13:02 postinst -rwxr-xr-x 1 dev dev 618 Feb 14 13:02 preinst $ ls -l compose/tmp/resources/ total 0 ``` This MR therefore exposes `jpackageResources` to be specified in Gradle build files by Compose projects. https://github.com/JetBrains/compose-jb/blob/v1.0.1/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt#L248 Fixes #1766.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexeyTsvetkov Exposing jpackageResources
via the DSL sounds good to me! I gave it a try and implemented packagingResourcesRootDir
analogously to how appResourcesDir
is implemented. I'm adding some comments in the code, but just want to mention that I did not add the preparePackagingResources
functions to the configurePackagingTask()
calls of run composeTask
and JavaExec.configureRunTask
because there we don't need those packaging resources, I guess.
Still unsure on how to test it (with Briar Desktop), though.
@@ -27,6 +27,7 @@ open class NativeDistributions @Inject constructor( | |||
var vendor: String? = null | |||
var packageVersion: String? = null | |||
val appResourcesRootDir: DirectoryProperty = objects.directoryProperty() | |||
val packagingResourcesRootDir: DirectoryProperty = objects.directoryProperty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now adding packagingResourcesRootDir
to the DSL similar to how appResourcesRootDir
is implemented.
val resourcesDir = project.layout.dir(prepareResources.map { it.destinationDir }) | ||
jpackageResources.set(resourcesDir) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm not sure whether resourcesDir
contains the right path.
val destDir = project.layout.buildDirectory.dir("compose/tmp/resources") | ||
into(destDir) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows to specify different files per OS/arch combination, just like with appResourcesRootDir
.
Hey @AlexeyTsvetkov I know it's been a while, but what you think about the PR? I think it'd be super useful to get in |
jpackage provides the option
--resource-dir
that allows to overridehttps://docs.oracle.com/en/java/javase/17/jpackage/override-jpackage-resources.html
This includes files like
preinst
andpostinst
that are used by .deb files to allow modifications of the installation process.When looking at the .deb file generated by jpackage, the default
preinst
andpostinst
scripts land in the control.tar.xz archive of the .deb file.However, with the .deb files produced by the
packageDeb
task, one can see that the files from the source'sappResourcesRootDir
(specified inbuild.gradle.kts
) land in /opt/briar-desktop/lib/app/resources/ inside the data.tar.xzarchive.
Looking at the jpackage parameters used during
packageDeb
, one can see that it uses compose/tmp/resources:[project root]/build/compose/tmp/packageDeb.args.txt
Looking at that directory, it is empty. However, inside compose/tmp/main/resources the files provided in source's
appResourcesRootDir
are found:This MR therefore exposes
jpackageResources
to be specified in Gradle build files byCompose projects.
https://github.com/JetBrains/compose-jb/blob/v1.0.1/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJPackageTask.kt#L248
Fixes #1766.