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.
Either import the class (org.gradle.api.tasks.application.CreateStartScripts
), or use the application
plugin. The latter is generally preferable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With