I'll try to clarify my example.

I have a gradle script to build a DBUtil.jar in my project.  Inside this
DBUtil.jar I have a method DBUtil.cleanDatabase() which is part of my
product. I want to leverage this utility method from gradle so a developer
can just type "gradle cleanDatabase".

However since my gradle build also builds the DBUtil.jar I'm in a situation
where I can't reference the DBUtil java class in my gradle build or it won't
compile.  In ant or ruby (buildr/rake) this wouldn't be a problem since
there is no compile of the script itself.  In ant/ruby if you tried to call
"ant cleanDatabase" and the class wasn't available because it hadn't been
built you would get a ClassNotFound error.

So I want thinking it would be cool if I could mark the body of a task so it
wasn't pre-compiled.  Sounds like it's not doable.

Levi suggested the JavaExec task.  This will work.  Or the ant exec task,
I'd have to look at which is less ugly......

phil



On Thu, Mar 24, 2011 at 6:17 PM, Peter Niederwieser <[email protected]>wrote:

> Compiling only a part of a script isn't really an option. Could you explain
> in more detail what problem you are trying to solve? There might be a
> simple
> solution to it, such as leveraging the 'buildSrc' project.
>
> --
> Peter Niederwieser
> Developer, Gradle
> http://www.gradle.org
> Trainer & Consultant, Gradleware
> http://www.gradleware.com
> Creator, Spock Framework
> http://spockframework.org
>
>
> phil swenson wrote:
> >
> > This might be more of a groovy question rather than a gradle question -
> > not
> > sure.
> >
> > One problem with the choice of Groovy as the build script language is
> it's
> > not interpreted.  This means if your build references an artifact that
> the
> > build itself is building, you are in an awkward situation when the
> > artifact
> > hasn't ever been built - even if you aren't calling the task that depends
> > on
> > the missing artifact.
> >
> > I think that a possible solution to this issues is if groovy (or gradle)
> > allowed sections of the script to not be compiled until that part of the
> > script is actually executed.
> >
> > something like this (&lt;{ code  }&gt; signifies don't compile ahead of
> > time):
> >
> > task cleanDB {
> >     description = &quot;Clean the db&quot;
> >     &lt;{
> >
> >       com.blah.DBUtil.cleanDB()
> >      }&gt;
> >
> > }
> >
> >
> > So DBUtil.cleanDB() isn't compiled until cleanDB task is executed.  This
> > would allow tasks to be included in the build scripts that reference
> > artifacts that the build script builds.  If that makes sense.
> >
> > Does this idea make any sense?  I don't even know if it's possible....
> >
> > phil
> >
>
>
> --
> View this message in context:
> http://gradle.1045684.n5.nabble.com/Interpreted-gradle-script-tp4262811p4263336.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

Reply via email to