You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Raphael Bauduin <rb...@gmail.com> on 2016/03/08 11:33:33 UTC

building a jar from groovy script with gradle

Hi,

I'm trying to package a groovy script as a jar with the help of gradle,
I use this gradle config: http://pastebin.com/RFEhzMCp

it builds fine, but when I try to run it with java -jar path_to.jar
I get this error:
Error: A JNI error has occurred, please check your installation and try
again
Exception in thread "main" java.lang.SecurityException: Invalid signature
file digest for Manifest main attributes

The only suggestions I found online applied when people repackaged jars,
which is not my case.
Any suggestion?

Thanks

Rb

Re: building a jar from groovy script with gradle

Posted by Schalk Cronjé <ys...@gmail.com>.
In that case I would suggest laying your project out as a minimal Groovy 
project

   rootDir -- src -- main -- groovy - yourpackage -- MyClass.groovy, 
HelperClass.groovy

and make your build.gradle to be like

    apply plugin : 'groovy'
    apply plugin : 'application'
    mainClassName='MyClass'

    dependencies {
       compile 'org.codehaus.groovy:groovy-all:2.0.0'
       compile '..... instead of @Grab, put all other maven coordinates
    here as compile lines ...'
    }

Running distZip task in Gradle will give you a zip which you can expand 
elsewhere and just run the script which is in the bin folder.



On 08/03/2016 11:05, Raphael Bauduin wrote:
> I have a groovy class with a main that has to be run, another help 
> class in Groovy, and a bunch of jars needed by the app in 
>  ~/.groovy/lib/.
>
> I got it working by using these lines (replacing what I had in the 
> initial config):
>
>     from configurations.runtime.asFileTree.files.collect { 
> zipTree(it).matching{exclude{it.path.contains('DSA') or 
> it.path.contains('RSA') or it.path.contains('SF') }} }
>     from configurations.compile.collect {
>               it.isDirectory() ? it : 
> zipTree(it).matching{exclude{it.path.contains('DSA') or 
> it.path.contains('RSA') or it.path.contains('SF') }}
>     }
>
>
> This removes the signatures of the included jars. I am not familiar 
> with this so I'm not sure about the implications.
> I'll read your suggestions with interest!
>
> Thanks
>
>
>
> On Tue, Mar 8, 2016 at 11:45 AM, Schalk Cronjé <ysb33r@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     I can spot a number of issues in your Gradle script, howver I need
>     to understand context.
>
>     [1] Are you trying to put a single Groovy script + required Groovy
>     JARs into a JAR?
>
>     OR
>
>     [2] Are you trying to build a proper Groovy application consisting
>     of a coouple of class files en dependent JARs?
>
>
>     On 08/03/2016 10:33, Raphael Bauduin wrote:
>
>
>         Hi,
>
>         I'm trying to package a groovy script as a jar with the help
>         of gradle,
>         I use this gradle config: http://pastebin.com/RFEhzMCp
>
>         it builds fine, but when I try to run it with java -jar
>         path_to.jar
>         I get this error:
>         Error: A JNI error has occurred, please check your
>         installation and try again
>         Exception in thread "main" java.lang.SecurityException:
>         Invalid signature file digest for Manifest main attributes
>
>         The only suggestions I found online applied when people
>         repackaged jars, which is not my case.
>         Any suggestion?
>
>         Thanks
>
>         Rb
>
>
>
>     -- 
>     Schalk W. Cronjé
>     Twitter / Ello / Toeter : @ysb33r
>
>
>
>
> -- 
> Web database: http://www.myowndb.com
> Free Software Developers Meeting: http://www.fosdem.org


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r


Re: building a jar from groovy script with gradle

Posted by Raphael Bauduin <rb...@gmail.com>.
I have a groovy class with a main that has to be run, another help class in
Groovy, and a bunch of jars needed by the app in  ~/.groovy/lib/.

I got it working by using these lines (replacing what I had in the initial
config):

    from configurations.runtime.asFileTree.files.collect {
zipTree(it).matching{exclude{it.path.contains('DSA') or
it.path.contains('RSA') or it.path.contains('SF') }} }
    from configurations.compile.collect {
              it.isDirectory() ? it :
zipTree(it).matching{exclude{it.path.contains('DSA') or
it.path.contains('RSA') or it.path.contains('SF') }}
    }


This removes the signatures of the included jars. I am not familiar with
this so I'm not sure about the implications.
I'll read your suggestions with interest!

Thanks



On Tue, Mar 8, 2016 at 11:45 AM, Schalk Cronjé <ys...@gmail.com> wrote:

