So I was wondering if there is a way I can modify the default configuration file generated by Gradle (command-line) to build a desktop app using Compose.
Does somebody have any experience with that? Is there some doc or a tutorial on how to do that?
Alternatively, is there a script for building a basic desktop “hello world” app template/project from the command-line.
I don’t have much experience with Compose, so correct me if I’m wrong, but even if you configure your desktop app using IntelliJ, underneath it creates Gradle project anyway. Just invoke gradle build for your desktop project.
I’m trying to avoid creating projects with an IDE.
If I can create blanks projects from the command-line with a script or a template, it makes it easier to automate the development process. It is more reproducible and less error-prone.
That’s what do with other languages : Go, JavaScript (npm), Crystal, Rust, etc.
In that case Compose provides both empty app templates and many example apps. I guess they are all using Gradle, because Gradle is the main/only build system supported by Compose.
Most probably you built a jar file with your own code only, without its dependencies and now you try to execute it as a standalone application. As I told you in another thread, you would have to create a so called “fat jar” if you want to execute it like this.
it will automatically generate a tar file and a zip file ready for distribution.
Without requiring that you take any additional steps.
What surprised me is that when you create a desktop app using the IDE (IntelliJ) there doesn’t seem to be an option to do the same, i.e. build the app for distribution.
It surprises me, because that’s the point eventually: Build an app to distribute it, so the whole procedure should be as simple and straightforward as possible.
With Go, for instance, it is as simple as:
go mod init MyApp
go get ... //dependencies
go build
Note that Compose Desktop internally uses native libraries for its UI, these apps are not pure-Java, so they are not multi-platform, they are less standard and building them is more complicated, at least internally.
Dependencies are downloaded from the internet by Gradle and usually stored somewhere inside ~/.gradle/caches/ directory.
Ctrl+click on a class name and you will see its contents. Then you can see the gradle artifact name in the window title, you can also right click on the class body/tab to find its full path. Or just use ctrl+shift+c to copy it.