You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by pa...@ubs.com on 2007/03/14 11:40:30 UTC

Maven2 Artifact Packaging

Hello, 

My question concerns packaging of Maven2 projects. Is it possible to
"double"-package (e.g. as a "jar" and a "war") a Maven2 project? The
reason why I want to do this is because my war project contains classes
that are references by another reactor project. I need to package my
"war" project as a war for deployment and at the same time as a "jar"
for usage as a simple lib dependency.

Thanks for your help
cheers
pawel

Re: RE: Maven2 Artifact Packaging

Posted by Thorsten Heit <th...@gmx.de>.
Hi,

> The problem with this solution (separate the war project into a classes
> and a webapp part) is that the IDEs and a Testserver will not be able to see
> the project as a whole --> you'll just have a dependency on the jar as a
> library and will not be able to reload the classes when working on a running
> server.

Indeed. I have similar problems using Eclipse with such a project. My workaround is to just copy the .classpath file from my jar subproject one level above so that at least Eclipse is able to compile the code without having to create separate projects for the jar and war...


> I was wondering whether it's possible to specify packaging as
> <packaging>jar,war</packaging> but this doesn't work. Would it be possible to change
> the build-lifecycle, so that it produces two packages? 

How about filing an enhancement request in Jira?


Regards

Thorsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Maven2 Artifact Packaging

Posted by pa...@ubs.com.
Hi Thorsten, 

The problem with this solution (separate the war project into a classes and a webapp part) is that the IDEs and a Testserver will not be able to see the project as a whole --> you'll just have a dependency on the jar as a library and will not be able to reload the classes when working on a running server.

I was wondering whether it's possible to specify packaging as <packaging>jar,war</packaging> but this doesn't work. Would it be possible to change the build-lifecycle, so that it produces two packages? 

cheers
pawel


-----Original Message-----
From: Thorsten Heit [mailto:theit@gmx.de] 
Sent: Mittwoch, 14. März 2007 12:03
To: Maven Users List
Subject: Re: Maven2 Artifact Packaging

Hi Pawel,

> My question concerns packaging of Maven2 projects. Is it possible to
> "double"-package (e.g. as a "jar" and a "war") a Maven2 project? The
> reason why I want to do this is because my war project contains classes
> that are references by another reactor project. I need to package my
> "war" project as a war for deployment and at the same time as a "jar"
> for usage as a simple lib dependency.

What about the following:

Create a master pom.xml with packaging==pom and add the following:

<modules>
  <module>module-jar</module>
  <module>module-war</module>
</modules>


Copy your original pom.xml into ./module-jar, but change it to be of type packaging==jar and remove the stuff that belongs to creating the WAR, i.e. let it just create a plain Jar file.

The in ./module-war place a new pom.xml, type packaging==war, add a dependency to module-jar and everything else you need to build your WAR. Then when you execute "mvn package" in the top-level directory Maven should create both a Jar and a WAR for you.


HTH

Thorsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven2 Artifact Packaging

Posted by Thorsten Heit <th...@gmx.de>.
Hi Pawel,

> My question concerns packaging of Maven2 projects. Is it possible to
> "double"-package (e.g. as a "jar" and a "war") a Maven2 project? The
> reason why I want to do this is because my war project contains classes
> that are references by another reactor project. I need to package my
> "war" project as a war for deployment and at the same time as a "jar"
> for usage as a simple lib dependency.

What about the following:

Create a master pom.xml with packaging==pom and add the following:

<modules>
  <module>module-jar</module>
  <module>module-war</module>
</modules>


Copy your original pom.xml into ./module-jar, but change it to be of type packaging==jar and remove the stuff that belongs to creating the WAR, i.e. let it just create a plain Jar file.

The in ./module-war place a new pom.xml, type packaging==war, add a dependency to module-jar and everything else you need to build your WAR. Then when you execute "mvn package" in the top-level directory Maven should create both a Jar and a WAR for you.


HTH

Thorsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org