Quantcast

Creating multiple jars

classic Classic list List threaded Threaded
8 messages Options
tog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Creating multiple jars

tog
Hi folks,

In my project I would like to create multiple jars:
  - one containing only the classes of my project (classic targer)
  - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
    for(file in configurations.compile) {
        jar.merge(file)
    }
}

What is the best way to achieve this ?
Clone the jar task ?

Do something like a :
jar.doLast{
    jar.copy(jar-minimal.jar)
    for(file in configurations.compile) {
        jar.merge(file)
    }
}

Thanks for your help

Guillaume

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

Adam Murdoch-2


tog wrote:

> Hi folks,
>
> In my project I would like to create multiple jars:
>   - one containing only the classes of my project (classic targer)
>   - a second one containing all dependencies,
>
> In the cookbook, it is said that I can do this:
>
> jar.doFirst {
>     for(file in configurations.compile) {
>         jar.merge(file)
>     }
> }
>
> What is the best way to achieve this ?
>  

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
    dependsOn classes
    from sourceSet.main.classesDir
    classifier = 'all'  // Give the jar a different name
    doFirst { task->
        for(file in configurations.compile) {
            task.merge(file)
        }
    }
}


> Clone the jar task ?
>
> Do something like a :
> jar.doLast{
>     jar.copy(jar-minimal.jar)
>     for(file in configurations.compile) {
>         jar.merge(file)
>     }
> }
>
> Thanks for your help
>
> Guillaume
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>  

--
Adam Murdoch
Gradle Developer
http://www.gradle.org


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

    http://xircles.codehaus.org/manage_email


tog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

tog
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?
 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?



On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com
tog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

tog
Could someone point me to the code of the merge task ?

Thanks
Guillaume

On Wed, Nov 25, 2009 at 9:50 PM, tog <[hidden email]> wrote:
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?
 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?




On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com



--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

hans_d
Administrator

On Nov 29, 2009, at 10:13 AM, tog wrote:

Could someone point me to the code of the merge task ?

Which version of Gradle are you using?


Thanks
Guillaume

On Wed, Nov 25, 2009 at 9:50 PM, tog <[hidden email]> wrote:
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?
 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?

To the Maven or the Codehaus repository?

- Hans

--
Hans Dockter
Gradle Project Manager





On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com



--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com

tog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

tog
Hi Hans


Which version of Gradle are you using?

I am using the 0.8 version (but won't mind using an other one)

Thanks
Guillaume

On Wed, Nov 25, 2009 at 9:50 PM, tog <[hidden email]> wrote:
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?
 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?

Currently, I am having problem using the merge task. Merging several jars having the same META-INF/LICENCE file ends up with a jar that cannot be signed. I would like to solve this.

To the Codehaus repos. My regular jar is upload so the question is how to add the newly created jar (by the other task) to the "list" of jar to be uploaded

Guillaume
 
To the Maven or the Codehaus repository?

- Hans

--
Hans Dockter
Gradle Project Manager





On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com



--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com




--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

hans_d
Administrator
In reply to this post by tog

On Nov 29, 2009, at 10:13 AM, tog wrote:

Could someone point me to the code of the merge task ?

Thanks
Guillaume

On Wed, Nov 25, 2009 at 9:50 PM, tog <[hidden email]> wrote:
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?

Adam, do you know how to do that?

 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?

You just say:

artifacts {
    archives additional_jar_with_classifier_task
}

- Hans

--
Hans Dockter
Gradle Project Manager






On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com



--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating multiple jars

Adam Murdoch-2


Hans Dockter wrote:

On Nov 29, 2009, at 10:13 AM, tog wrote:

Could someone point me to the code of the merge task ?

Thanks
Guillaume

On Wed, Nov 25, 2009 at 9:50 PM, tog <[hidden email]> wrote:
Thanks Adam, 2 more questions:

 - Is there a way to merge a signed jar - I would need either to remove the signatures or recompute them ?

Adam, do you know how to do that?

To remove them, you would exclude them when merging, something like:

jar {
    from zipTree('some-file.jar).matching { exclude 'META-INF/**',  }
}

To recompute them, you would need to use the signjar Ant task, or jarsigner command line tool. I've added a JIRA issue for Gradle to better support signed jars: http://jira.codehaus.org/browse/GRADLE-769


 - How can I have this jar (with the modified classifier) uploaded together with the "regular" one ?

You just say:

artifacts {
    archives additional_jar_with_classifier_task
}

- Hans

--
Hans Dockter
Gradle Project Manager






On Tue, Nov 24, 2009 at 4:08 AM, Adam Murdoch <[hidden email]> wrote:


tog wrote:
Hi folks,

In my project I would like to create multiple jars:
 - one containing only the classes of my project (classic targer)
 - a second one containing all dependencies,

In the cookbook, it is said that I can do this:

jar.doFirst {
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

What is the best way to achieve this ?
 

You can add another jar task to build the fat jar:

task fatJar(type: Jar) {
  dependsOn classes
  from sourceSet.main.classesDir
  classifier = 'all'  // Give the jar a different name
  doFirst { task->

      for(file in configurations.compile) {
          task.merge(file)
      }
  }
}


Clone the jar task ?

Do something like a :
jar.doLast{
   jar.copy(jar-minimal.jar)
   for(file in configurations.compile) {
       jar.merge(file)
   }
}

Thanks for your help

Guillaume

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

   http://xircles.codehaus.org/manage_email


 

--
Adam Murdoch
Gradle Developer
http://www.gradle.org



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

  http://xircles.codehaus.org/manage_email





--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com



--
PGP KeyID: 1024D/69B00854  subkeys.pgp.net

http://cheztog.blogspot.com


-- 
Adam Murdoch
Gradle Developer
http://www.gradle.org
Loading...