fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 133 forks source link

I can't for the life of me figure out how to set the executable name! #303

Closed dkoding closed 3 weeks ago

dkoding commented 1 year ago

I'm submitting a…

Short description of the issue/suggestion:

First of all, thank you very much for this great tool! I use it for all my games and utilities.

But how can I set the name of the resulting generated .exe file on Windows? I use the gradle configuration. I set applicationName and appName but that is totally ignored.

The tool insists on using my submodule (project) name as the executable name. Can this be overridden?

In general the documentation is quite sparse, I would love some more examples of how to do even the basic things.

Steps to reproduce the issue/enhancement:

Follow the examples on the project page.

What is the expected behavior?

I would expect the resulting .exe file to have the same name as applicationName

What is the current behavior?

The .exe file has the same name as the subproject/module.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

This is the configuration I use:

task createInstaller(type: PackageTask, dependsOn: obfuscate) {
    mainClass = project.mainClassName
    bundleJre = true
    generateInstaller = true
    administratorRequired = false
    runnableJar = file('build/libs/' + applicationName + '-' + appVersion + '-obfuscated.jar')
    assetsDir = file('src/main/resources')
    licenseFile = file("LICENSE.txt")
    platform = io.github.fvarrui.javapackager.model.Platform.windows
    copyDependencies = false
    additionalResources = [ file('controller_config')]

    winConfig {
        headerType = HeaderType.gui
        wrapJar = true
        generateSetup = true
        generateMsm = false
        generateMsi = true
        icoFile = file('src/main/resources/icon.ico')
        companyName = '...'
        fileVersion = version
        txtFileVersion = version
        productVersion = version
        txtProductVersion = version
        fileDescription = applicationName + '-' + version
        copyright = "..."
        productName = applicationName
        organizationName = '...'
        organizationUrl = '...'
        disableDirPage = false
        disableFinishedPage = false
    }
}

What is the motivation / use case for changing the behavior?

I request the logical behavior I think

Please tell us about your environment:

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

fvarrui commented 1 year ago

Hi @dkoding! Sorry, I fear this it's not possible right now ... you can set the name option, but this will affect to all generated artifacts artifacts. But don't worry, we can add a new option to set the EXE filename.

I had planned to add the ability to generate more than one EXE per project. I can still take advantage of this new feature to allow specifying the name of the EXE.

<executables>
  <executable>
    <name>exec1</name>
    <mainClass>mainClass1</mainClass>
    <administratorRequired>true</administratorRequired>
  </executable>
  <executable>
    <name>exec2</name>
    <mainClass>mainClass2</mainClass>    
    <administratorRequired>false</administratorRequired>
  </executable>
</executables>

so, for example, in Windows, this will generate exec1.exe and exec2.exe.

fvarrui commented 1 year ago

Hi @dkoding!

After analyzing the situation, adding the ability to generate more than one executable is quite a bit more complex than expected and I don't have much time. So that you don't wait any longer for this feature, I thought about adding a new option to JavaPackager that allows you to specify the name of the executable: executableName (e.g.)

Sorry for the inconveniences

fvarrui commented 1 year ago

I've just added executableName option to JavaPackager.

Please, test 1.7.3-20230628.000611-11 snapshot version (see this link).

dagkodingentur commented 1 month ago

Great thanks! It works as expected!