Hi,
If you can, avoid using classifiers here and actually publish as individual
artifacts (classifiers can be problematic in builds).
Here's how you could do it…
def components = [
[name: "foo"],
[name: "bar"],
[name: "baz"]
]
components.each { comp ->
project.task(comp.name, type: Jar)
}
You then need to assign these artifacts to a configuration (the convention is
to use the “archives” configuration)…
artfiacts {
components.each { archives(tasks[it.name]) }
}
Then you need to declare that these jars are published individually…
uploadArchives {
repositories.mavenDeployer {
repository(url: "file://localhost/tmp/myRepo/")
components.each { component ->
addFilter(component.name) { artifact, file -> artifact.name ==
component.name }
}
}
}
--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com
Please vote Gradle for JAX Awards » http://vote.jax-awards.com
On 17/06/2011, at 6:52 AM, Eric Berry wrote:
> You should probably look at the maven plugin:
> http://www.gradle.org/maven_plugin.html
>
> As for the multiple artifacts, it would probably be easiest to just assign
> different classifiers for them - similar to uploading source and javadoc jars:
> http://gradle.1045684.n5.nabble.com/javadoc-and-source-jars-td3246213.html
>
>
> On Thu, Jun 16, 2011 at 1:45 PM, Mark Davidson <[email protected]> wrote:
> This approach works great.
>
> My next question is - how can I deploy the generated jars to a repository?
> I've read up about addFilter() but can't figure out how to use this to upload
> the jars with same groupId and unique artifactId (e.g. "$prefix.$jarname").
> Any ideas?
>
> Regards
>
> Mark
>
> On 15 June 2011 19:19, Eric Berry <[email protected]> wrote:
> You should be able to do this. You don't even need the extra task really,
> unless you want just one task to run.
>
> You can set this up similar to below in the config phase:
> [code]
> def components = [
> [name: "foo"],
> [name: "bar"],
> [name: "baz"]
> ]
>
> components.each { comp ->
> project.task(comp.name, type: Jar) {
> }
> }
> [/code]
>
> If you run 'gradle tasks' you'll see 3 new tasks 'foo', 'bar', and 'baz'.
>
> You could go further and add each of these tasks to the artifacts closure so
> that the jars will be produced when you build the project.
>
>
>
>
> On Wed, Jun 15, 2011 at 4:26 AM, Mark Davidson <[email protected]> wrote:
> Hi there
>
> I have a project that I want to package as a large number of jars (~30). I've
> seen a solution on the mailing list that looks like this:
>
> jar {
> include 'com/mycompany/package1/**'
> }
>
> task otherJar(type: Jar) {
> from sourceSets.main.classes
> include 'com/mycompany/package2/**'
> // you will need something to distinguish this jar from the other,
> one of:
> // baseName = 'myotherjar'
> // classifier = 'someclassifier'
> // customName = 'myotherjar.jar'
> }
>
> I accept that this would work for me however I was hoping to do something
> like this to reduce the amount jar-type tasks:
>
> def components = [
> [name: 'validate-metadata', title: 'Validate Metadata Component',
> pattern: 'com/mycompany/package1/**']
> [name: 'generate-pdf', title: 'Generate PDF Component', pattern:
> 'com/mycompany/package2/**']
> [name: 'approve-package', title: 'Approve Package Component', pattern:
> 'com/mycompany/package3/**']
> etc..
> ]
>
> task createComponents {
> components.each { c ->
> // call some jar-type task..
> }
> }
>
> Is this possible? Would I have to use AntBuilder to do this?
>
> Cheers
>
> Mark
>
>
>
> --
> Learn from the past. Live in the present. Plan for the future.
> Blog: http://eric-berry.blogspot.com
> jEdit <http://www.jedit.org> - Programmer's Text Editor
> Bazaar <http://bazaar.canonical.com> - Version Control for Humans
>
>
>
>
> --
> Learn from the past. Live in the present. Plan for the future.
> Blog: http://eric-berry.blogspot.com
> jEdit <http://www.jedit.org> - Programmer's Text Editor
> Bazaar <http://bazaar.canonical.com> - Version Control for Humans