run main, package all libs, run easyb

View: New views
4 Messages — Rating Filter:   Alert me  

run main, package all libs, run easyb

by michael milewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am new to using gradle and have been tearing my hair out on the following.
  1. is there a way to run a program from gradle? yes I know I can execute groovy in a task but how do I execute something from my project, like a class with a main method and have gradle use all the relevant libraries.
  2. gradle dists generates a jar for me but it does not contain any of the dependent libraries, what do I need to setup for all the dependent libraries to be put into the jar? I also was thinking of bundling groovy in a groovy project so that I have a jar that someone with only java will be able to run, how do I do this?
  3. has anyone got easyb working from gradle? I know that there are ant and maven plugins available, how do I run easyb directly or through a plugin from gradle?
thanks

saramic


Re: run main, package all libs, run easyb

by Russel Winder-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael,

On Sun, 2009-03-08 at 17:02 +1100, michael milewski wrote:
> Hi,
>
> I am new to using gradle and have been tearing my hair out on the
> following.
>      1. is there a way to run a program from gradle? yes I know I can
>         execute groovy in a task but how do I execute something from
>         my project, like a class with a main method and have gradle
>         use all the relevant libraries.

I'm afraid you have one of the answers to your question in your
question.  You could use Groovy's process execution capabilities to run
a java job using all the classes resulting from compiling your project.
So create new task, "run" say, that depends on the compile task and then
issues a Java job.  Of course because Gradle works with Ant, there is
the Ant Java task that you could use so as to avoid all the hassles of
managing your own processes.

A question always worth asking in this situation is "How would I do this
in Maven or Ant.  You can guarantee it will be easier in Gradle.

>      1. gradle dists generates a jar for me but it does not contain
>         any of the dependent libraries, what do I need to setup for
>         all the dependent libraries to be put into the jar? I also was
>         thinking of bundling groovy in a groovy project so that I have
>         a jar that someone with only java will be able to run, how do
>         I do this?

It is difficult to be constructive here since you did not attach your
build.gradle file -- I could speculate as to what the problem is, but I
may be a long way from anything useful.

>      1. has anyone got easyb working from gradle? I know that there
>         are ant and maven plugins available, how do I run easyb
>         directly or through a plugin from gradle?

No I haven't.  Whilst I have lots of TDD in my processes, BDD hasn't yet
convinced me that it is anything other than TDD using diffferent syntax.

--
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077


signature.asc (204 bytes) Download Attachment

Re: run main, package all libs, run easyb

by michael milewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I h
I have attached the build.gradle file

>      1. is there a way to run a program from gradle? yes I know I can
>         execute groovy in a task but how do I execute something from
>         my project, like a class with a main method and have gradle
>         use all the relevant libraries.

I'm afraid you have one of the answers to your question in your
question.  You could use Groovy's process execution capabilities to run
a java job using all the classes resulting from compiling your project.
So create new task, "run" say, that depends on the compile task and then
issues a Java job.  Of course because Gradle works with Ant, there is
the Ant Java task that you could use so as to avoid all the hassles of
managing your own processes.

createTask('run', dependsOn: 'compile') {
    WhatTime wt = new WhatTime()
    ...
}
when I run 'gradle run' I get an exception on "unable to resolve class WhatTime" which is in src/main/groovy/WhatTime.groovy so not sure what else I need to do there

A question always worth asking in this situation is "How would I do this
in Maven or Ant.  You can guarantee it will be easier in Gradle.

>      1. gradle dists generates a jar for me but it does not contain
>         any of the dependent libraries, what do I need to setup for
>         all the dependent libraries to be put into the jar? I also was
>         thinking of bundling groovy in a groovy project so that I have
>         a jar that someone with only java will be able to run, how do
>         I do this?

It is difficult to be constructive here since you did not attach your
build.gradle file -- I could speculate as to what the problem is, but I
may be a long way from anything useful.

file attached but my jar file has only the WhatTime.class and none of the dependencies


>      1. has anyone got easyb working from gradle? I know that there
>         are ant and maven plugins available, how do I run easyb
>         directly or through a plugin from gradle?

No I haven't.  Whilst I have lots of TDD in my processes, BDD hasn't yet
convinced me that it is anything other than TDD using diffferent syntax.

yes I agree but there is an attraction to the way that BDD maps so directly to functionality/user stories.


--
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077



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

    http://xircles.codehaus.org/manage_email

build.gradle (2K) Download Attachment

RE: run main, package all libs, run easyb

by Pfau, Matthias :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Michael,
you could try this:

createTask('run', dependsOn: 'compile') {
    def classLoader = this.class.classLoader
    classLaoder.rootLoader.addURL(new URL("file:///build/classes") )
    def whatTime = classLoader.loadClass("WhatTime")
    def wt = whatTime.newInstance()
    ...
}

Kind Regards
Matthias

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

    http://xircles.codehaus.org/manage_email