Maven install dist not jar

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Maven install dist not jar

Mike Mills
I have a project that creates a zip of our product as well as a jar.

Currently I am using the maven plugin to install the jar into my local repo.

Is there a way to install the zip into the local repo?

Specifically the zip has no external dependencies, so the installed
pom should also have no dependencies listed.

I am at a loss on how to configure this....


-Mike




Some Background info:

This is part of a larger process involving two separate projects.

Currently Project A creates a zip package, Project B unpacks that zip
and executes it and runs tests against that running instance.

So I am trying to get the zip from project A into a place that project
B can use it.

As these projects are currently separate (and project A is multi
module) I can not conveniently create the appropriate convenient
Gradle dependencies.

The projects are Ant builds, and maven-ant-tasks to do the install
from project A / resolve in project B.

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Maven install dist not jar

jkfrench
Mike, did you figure this out? I'm trying to do the same thing.

     Jeff

Mike Mills wrote
I have a project that creates a zip of our product as well as a jar.

Currently I am using the maven plugin to install the jar into my local repo.

Is there a way to install the zip into the local repo?

Specifically the zip has no external dependencies, so the installed
pom should also have no dependencies listed.

I am at a loss on how to configure this....
Reply | Threaded
Open this post in threaded view
|

Re: Maven install dist not jar

Mike Mills
Jeff,

I did find a solution that was acceptable. Using the maven and
application plugins, you can deploy the zip created by the distZip
task. But you also need to remove the transitive dependencies so that
anything that pulls in the zip will not also pull in everything else.
Remember the aim here to package everything inside the zip as a
complete application, so you do not have other dependencies.

So referencing the example below:

First you need to configure maven to deploy the distZip, do this by
using the "artifacts" closure.
To remove the transitive dependencies (or you could also add a new
set), use the "pom*.whenConfigured" closure. In the example below I
have just remove all other dependencies.

Issues:
There seems to be no way to remove the jar artifact configuration
created by the application plugin. The api only seems to allow you to
add dependencies, and the application plugin has no switch to not
create the jar configuration.

This means that when you install your application into your maven
repo, you will still get a jar added as well. If anyone has a solution
here I would like to know.

To reference the zip in another gradle project use the parameter "ext:
'zip'" when trying to retrieve the application from you maven
repository. By default it will look for the jar, which as you cant
prevent it from being installed/deployed, it will be found and give
you strange results.

The only other trick I have used with the application plugin is to
create a copy spec closure for use by the distZip and installApp
tasks. I think it would be nice if the application plugin had this in
the ApplicationPluginConvention because I think in almost all cases
the installed app and dist would use the same copy spec.

Hope this helps,

-Mike




apply plugin: "maven"
apply plugin: "application"

mainClassName = "<fully qualified main class>"

distCopySpec = {
  from jar.outputs.files
  from 'src/main/scripts'
  into('lib') {
    from configurations.runtime
  }
  .. other copy spec statements
}

installApp distCopySpec
distZip distCopySpec


artifacts {
    archives distZip
}

def installer = install.repositories.mavenInstaller

[installer]*.pom*.whenConfigured {pom ->
  // This is to wipe any dependencies, everything is packaged in this
zip anyway!
  pom.dependencies.clear()
}


run {
  def args = []
  args << "-Xdebug"
  args << "-Xnoagent"
  args << "-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
  jvmArgs(args)

  systemProperty 'file.encoding', 'UTF8'
}




On Sat, Sep 3, 2011 at 4:07 AM, jkfrench <[hidden email]> wrote:

> Mike, did you figure this out? I'm trying to do the same thing.
>
>     Jeff
>
>
> Mike Mills wrote:
>>
>> I have a project that creates a zip of our product as well as a jar.
>>
>> Currently I am using the maven plugin to install the jar into my local
>> repo.
>>
>> Is there a way to install the zip into the local repo?
>>
>> Specifically the zip has no external dependencies, so the installed
>> pom should also have no dependencies listed.
>>
>> I am at a loss on how to configure this....
>>
>
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Maven-install-dist-not-jar-tp4726649p4763344.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Maven install dist not jar

Luke Daley-2

On 04/09/2011, at 8:48 AM, Mike Mills wrote:

> Issues:
> There seems to be no way to remove the jar artifact configuration
> created by the application plugin. The api only seems to allow you to
> add dependencies, and the application plugin has no switch to not
> create the jar configuration.

You could remove the jar artifact with:

configurations.archives.with { archives ->
        def jarArtifact = archives.artifacts.find { it.class.simpleName == "ArchivePublishArtifact" && it.archiveTask == jar }
        archives.removeArtifact(jarArtifact)
}

Note that removeArtifact was deprecated in m4, so from m4 on you should use…

configurations.archives.artifacts.with { archives ->
        def jarArtifact = find { it.class.simpleName == "ArchivePublishArtifact" && it.archiveTask == jar }
        remove(jarArtifact)
}

--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com


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

    http://xircles.codehaus.org/manage_email