Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Gradle's CreateStartScripts Task

I want to use gradle's CreateStartScripts Task to generate the script to start the application.

I use it in the following way:

apply plugin: 'java'
mainClass = 'UIMain';

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

task copyResources(type: Copy) {
    from 'config.ini'
    into 'build/dist'
}

task copyLibs(type: Copy) {
    from configurations.default
    from configurations.default.allArtifacts.files
    into 'build/dist/libs'
}

task generateScript(type: CreateStartScripts) {
     applicationName = "Dagang"
     mainClassName = mainClass
     outputDir = "build/dist/"
     classpath = ""
}

task distribute(dependsOn: [
    build,
    copyLibs,
    copyResources,
    generateScript
    ]) <<{ 

description = 'Copies all the project libs to the distribution place.' 
}

However when I run the build, it runs into error like:

A problem occurred evaluating root project 'dagang'. [org.gradle.BuildExceptionReporter] Cause: Could not find property 'CreateStartScripts' on root project 'dagang'.

Can anyone shed me some light? Thanks.

like image 722
Wudong Avatar asked Jan 09 '12 10:01

Wudong


1 Answers

Either import the class (org.gradle.api.tasks.application.CreateStartScripts), or use the application plugin. The latter is generally preferable.

like image 179
Peter Niederwieser Avatar answered Oct 03 '22 13:10

Peter Niederwieser