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é <[email protected] <mailto:[email protected]>> 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

Reply via email to