> I can spot a number of issues in your Gradle script, howver I need to
> understand context.
>
> [1] Are you trying to put a single Groovy script + required Groovy JARs
> into a JAR?
>
> OR
>
> [2] Are you trying to build a proper Groovy application consisting of a
> coouple of class files en dependent JARs?
>
>
> On 08/03/2016 10:33, Raphael Bauduin wrote:
>
>>
>> Hi,
>>
>> I'm trying to package a groovy script as a jar with the help of gradle,
>> I use this gradle config: http://pastebin.com/RFEhzMCp
>>
>> it builds fine, but when I try to run it with java -jar path_to.jar
>> I get this error:
>> Error: A JNI error has occurred, please check your installation and try
>> again
>> Exception in thread "main" java.lang.SecurityException: Invalid signature
>> file digest for Manifest main attributes
>>
>> The only suggestions I found online applied when people repackaged jars,
>> which is not my case.
>> Any suggestion?
>>
>> Thanks
>>
>> Rb
>>
>
>
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>
>


-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Re: building a jar from groovy script with gradle

Posted by Henrik Martin <he...@netgate.net>.
That's good to know! I've only used the bootRepackage stuff for Spring 
Boot apps, so I've never really examined the bare dependencies of the 
uber jar without other Spring dependencies. The Spring Boot stuff in 
general is very nice, and I use it for everything from small IoT 
projects to Big Data deployments. Cheers,

-H

On 3/8/16 9:08 AM, David Dawson wrote:
> good steer on shadowJar.
>
> I can confirm though that all you end up with is a couple of hundred 
> kb of spring boot launcher. Nothing else spring is pulled in.
>
>
> On 8 March 2016 at 17:03, Henrik Martin <henrik@netgate.net 
> <ma...@netgate.net>> wrote:
>
>     For "uber jars", I use both Spring Boot's bootRepackage, and
>     shadowJar, the Gradle port of Maven Shadow. Both work really well
>     and are easy to use from Gradle. The only thing about using Spring
>     Boot is that you probably end up with a bunch of transient
>     dependencies for Spring/Spring Boot that may bloat your runnable
>     jar file. From that perspective, I think the shadowJar solution
>     will result in fewer dependencies. Here's the link to shadowJar if
>     you want to check it out:
>
>     https://github.com/johnrengelman/shadow
>
>     Cheers,
>
>     -H
>
>
>     On 3/8/16 6:40 AM, David Dawson wrote:
>>     I actually re-use the spring boot plugin.
>>
>>     You don't have to use it to build a spring boot application, it
>>     can build vanilla apps too.
>>
>>     add the spring boot plugin, set the mainClass attribute as in
>>     their examples and do a gradle bootRepackage.
>>
>>     You'll end up with a single runnable jar file.
>>
>>     You can even do that with no source, just jars in the deps list
>>     and reference a class in one of the dependencies.
>>
>>
>>
>>     On 8 March 2016 at 14:38, Schalk Cronjé <ysb33r@gmail.com
>>     <ma...@gmail.com>> wrote:
>>
>>         What's wrong with running a .bat file?
>>
>>
>>         On 08/03/2016 14:30, Gerald Wiltse wrote:
>>>         I have a similar situation I am about to tackle, building an
>>>         installer that executes Groovy code. This will be going to
>>>         clients and run on windows, so it really has to be an EXE.
>>>
>>>         Anybody have good experience with JAR-to-EXE packers or
>>>         something?
>>>
>>>         Gerald R. Wiltse
>>>         jerrywiltse@gmail.com <ma...@gmail.com>
>>>
>>>
>>>         On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason
>>>         <Jason.Winnebeck@windstream.com
>>>         <ma...@windstream.com>> wrote:
>>>
>>>             I've "deployed" some scripts to other users in my
>>>             organization where Java but not Groovy is installed
>>>             through the GroovyWrapper script. I got it from Codehaus
>>>             and I can't find the original copy anywhere but I found
>>>             a fork of it at
>>>             https://github.com/sdanzan/groovy-wrapper that appears
>>>             to have more features than the original. The original I
>>>             have basically just uses the Ant inside of the Groovy
>>>             distribution to compile a single Groovy file and merge
>>>             that file, embeddable groovy JAR and some of the Groovy
>>>             libs into a single jar you can run with java -jar.
>>>
>>>             Looking at the code it appears the main difference in
>>>             that updated script is that it supports adding @Grab'd
>>>             dependencies into the single JAR, presumably to prevent
>>>             users from having to download them.
>>>
>>>             Jason
>>>
>>>             -----Original Message-----
>>>             From: Jim Northrop
>>>             [mailto:james.b.northrop@googlemail.com
>>>             <ma...@googlemail.com>]
>>>             Sent: Tuesday, March 08, 2016 8:19 AM
>>>             To: users@groovy.apache.org <ma...@groovy.apache.org>
>>>             Subject: Re: building a jar from groovy script with gradle
>>>
>>>             Out of interest, what is the typical deployment strategy
>>>             for a runnable Groovy class w/main method? I have been
>>>             trying to make a user executable jar but as 2 diff.jars.
>>>             One jar is only my code, no support jars and 2nd is
>>>             mystuff-all-v1.0.jar as a bundle w/all dependency jars
>>>             included hence runnable. End user can choose jar.
>>>
>>>              Are there other strategies to package code 4 deployment?
>>>             Thx.
>>>
>>>             Sent from my iPad
>>>
>>>             > On 8 Mar 2016, at 11:45, Schalk Cronjé
>>>             <ysb33r@gmail.com <ma...@gmail.com>> wrote:
>>>             >
>>>             > I can spot a number of issues in your Gradle script,
>>>             howver I need to understand context.
>>>             >
>>>             > [1] Are you trying to put a single Groovy script +
>>>             required Groovy JARs into a JAR?
>>>             >
>>>             > OR
>>>             >
>>>             > [2] Are you trying to build a proper Groovy
>>>             application consisting of a coouple of class files en
>>>             dependent JARs?
>>>             >
>>>             >> On 08/03/2016 10:33, Raphael Bauduin wrote:
>>>             >>
>>>             >> Hi,
>>>             >>
>>>             >> I'm trying to package a groovy script as a jar with
>>>             the help of
>>>             >> gradle, I use this gradle config:
>>>             http://pastebin.com/RFEhzMCp
>>>             >>
>>>             >> it builds fine, but when I try to run it with java
>>>             -jar path_to.jar I
>>>             >> get this error:
>>>             >> Error: A JNI error has occurred, please check your
>>>             installation and
>>>             >> try again Exception in thread "main"
>>>             java.lang.SecurityException:
>>>             >> Invalid signature file digest for Manifest main
>>>             attributes
>>>             >>
>>>             >> The only suggestions I found online applied when
>>>             people repackaged jars, which is not my case.
>>>             >> Any suggestion?
>>>             >>
>>>             >> Thanks
>>>             >>
>>>             >> Rb
>>>             >
>>>             >
>>>             > --
>>>             > Schalk W. Cronjé
>>>             > Twitter / Ello / Toeter : @ysb33r
>>>             >
>>>
>>>             ----------------------------------------------------------------------
>>>             This email message and any attachments are for the sole
>>>             use of the intended recipient(s). Any unauthorized
>>>             review, use, disclosure or distribution is prohibited.
>>>             If you are not the intended recipient, please contact
>>>             the sender by reply email and destroy all copies of the
>>>             original message and any attachments.
>>>
>>>
>>
>>
>>         -- 
>>         Schalk W. Cronjé
>>         Twitter / Ello / Toeter : @ysb33r
>>
>>
>>
>>
>>     -- 
>>
>>
>>     David Dawson | CEO | Simplicity Itself
>>
>>     Tel +44 7866 011 256 <tel:%2B44%207866%20011%20256>
>>     Skype: davidadawson
>>     david.dawson@simplicityitself.com
>>     <ma...@simplicityitself.com>
>>     http://www.simplicityitself.com
>
>
>
>
> -- 
>
>
> David Dawson | CEO | Simplicity Itself
>
> Tel +44 7866 011 256
> Skype: davidadawson
> david.dawson@simplicityitself.com 
> <ma...@simplicityitself.com>
> http://www.simplicityitself.com


