Gradle: how to use one line output as input for launch4j

I would like to create an exe file without putting all the required libraries next to the exe. Earlier with ant I created a standalone jar file with one jar and then wrapped it in an exe file using start4j.

Gradle has plugins for both and standalone, both work very well with little to no configuration.

But how can I use the created one jar as input for launch4j?

This is my current build file:

apply plugin: 'java'
apply plugin: 'launch4j'
apply plugin: 'gradle-one-jar'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'edu.sc.seis.gradle:launch4j:1.0.6'
        classpath 'com.github.rholder:gradle-one-jar:1.0.4'
    }
}

launch4j {
    mainClassName = "de.my.umkopierer.Umkopierer"
    launch4jCmd = "C:/Program Files (x86)/Launch4j/launch4j"
    jar = "lib/Umkopierer-1.0.jar"
    headerType = "console"
    dontWrapJar = false
}

sourceCompatibility = 1.7
version = '1.0'

jar {
    manifest {
        attributes 'Implementation-Title': 'Umkopierer', 'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile 'com.google.guava:guava:18.0'    
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.4'
    compile 'com.fasterxml.jackson.datatype:jackson-datatype-jdk7:2.4.4'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'


    testCompile group: 'junit', name: 'junit', version: '4.+'
}

task oneJar(type: OneJar) {
    mainClass = "de.stiffi.umkopierer.Umkopierer"
}

      

+3


source to share


1 answer


I solved this by making the launch4j "createExe" task dependent on onejar / fatjar (or any other fat jar creation method). For example:.

tasks.createExe.dependsOn('oneJar')     


task launch4j(overwrite: true, dependsOn: ['createExe']){
}

      

Also I think your gradle build file should contain a main class attribute like



manifest {
    attributes 'Main-Class':'com.example.MyMainClass'
}

      

(at least that's the case if you're using the fatjar gradle plugin).

+1


source







All Articles