Override startScripts in Application Plugin

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Override startScripts in Application Plugin

Glyn Walters
Hi

Is it possible to override this task so I can call my own task to generate the shell scripts?

I have tried:

task startScripts(type: CreateStartScripts, overwrite: true) << {
        // call my task
}

But I get "Could not find property 'CreateStartScripts'" as it's declared private.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Override startScripts in Application Plugin

Peter Niederwieser
CreateStartScripts is a public class and part of the Gradle API. However you need to import it (import org.gradle.api.tasks.application.CreateStartScripts). Otherwise the Groovy compiler will think that "CreateStartScripts" refers to a property (rather than a class) which then leads to a runtime error.

I'm not sure why this package isn't imported by default (like so many others). It might be an oversight.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw
Reply | Threaded
Open this post in threaded view
|

Re: Override startScripts in Application Plugin

Glyn Walters
Ah I see, many thanks
Reply | Threaded
Open this post in threaded view
|

Re: Override startScripts in Application Plugin

jotel
This post has NOT been accepted by the mailing list yet.
In reply to this post by Peter Niederwieser
Hey,

I'm interested in creating a couple of tasks based on CreateStartScripts, but unfortunately this class is not public but package visible :( So it's not possible to do this (directly importing won't help in this case). It would be very nice if you could make this class public.

JL

Peter Niederwieser wrote
CreateStartScripts is a public class and part of the Gradle API. However you need to import it (import org.gradle.api.tasks.application.CreateStartScripts). Otherwise the Groovy compiler will think that "CreateStartScripts" refers to a property (rather than a class) which then leads to a runtime error.

I'm not sure why this package isn't imported by default (like so many others). It might be an oversight.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw