edvin / fxlauncher

Auto updating launcher for JavaFX Applications
Apache License 2.0
714 stars 110 forks source link

Work with e(fx)clipse eclipse plugin #69

Closed HossamMohsen7 closed 7 years ago

HossamMohsen7 commented 7 years ago

Hello, I'm trying to make fxlauncher work with the e(fx)clipse plugin for eclipse where you can make JavaFX applications with it easily and with all native installers too. but it uses ant to build the application. because of that I can't make fxlauncher work with applications made with e(fx)clipse. Can you help me?

edvin commented 7 years ago

It is absolutely possible to adapt your ant build script for fxlauncher. Take a look at the pom.xml from https://github.com/edvin/fxldemo/blob/master/pom.xml - it lists the steps needed and how they are done in Maven:

  1. Compile project jar to app.dir
  2. Copy dependencies to app.dir
  3. Generate app.xml manifest and embed it into fxlauncher.jar
  4. Create native installer
  5. Upload application artifacts

1 and 2 can easily be done, you simply compile your app and copy the resulting jar together with the other libraries you need to some folder (what I mean with app.dir above).

  1. Is two fold. First you need to execute the class fxlauncher.CreateManifest in fxlauncher.jar with these parameters (taken from pom.xml, adapt to ant syntax for executing a java class):
<mainClass>fxlauncher.CreateManifest</mainClass>
<arguments>
    <argument>${app.url}</argument>
    <argument>${app.mainClass}</argument>
    <argument>${app.dir}</argument>
    <argument>--cache-dir=${app.cacheDir}</argument>
    <argument>--accept-downgrade=${app.acceptDowngrade}</argument>
    <argument>--include-extensions=jpg</argument>
    <argument>${app.parameters}</argument>
</arguments>

The resulting app.xml then needs to be inserted into fxlauncher.jar. This can be done using the jar command:

<executable>jar</executable>
<workingDirectory>${app.dir}</workingDirectory>
<arguments>
    <argument>uf</argument>
    <argument>fxlauncher.jar</argument>
    <argument>app.xml</argument>
</arguments>

4 is simply to call javapackager with the required arguments. You don't need all of these, start small and consult the javapackager documentation:

<argument>-deploy</argument>
<argument>-native</argument>
<argument>-outdir</argument>
<argument>${app.installerdir}</argument>
<argument>-outfile</argument>
<argument>${app.filename}</argument>
<argument>-srcdir</argument>
<argument>${app.dir}</argument>
<argument>-srcfiles</argument>
<argument>fxlauncher.jar</argument>
<argument>-appclass</argument>
<argument>fxlauncher.Launcher</argument>
<argument>-name</argument>
<argument>${project.name}</argument>
<argument>-title</argument>
<argument>${project.name}</argument>
<argument>-vendor</argument>
<argument>${app.vendor}</argument>
<argument>-BappVersion=${app.version}</argument>
<argument>-Bidentifier=${project.groupId}.${project.artifactId}</argument>

Step 5 is just to upload your artifacts to your web server, which you can do with either an scp ant task or by calling scp.

If you decide to put this together to an ant build I would be very grateful if you would share it with us :)

HossamMohsen7 commented 7 years ago

Ok I decided to use .bat files to make this but I want to know if I added a new file or library will the launcher download it or will it only download files it has inside app.xml in the launcher jar?

HossamMohsen7 commented 7 years ago

Sorry, and is there a way that you can make the launcher download files from another web server?

edvin commented 7 years ago

If you add a new library you will publish a new version of app.xml with the new library in it, so that clients can download it. That's the basic principle of FXLauncher. You configure the manifest with whatever URL you want to host the libraries on, but they all have to recide on the same server. I can't really see a use case for supporting separate download locations, but if you can give me such a use case I will implement support for it :)

HossamMohsen7 commented 7 years ago

Thank you. About the use of separate download locations maybe someone doesn't want to host libraries on his server but download it from the library publisher directly, another use is if someone doesn't even have a web server he might use dropbox to host the app.xml file and because dropbox disabled public folders then you need to add every library's url manually. I hope you got my point because English isn't my first language :)

HossamMohsen7 commented 7 years ago

Oh and sorry for my questions :) but if the user installs my application using a .msi installer then I updated my application to a new version like 1.0.1 or something how can I update the version shown in the Control panel / Programs and Features ?

edvin commented 7 years ago

You can't, unless you make the user install a new version. Since the app will update dynamically you should let the installer version number reflect this somehow. Maybe use 2017 or something like that for the version number? :)

edvin commented 7 years ago

I will look into support for per-library static download urls as well :)

HossamMohsen7 commented 7 years ago

Thank you and Thanks for your time :)

edvin commented 7 years ago

My pleasure :)