Re: building a jar from groovy script with gradle

Posted by David Dawson <da...@simplicityitself.com>.
good steer on shadowJar.

I can confirm though that all you end up with is a couple of hundred kb of
spring boot launcher. Nothing else spring is pulled in.


On 8 March 2016 at 17:03, Henrik Martin <he...@netgate.net> wrote:

> For "uber jars", I use both Spring Boot's bootRepackage, and shadowJar,
> the Gradle port of Maven Shadow. Both work really well and are easy to use
> from Gradle. The only thing about using Spring Boot is that you probably
> end up with a bunch of transient dependencies for Spring/Spring Boot that
> may bloat your runnable jar file. From that perspective, I think the
> shadowJar solution will result in fewer dependencies. Here's the link to
> shadowJar if you want to check it out:
>
> https://github.com/johnrengelman/shadow
>
> Cheers,
>
> -H
>
>
> On 3/8/16 6:40 AM, David Dawson wrote:
>
> I actually re-use the spring boot plugin.
>
> You don't have to use it to build a spring boot application, it can build
> vanilla apps too.
>
> add the spring boot plugin, set the mainClass attribute as in their
> examples and do a gradle bootRepackage.
>
> You'll end up with a single runnable jar file.
>
> You can even do that with no source, just jars in the deps list and
> reference a class in one of the dependencies.
>
>
>
> On 8 March 2016 at 14:38, Schalk Cronjé <ys...@gmail.com> wrote:
>
>> What's wrong with running a .bat file?
>>
>>
>> On 08/03/2016 14:30, Gerald Wiltse wrote:
>>
>> I have a similar situation I am about to tackle, building an installer
>> that executes Groovy code. This will be going to clients and run on
>> windows, so it really has to be an EXE.
>>
>> Anybody have good experience with JAR-to-EXE packers or something?
>>
>> Gerald R. Wiltse
>> jerrywiltse@gmail.com
>>
>>
>> On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason <
>> <Ja...@windstream.com> wrote:
>>
>>> I've "deployed" some scripts to other users in my organization where
>>> Java but not Groovy is installed through the GroovyWrapper script. I got it
>>> from Codehaus and I can't find the original copy anywhere but I found a
>>> fork of it at <https://github.com/sdanzan/groovy-wrapper>
>>> https://github.com/sdanzan/groovy-wrapper that appears to have more
>>> features than the original. The original I have basically just uses the Ant
>>> inside of the Groovy distribution to compile a single Groovy file and merge
>>> that file, embeddable groovy JAR and some of the Groovy libs into a single
>>> jar you can run with java -jar.
>>>
>>> Looking at the code it appears the main difference in that updated
>>> script is that it supports adding @Grab'd dependencies into the single JAR,
>>> presumably to prevent users from having to download them.
>>>
>>> Jason
>>>
>>> -----Original Message-----
>>> From: Jim Northrop [mailto: <ja...@googlemail.com>
>>> james.b.northrop@googlemail.com]
>>> Sent: Tuesday, March 08, 2016 8:19 AM
>>> To: users@groovy.apache.org
>>> Subject: Re: building a jar from groovy script with gradle
>>>
>>> Out of interest, what is the typical deployment strategy for a runnable
>>> Groovy class w/main method? I have been trying to make a user executable
>>> jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is
>>> mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence
>>> runnable. End user can choose jar.
>>>
>>>  Are there other strategies to package code 4 deployment?
>>> Thx.
>>>
>>> Sent from my iPad
>>>
>>> > On 8 Mar 2016, at 11:45, Schalk Cronjé <ys...@gmail.com> wrote:
>>> >
>>> > I can spot a number of issues in your Gradle script, howver I need to
>>> understand context.
>>> >
>>> > [1] Are you trying to put a single Groovy script + required Groovy
>>> JARs into a JAR?
>>> >
>>> > OR
>>> >
>>> > [2] Are you trying to build a proper Groovy application consisting of
>>> a coouple of class files en dependent JARs?
>>> >
>>> >> On 08/03/2016 10:33, Raphael Bauduin wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm trying to package a groovy script as a jar with the help of
>>> >> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
>>> >>
>>> >> it builds fine, but when I try to run it with java -jar path_to.jar I
>>> >> get this error:
>>> >> Error: A JNI error has occurred, please check your installation and
>>> >> try again Exception in thread "main" java.lang.SecurityException:
>>> >> Invalid signature file digest for Manifest main attributes
>>> >>
>>> >> The only suggestions I found online applied when people repackaged
>>> jars, which is not my case.
>>> >> Any suggestion?
>>> >>
>>> >> Thanks
>>> >>
>>> >> Rb
>>> >
>>> >
>>> > --
>>> > Schalk W. Cronjé
>>> > Twitter / Ello / Toeter : @ysb33r
>>> >
>>>
>>> ----------------------------------------------------------------------
>>> This email message and any attachments are for the sole use of the
>>> intended recipient(s). Any unauthorized review, use, disclosure or
>>> distribution is prohibited. If you are not the intended recipient, please
>>> contact the sender by reply email and destroy all copies of the original
>>> message and any attachments.
>>>
>>
>>
>>
>> --
>> Schalk W. Cronjé
>> Twitter / Ello / Toeter : @ysb33r
>>
>>
>
>
> --
>
>
> David Dawson | CEO | Simplicity Itself
>
> Tel +44 7866 011 256
> Skype: davidadawson
> david.dawson@simplicityitself.com
> http://www.simplicityitself.com
>
>
>


