Using a Buildscript as a Project's Executable?

(Justis Allen) #1

I’ve currently modeled my (currently all-Java) application as a composition of multiple applications–what I’ve been referring to as ‘parsers’ and ‘generators’: essentially, the output of a parser is piped as input to a generator. I’ve currently only implemented a single parser and generator, both of which are written in Java and employed via their individual main methods. But, I like the idea that I (or someone else) might add another parser that properly creates output that the existing generator can process, but is built in a language other than Java (e.g., C++); therefore, assuming this new parser is visible from the build file, a buildscript seems like an appropriate place to process user-specified flags, at least one of which might govern which parser to use–and so this buildscript would serve as the project’s executable.

It seems this flow would work if I establish that the user must have gradle (in which case, they would just run the buildscript), but is it possible to export the buildscript as an executable that, for the time being at least, only requires Java?

I’ve spent a fair amount of time looking into using the application plugin as a solution, but it seems I’d have to either set the main class name to the buildscript in question or hijack the createStartScripts task.