Given a project ‘sample’ using the application plugin with the following build file
apply plugin: 'java' apply plugin: 'application' archivesBaseName = 'gradle.sample' version = '1.0' mainClassName = 'gradle.sample.SampleApp'
and a java file src/main/java/gradle/sample/SamplApp.java existing, having a main and compiling with success, one cannot do “gradle startScripts” followed by “./build/scripts/sample” because the generated script refers to ‘lib/gradle.sample-1.0.jar’ in its classpath but at that point, the jar is in ‘build/libs’.
Running “gradle installApp” will create ‘build/install’ with subdirectories ‘bin’ and ‘lib’ and then running ‘./build/install/bin/sample’ will work correctly.
I’ve created this pull request https://github.com/gradle/gradle/pull/146 to support this use case : startScripts prepares 2 classpaths, one for the “in-place” scenario, the other for the “installed” scenario and the generated script decides at run-time which to use based on the presence.