-- 


David Dawson | CEO | Simplicity Itself

Tel +44 7866 011 256
Skype: davidadawson
david.dawson@simplicityitself.com
http://www.simplicityitself.com

Re: building a jar from groovy script with gradle

Posted by Henrik Martin <he...@netgate.net>.
For "uber jars", I use both Spring Boot's bootRepackage, and shadowJar, 
the Gradle port of Maven Shadow. Both work really well and are easy to 
use from Gradle. The only thing about using Spring Boot is that you 
probably end up with a bunch of transient dependencies for Spring/Spring 
Boot that may bloat your runnable jar file. From that perspective, I 
think the shadowJar solution will result in fewer dependencies. Here's 
the link to shadowJar if you want to check it out:

https://github.com/johnrengelman/shadow

Cheers,

-H

On 3/8/16 6:40 AM, David Dawson wrote:
> I actually re-use the spring boot plugin.
>
> You don't have to use it to build a spring boot application, it can 
> build vanilla apps too.
>
> add the spring boot plugin, set the mainClass attribute as in their 
> examples and do a gradle bootRepackage.
>
> You'll end up with a single runnable jar file.
>
> You can even do that with no source, just jars in the deps list and 
> reference a class in one of the dependencies.
>
>
>
> On 8 March 2016 at 14:38, Schalk Cronjé <ysb33r@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     What's wrong with running a .bat file?
>
>
>     On 08/03/2016 14:30, Gerald Wiltse wrote:
>>     I have a similar situation I am about to tackle, building an
>>     installer that executes Groovy code. This will be going to
>>     clients and run on windows, so it really has to be an EXE.
>>
>>     Anybody have good experience with JAR-to-EXE packers or something?
>>
>>     Gerald R. Wiltse
>>     jerrywiltse@gmail.com <ma...@gmail.com>
>>
>>
>>     On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason
>>     <Jason.Winnebeck@windstream.com
>>     <ma...@windstream.com>> wrote:
>>
>>         I've "deployed" some scripts to other users in my
>>         organization where Java but not Groovy is installed through
>>         the GroovyWrapper script. I got it from Codehaus and I can't
>>         find the original copy anywhere but I found a fork of it at
>>         https://github.com/sdanzan/groovy-wrapper that appears to
>>         have more features than the original. The original I have
>>         basically just uses the Ant inside of the Groovy distribution
>>         to compile a single Groovy file and merge that file,
>>         embeddable groovy JAR and some of the Groovy libs into a
>>         single jar you can run with java -jar.
>>
>>         Looking at the code it appears the main difference in that
>>         updated script is that it supports adding @Grab'd
>>         dependencies into the single JAR, presumably to prevent users
>>         from having to download them.
>>
>>         Jason
>>
>>         -----Original Message-----
>>         From: Jim Northrop [mailto:james.b.northrop@googlemail.com
>>         <ma...@googlemail.com>]
>>         Sent: Tuesday, March 08, 2016 8:19 AM
>>         To: users@groovy.apache.org <ma...@groovy.apache.org>
>>         Subject: Re: building a jar from groovy script with gradle
>>
>>         Out of interest, what is the typical deployment strategy for
>>         a runnable Groovy class w/main method? I have been trying to
>>         make a user executable jar but as 2 diff.jars. One jar is
>>         only my code, no support jars and 2nd is mystuff-all-v1.0.jar
>>         as a bundle w/all dependency jars included hence runnable.
>>         End user can choose jar.
>>
>>          Are there other strategies to package code 4 deployment?
>>         Thx.
>>
>>         Sent from my iPad
>>
>>         > On 8 Mar 2016, at 11:45, Schalk Cronjé <ysb33r@gmail.com
>>         <ma...@gmail.com>> wrote:
>>         >
>>         > I can spot a number of issues in your Gradle script, howver
>>         I need to understand context.
>>         >
>>         > [1] Are you trying to put a single Groovy script + required
>>         Groovy JARs into a JAR?
>>         >
>>         > OR
>>         >
>>         > [2] Are you trying to build a proper Groovy application
>>         consisting of a coouple of class files en dependent JARs?
>>         >
>>         >> On 08/03/2016 10:33, Raphael Bauduin wrote:
>>         >>
>>         >> Hi,
>>         >>
>>         >> I'm trying to package a groovy script as a jar with the
>>         help of
>>         >> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
>>         >>
>>         >> it builds fine, but when I try to run it with java -jar
>>         path_to.jar I
>>         >> get this error:
>>         >> Error: A JNI error has occurred, please check your
>>         installation and
>>         >> try again Exception in thread "main"
>>         java.lang.SecurityException:
>>         >> Invalid signature file digest for Manifest main attributes
>>         >>
>>         >> The only suggestions I found online applied when people
>>         repackaged jars, which is not my case.
>>         >> Any suggestion?
>>         >>
>>         >> Thanks
>>         >>
>>         >> Rb
>>         >
>>         >
>>         > --
>>         > Schalk W. Cronjé
>>         > Twitter / Ello / Toeter : @ysb33r
>>         >
>>
>>         ----------------------------------------------------------------------
>>         This email message and any attachments are for the sole use
>>         of the intended recipient(s). Any unauthorized review, use,
>>         disclosure or distribution is prohibited. If you are not the
>>         intended recipient, please contact the sender by reply email
>>         and destroy all copies of the original message and any
>>         attachments.
>>
>>
>
>
>     -- 
>     Schalk W. Cronjé
>     Twitter / Ello / Toeter : @ysb33r
>
>
>
>
> -- 
>
>
> David Dawson | CEO | Simplicity Itself
>
> Tel +44 7866 011 256
> Skype: davidadawson
> david.dawson@simplicityitself.com 
> <ma...@simplicityitself.com>
> http://www.simplicityitself.com


