Hello all,

I'm reading "Gradle Effective Implementation Guide" by mrhaki and I =
noticed a small hiccup in the application plugin.

With this build file:

        apply plugin: 'java'
        apply plugin: 'application'
        archivesBaseName =3D 'gradle.sample'
        version =3D '1.0'
        mainClassName =3D 'gradle.sample.SampleApp'

running "gradle startScripts" will compile and create the jar =
'build/libs/gradle.sample-1.0.jar' and the scripts =
'build/scripts/chapter6' and 'build/scripts/chapter6.bat'.

The problem is that the scripts generated refer to the 'lib' (note no =
trailing 's') directory and thus trying to run them at that point fails:

[marcpa@moliere-wifi chapter6]$ gradle --build-file appPlugin.gradle =
clean startScripts
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=3DUTF-8
:clean
:compileJava
:processResources
:classes
:jar
:startScripts

BUILD SUCCESSFUL

Total time: 1.503 secs
[marcpa@moliere-wifi chapter6]$ ./build/scripts/chapter6
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=3DUTF-8
Exception in thread "main" java.lang.NoClassDefFoundError: =
gradle/sample/SampleApp
Caused by: java.lang.ClassNotFoundException: gradle.sample.SampleApp
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[marcpa@moliere-wifi chapter6]$

However, if you run 'gradle installApp', then the jar is copied to =
'build/install/lib', the scripts to 'build/install/bin' and you can =
execute the scripts because now the lib subdirectory exists.

Looking at the source of ApplicationPlugin it seems intentional, but I =
find it confusing to end up with a script that cannot be used to run the =
application after "gradle startScripts".

Should I open an issue on that ?

Regards,
Marc Paquette

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to