TheBoegl / gradle-launch4j

A gradle-plugin to create windows executables with launch4j

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple, complete, working example

opened this issue · comments

It'd be nice to see the documentation updated with an example that would work against the latest version. For example:

build.gradle

plugins {
  id 'edu.sc.seis.launch4j' version '2.1.0'
}

apply plugin: 'java'
apply plugin: 'application'

applicationName = 'example'
mainClassName = 'com.domain.ApplicationMain'

repositories {
  mavenCentral()
}

jar {
  baseName = applicationName
  
  doFirst {
    from {
      configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
  }

  // Remove digital signature files to ensure an executable JAR file.
  exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' 

  manifest {
    attributes 'Main-Class': mainClassName
    attributes 'Class-Path': configurations.compile.collect {
     'libs/' + it.getName()
    }.join(' ')
  }
}

distributions {
  main {
    baseName = applicationName
    contents {
      from { ['LICENSE', 'README.md'] }
      into( 'images' ) {
        from { 'images' }
      }
    }
  }
  
  launch4j {
    mainClassName = mainClassName

    /* Example options here? Set icon, executable filename, etc. */
  }

  assemble.dependsOn createAllExecutables
}

@DaveJarvis I think a working simple example configuration is already in the README. IMHO your example is way to complicated and is not the recommended way, but feel free to create a PR or comment here.

The example configuration in the README didn't work for me. I was getting errors about the icon -- not that it couldn't find it, but that the icon syntax was not allowed:

  launch4j {
    mainClassName = mainClassName
    icon = 'logo.ico'
  }

The icon = 'logo.ico' wouldn't work for me (the path was correct), but removing the line was okay. I don't have the error message off hand, but I can get it to you if necessary. Yes, the example I gave above is a bit more complicated than it needs to be, but the idea stands: a simple, working, minimal example would be helpful.

Additionally, the documentation shows two example configurations. Pick the preferred method and put the other one elsewhere (e.g., outside of README.md).

@DaveJarvis see #43 for your issue with the icon.

Issue #43 doesn't provide any information about the problem or how to resolve it -- it merely states that there was an issue, resolved by a new commit. Are there any unit tests to make sure the configuration options are being parsed correctly in various situations? I also noticed that other parameters failed to parse correctly, but that might have been due to the icon issue.

In other words, why did this type of error get into the project and how can the process be improved so that it doesn't happen again? :-)

Feel free to read the commit message and take a look at the pushed files at 48f7f08 to find the unit test you've missed. Afterwards use the latest version (2.2) of this plugin and feel happy.

You should create new issues for incorrectly parsed parameters.

In other words, why did this type of error get into the project and how can the process be improved so that it doesn't happen again? :-)

😕 Submit a PR or an issue?

commented

Just to say +1 for the example supplied. It is just what I'm trying to get working too:

  • Launch4J, for Windows users (obviously)
  • Runnable .jar for Linux users
  • 'application' so casual / curious developers can jump in and run the latest code from source with an easy 1-liner