Re: building a jar from groovy script with gradle

Posted by David Dawson <da...@simplicityitself.com>.
I actually re-use the spring boot plugin.

You don't have to use it to build a spring boot application, it can build
vanilla apps too.

add the spring boot plugin, set the mainClass attribute as in their
examples and do a gradle bootRepackage.

You'll end up with a single runnable jar file.

You can even do that with no source, just jars in the deps list and
reference a class in one of the dependencies.



On 8 March 2016 at 14:38, Schalk Cronjé <ys...@gmail.com> wrote:

> What's wrong with running a .bat file?
>
>
> On 08/03/2016 14:30, Gerald Wiltse wrote:
>
> I have a similar situation I am about to tackle, building an installer
> that executes Groovy code. This will be going to clients and run on
> windows, so it really has to be an EXE.
>
> Anybody have good experience with JAR-to-EXE packers or something?
>
> Gerald R. Wiltse
> jerrywiltse@gmail.com
>
>
> On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason <
> <Ja...@windstream.com> wrote:
>
>> I've "deployed" some scripts to other users in my organization where Java
>> but not Groovy is installed through the GroovyWrapper script. I got it from
>> Codehaus and I can't find the original copy anywhere but I found a fork of
>> it at https://github.com/sdanzan/groovy-wrapper that appears to have
>> more features than the original. The original I have basically just uses
>> the Ant inside of the Groovy distribution to compile a single Groovy file
>> and merge that file, embeddable groovy JAR and some of the Groovy libs into
>> a single jar you can run with java -jar.
>>
>> Looking at the code it appears the main difference in that updated script
>> is that it supports adding @Grab'd dependencies into the single JAR,
>> presumably to prevent users from having to download them.
>>
>> Jason
>>
>> -----Original Message-----
>> From: Jim Northrop [mailto:james.b.northrop@googlemail.com]
>> Sent: Tuesday, March 08, 2016 8:19 AM
>> To: users@groovy.apache.org
>> Subject: Re: building a jar from groovy script with gradle
>>
>> Out of interest, what is the typical deployment strategy for a runnable
>> Groovy class w/main method? I have been trying to make a user executable
>> jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is
>> mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence
>> runnable. End user can choose jar.
>>
>>  Are there other strategies to package code 4 deployment?
>> Thx.
>>
>> Sent from my iPad
>>
>> > On 8 Mar 2016, at 11:45, Schalk Cronjé < <ys...@gmail.com>
>> ysb33r@gmail.com> wrote:
>> >
>> > I can spot a number of issues in your Gradle script, howver I need to
>> understand context.
>> >
>> > [1] Are you trying to put a single Groovy script + required Groovy JARs
>> into a JAR?
>> >
>> > OR
>> >
>> > [2] Are you trying to build a proper Groovy application consisting of a
>> coouple of class files en dependent JARs?
>> >
>> >> On 08/03/2016 10:33, Raphael Bauduin wrote:
>> >>
>> >> Hi,
>> >>
>> >> I'm trying to package a groovy script as a jar with the help of
>> >> gradle, I use this gradle config: <http://pastebin.com/RFEhzMCp>
>> http://pastebin.com/RFEhzMCp
>> >>
>> >> it builds fine, but when I try to run it with java -jar path_to.jar I
>> >> get this error:
>> >> Error: A JNI error has occurred, please check your installation and
>> >> try again Exception in thread "main" java.lang.SecurityException:
>> >> Invalid signature file digest for Manifest main attributes
>> >>
>> >> The only suggestions I found online applied when people repackaged
>> jars, which is not my case.
>> >> Any suggestion?
>> >>
>> >> Thanks
>> >>
>> >> Rb
>> >
>> >
>> > --
>> > Schalk W. Cronjé
>> > Twitter / Ello / Toeter : @ysb33r
>> >
>>
>> ----------------------------------------------------------------------
>> This email message and any attachments are for the sole use of the
>> intended recipient(s). Any unauthorized review, use, disclosure or
>> distribution is prohibited. If you are not the intended recipient, please
>> contact the sender by reply email and destroy all copies of the original
>> message and any attachments.
>>
>
>
>
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>
>


-- 


David Dawson | CEO | Simplicity Itself

Tel +44 7866 011 256
Skype: davidadawson
david.dawson@simplicityitself.com
http://www.simplicityitself.com

Re: building a jar from groovy script with gradle

Posted by Schalk Cronjé <ys...@gmail.com>.
What's wrong with running a .bat file?

On 08/03/2016 14:30, Gerald Wiltse wrote:
> I have a similar situation I am about to tackle, building an installer 
> that executes Groovy code. This will be going to clients and run on 
> windows, so it really has to be an EXE.
>
> Anybody have good experience with JAR-to-EXE packers or something?
>
> Gerald R. Wiltse
> jerrywiltse@gmail.com <ma...@gmail.com>
>
>
> On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason 
> <Jason.Winnebeck@windstream.com 
> <ma...@windstream.com>> wrote:
>
>     I've "deployed" some scripts to other users in my organization
>     where Java but not Groovy is installed through the GroovyWrapper
>     script. I got it from Codehaus and I can't find the original copy
>     anywhere but I found a fork of it at
>     https://github.com/sdanzan/groovy-wrapper that appears to have
>     more features than the original. The original I have basically
>     just uses the Ant inside of the Groovy distribution to compile a
>     single Groovy file and merge that file, embeddable groovy JAR and
>     some of the Groovy libs into a single jar you can run with java -jar.
>
>     Looking at the code it appears the main difference in that updated
>     script is that it supports adding @Grab'd dependencies into the
>     single JAR, presumably to prevent users from having to download them.
>
>     Jason
>
>     -----Original Message-----
>     From: Jim Northrop [mailto:james.b.northrop@googlemail.com
>     <ma...@googlemail.com>]
>     Sent: Tuesday, March 08, 2016 8:19 AM
>     To: users@groovy.apache.org <ma...@groovy.apache.org>
>     Subject: Re: building a jar from groovy script with gradle
>
>     Out of interest, what is the typical deployment strategy for a
>     runnable Groovy class w/main method? I have been trying to make a
>     user executable jar but as 2 diff.jars. One jar is only my code,
>     no support jars and 2nd is mystuff-all-v1.0.jar as a bundle w/all
>     dependency jars included hence runnable. End user can choose jar.
>
>      Are there other strategies to package code 4 deployment?
>     Thx.
>
>     Sent from my iPad
>
>     > On 8 Mar 2016, at 11:45, Schalk Cronjé <ysb33r@gmail.com
>     <ma...@gmail.com>> wrote:
>     >
>     > I can spot a number of issues in your Gradle script, howver I
>     need to understand context.
>     >
>     > [1] Are you trying to put a single Groovy script + required
>     Groovy JARs into a JAR?
>     >
>     > OR
>     >
>     > [2] Are you trying to build a proper Groovy application
>     consisting of a coouple of class files en dependent JARs?
>     >
>     >> On 08/03/2016 10:33, Raphael Bauduin wrote:
>     >>
>     >> Hi,
>     >>
>     >> I'm trying to package a groovy script as a jar with the help of
>     >> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
>     >>
>     >> it builds fine, but when I try to run it with java -jar
>     path_to.jar I
>     >> get this error:
>     >> Error: A JNI error has occurred, please check your installation and
>     >> try again Exception in thread "main" java.lang.SecurityException:
>     >> Invalid signature file digest for Manifest main attributes
>     >>
>     >> The only suggestions I found online applied when people
>     repackaged jars, which is not my case.
>     >> Any suggestion?
>     >>
>     >> Thanks
>     >>
>     >> Rb
>     >
>     >
>     > --
>     > Schalk W. Cronjé
>     > Twitter / Ello / Toeter : @ysb33r
>     >
>
>     ----------------------------------------------------------------------
>     This email message and any attachments are for the sole use of the
>     intended recipient(s). Any unauthorized review, use, disclosure or
>     distribution is prohibited. If you are not the intended recipient,
>     please contact the sender by reply email and destroy all copies of
>     the original message and any attachments.
>
>


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r


Re: building a jar from groovy script with gradle

Posted by Gerald Wiltse <je...@gmail.com>.
I have a similar situation I am about to tackle, building an installer that
executes Groovy code. This will be going to clients and run on windows, so
it really has to be an EXE.

Anybody have good experience with JAR-to-EXE packers or something?

Gerald R. Wiltse
jerrywiltse@gmail.com


On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason <
Jason.Winnebeck@windstream.com> wrote:

> I've "deployed" some scripts to other users in my organization where Java
> but not Groovy is installed through the GroovyWrapper script. I got it from
> Codehaus and I can't find the original copy anywhere but I found a fork of
> it at https://github.com/sdanzan/groovy-wrapper that appears to have more
> features than the original. The original I have basically just uses the Ant
> inside of the Groovy distribution to compile a single Groovy file and merge
> that file, embeddable groovy JAR and some of the Groovy libs into a single
> jar you can run with java -jar.
>
> Looking at the code it appears the main difference in that updated script
> is that it supports adding @Grab'd dependencies into the single JAR,
> presumably to prevent users from having to download them.
>
> Jason
>
> -----Original Message-----
> From: Jim Northrop [mailto:james.b.northrop@googlemail.com]
> Sent: Tuesday, March 08, 2016 8:19 AM
> To: users@groovy.apache.org
> Subject: Re: building a jar from groovy script with gradle
>
> Out of interest, what is the typical deployment strategy for a runnable
> Groovy class w/main method? I have been trying to make a user executable
> jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is
> mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence
> runnable. End user can choose jar.
>
>  Are there other strategies to package code 4 deployment?
> Thx.
>
> Sent from my iPad
>
> > On 8 Mar 2016, at 11:45, Schalk Cronjé <ys...@gmail.com> wrote:
> >
> > I can spot a number of issues in your Gradle script, howver I need to
> understand context.
> >
> > [1] Are you trying to put a single Groovy script + required Groovy JARs
> into a JAR?
> >
> > OR
> >
> > [2] Are you trying to build a proper Groovy application consisting of a
> coouple of class files en dependent JARs?
> >
> >> On 08/03/2016 10:33, Raphael Bauduin wrote:
> >>
> >> Hi,
> >>
> >> I'm trying to package a groovy script as a jar with the help of
> >> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
> >>
> >> it builds fine, but when I try to run it with java -jar path_to.jar I
> >> get this error:
> >> Error: A JNI error has occurred, please check your installation and
> >> try again Exception in thread "main" java.lang.SecurityException:
> >> Invalid signature file digest for Manifest main attributes
> >>
> >> The only suggestions I found online applied when people repackaged
> jars, which is not my case.
> >> Any suggestion?
> >>
> >> Thanks
> >>
> >> Rb
> >
> >
> > --
> > Schalk W. Cronjé
> > Twitter / Ello / Toeter : @ysb33r
> >
>
> ----------------------------------------------------------------------
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>

RE: building a jar from groovy script with gradle

Posted by "Winnebeck, Jason" <Ja...@windstream.com>.
I've "deployed" some scripts to other users in my organization where Java but not Groovy is installed through the GroovyWrapper script. I got it from Codehaus and I can't find the original copy anywhere but I found a fork of it at https://github.com/sdanzan/groovy-wrapper that appears to have more features than the original. The original I have basically just uses the Ant inside of the Groovy distribution to compile a single Groovy file and merge that file, embeddable groovy JAR and some of the Groovy libs into a single jar you can run with java -jar.

Looking at the code it appears the main difference in that updated script is that it supports adding @Grab'd dependencies into the single JAR, presumably to prevent users from having to download them.

Jason

-----Original Message-----
From: Jim Northrop [mailto:james.b.northrop@googlemail.com] 
Sent: Tuesday, March 08, 2016 8:19 AM
To: users@groovy.apache.org
Subject: Re: building a jar from groovy script with gradle

Out of interest, what is the typical deployment strategy for a runnable Groovy class w/main method? I have been trying to make a user executable jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence runnable. End user can choose jar. 

 Are there other strategies to package code 4 deployment? 
Thx.

Sent from my iPad

> On 8 Mar 2016, at 11:45, Schalk Cronjé <ys...@gmail.com> wrote:
> 
> I can spot a number of issues in your Gradle script, howver I need to understand context.
> 
> [1] Are you trying to put a single Groovy script + required Groovy JARs into a JAR?
> 
> OR
> 
> [2] Are you trying to build a proper Groovy application consisting of a coouple of class files en dependent JARs?
> 
>> On 08/03/2016 10:33, Raphael Bauduin wrote:
>> 
>> Hi,
>> 
>> I'm trying to package a groovy script as a jar with the help of 
>> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
>> 
>> it builds fine, but when I try to run it with java -jar path_to.jar I 
>> get this error:
>> Error: A JNI error has occurred, please check your installation and 
>> try again Exception in thread "main" java.lang.SecurityException: 
>> Invalid signature file digest for Manifest main attributes
>> 
>> The only suggestions I found online applied when people repackaged jars, which is not my case.
>> Any suggestion?
>> 
>> Thanks
>> 
>> Rb
> 
> 
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
> 

----------------------------------------------------------------------
This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.

Re: building a jar from groovy script with gradle

Posted by Jim Northrop <ja...@googlemail.com>.
Out of interest, what is the typical deployment strategy for a runnable Groovy class w/main method? I have been trying to make a user executable jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence runnable. End user can choose jar. 

 Are there other strategies to package code 4 deployment? 
Thx.

Sent from my iPad

> On 8 Mar 2016, at 11:45, Schalk Cronjé <ys...@gmail.com> wrote:
> 
> I can spot a number of issues in your Gradle script, howver I need to understand context.
> 
> [1] Are you trying to put a single Groovy script + required Groovy JARs into a JAR?
> 
> OR
> 
> [2] Are you trying to build a proper Groovy application consisting of a coouple of class files en dependent JARs?
> 
>> On 08/03/2016 10:33, Raphael Bauduin wrote:
>> 
>> Hi,
>> 
>> I'm trying to package a groovy script as a jar with the help of gradle,
>> I use this gradle config: http://pastebin.com/RFEhzMCp
>> 
>> it builds fine, but when I try to run it with java -jar path_to.jar
>> I get this error:
>> Error: A JNI error has occurred, please check your installation and try again
>> Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
>> 
>> The only suggestions I found online applied when people repackaged jars, which is not my case.
>> Any suggestion?
>> 
>> Thanks
>> 
>> Rb
> 
> 
> -- 
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
> 

Re: building a jar from groovy script with gradle

Posted by Schalk Cronjé <ys...@gmail.com>.
I can spot a number of issues in your Gradle script, howver I need to 
understand context.

[1] Are you trying to put a single Groovy script + required Groovy JARs 
into a JAR?

OR

[2] Are you trying to build a proper Groovy application consisting of a 
coouple of class files en dependent JARs?

On 08/03/2016 10:33, Raphael Bauduin wrote:
>
> Hi,
>
> I'm trying to package a groovy script as a jar with the help of gradle,
> I use this gradle config: http://pastebin.com/RFEhzMCp
>
> it builds fine, but when I try to run it with java -jar path_to.jar
> I get this error:
> Error: A JNI error has occurred, please check your installation and 
> try again
> Exception in thread "main" java.lang.SecurityException: Invalid 
> signature file digest for Manifest main attributes
>
> The only suggestions I found online applied when people repackaged 
> jars, which is not my case.
> Any suggestion?
>
> Thanks
>
> Rb


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r