You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Narayanan K <kn...@gmail.com> on 2014/04/22 02:18:51 UTC

Generating war and Jar from same codebase

Hi

We have a default pom file with packaging "war" for our codebase.

>From the same code base we also want to generate a normal jar and a
fat jar with dependencies.

Currently solution that has been implemented is another pom-jar.xml
file that has the packaging as jar and maven-assembly-plugin to
generate the jar with dependencies. We use mvn install -f pom-jar.xml.

But we are in a situation where if any new dependency is added to
pom.xml, we need to add to pom-jar.xml as well as it is the same
codebase.

To avoid this we thought of couple of solutions -

1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
with packaging war - so it generates a war file, a normal jar file and
fat jar out of the same pom. So we can do away with the pom-jar.xml.

Not sure if this is a good solution. We tried this, but this is
working well only in maven 3.0.4. The assembly plugin is not working
well with Maven 2 (which is in our build environment) while generating
the fat jar.

2. Have a parent pom and put all the dependencies and plugins in that
and have 2 child poms in the same codebase with different names
inherit from parent pom, one that has packaging of war that generates
war file and the other child pom has packaging jar with maven assembly
plugin to generate both normal and fat jar. And all new dependencies
need to be added only to parent pom.

This solution will make us have 3 pom files in codebase, doesnt look
very elegant, but will solve our dependency management issues between
the 2 packaging.


Are these good solutions? Is there any other good solution available
for this scenario ?


Regards
Narayanan

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


Re: Generating war and Jar from same codebase

Posted by Anders Hammar <an...@hammar.net>.
#2 is the "Maven way" in a structural sense, although you shouldn't put all
dependencies in the parent but where they are used. So the jar project will
get most of the deps and the war project will have a dependency to the jar
artifact (and possibly some other web related deps).
Also, as the jar project already produces a jar artifact as the main
artifact, you only need to add the m-assembly-p to produce the secondary
"fat jar" artifact.

/Anders


On Tue, Apr 22, 2014 at 2:18 AM, Narayanan K <kn...@gmail.com> wrote:

> Hi
>
> We have a default pom file with packaging "war" for our codebase.
>
> From the same code base we also want to generate a normal jar and a
> fat jar with dependencies.
>
> Currently solution that has been implemented is another pom-jar.xml
> file that has the packaging as jar and maven-assembly-plugin to
> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>
> But we are in a situation where if any new dependency is added to
> pom.xml, we need to add to pom-jar.xml as well as it is the same
> codebase.
>
> To avoid this we thought of couple of solutions -
>
> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
> with packaging war - so it generates a war file, a normal jar file and
> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>
> Not sure if this is a good solution. We tried this, but this is
> working well only in maven 3.0.4. The assembly plugin is not working
> well with Maven 2 (which is in our build environment) while generating
> the fat jar.
>
> 2. Have a parent pom and put all the dependencies and plugins in that
> and have 2 child poms in the same codebase with different names
> inherit from parent pom, one that has packaging of war that generates
> war file and the other child pom has packaging jar with maven assembly
> plugin to generate both normal and fat jar. And all new dependencies
> need to be added only to parent pom.
>
> This solution will make us have 3 pom files in codebase, doesnt look
> very elegant, but will solve our dependency management issues between
> the 2 packaging.
>
>
> Are these good solutions? Is there any other good solution available
> for this scenario ?
>
>
> Regards
> Narayanan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Generating war and Jar from same codebase

Posted by Ron Wheeler <rw...@artifact-software.com>.
If you are going to get serious about development, you should install a 
Maven repo.
We use the Community version of Nexus and it works very well.

What are the restrictions on your development?
Almost every other company that uses Maven works as Anders suggests.

Ron

On 23/04/2014 12:15 AM, Narayanan K wrote:
> Hi Anders
>
> The codebase is the same. So having 2 separate directories (for
> modules) and pom in each of them is not required right ?
>
> I can have <modules> in parent pom to specify the 2 child poms that
> are present in the same project level. Tried below and seems it is
> working.
>
> parent pom will have :
>
> <modules>
>    <module>pom-war.xml</module>
>    <module>pom-jar.xml</module>
> <modules>
>
> In both child poms,
>
> <parent>
> <relativePath>./pom-parent.xml</relativePath>
> </parent>
>
> Currently including the jar artifact dependency in war project cannot
> be done due to some restrictions in our development.
>
> Narayanan
>
> On Tue, Apr 22, 2014 at 11:37 AM, Anders Hammar <an...@hammar.net> wrote:
>>> My new maven project structure will be :
>>>
>>> .
>>>   | -- pom.xml (parent pom)
>>>   | -- pom-war.xml (inherits from parent, generates a war)
>>>   | -- pom-jar.xml (inherits from parent, generates a jar)
>>>
>>> There are no modules in the project. All poms are going to be in the
>>> root path of the project.
>>>
>> Wrong!
>> You should create two modules; one for the jar project and one for the war
>> project. Follow the Maven standards and you can use any of the many
>> examples of this on the Internet.
>> I believe we haven't pushed the mantra for some time now, so here it comes:
>> Don't fight Maven!
>>
>> /Anders
>>
>>
>>> 1. Any examples on how to write the parent pom referencing the same
>>> codebase for the child poms.
>>> Will there be a <module> tag for parent pom.  I understand that the
>>> packaging for parent pom will be "pom".
>>>
>>> 2. The child poms will have <relativePath> in <parent> tag as
>>> ./pom.xml. Please correct me if this is wrong.
>>>
>>> Thanks
>>> Narayanan
>>>
>>>
>>>
>>>
>>>
>>> Narayanan
>>>
>>> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
>>> <st...@gmail.com> wrote:
>>>> On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> We have a default pom file with packaging "war" for our codebase.
>>>>>
>>>>>  From the same code base we also want to generate a normal jar and a
>>>>> fat jar with dependencies.
>>>>>
>>>>> Currently solution that has been implemented is another pom-jar.xml
>>>>> file that has the packaging as jar and maven-assembly-plugin to
>>>>> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>>>>>
>>>>> But we are in a situation where if any new dependency is added to
>>>>> pom.xml, we need to add to pom-jar.xml as well as it is the same
>>>>> codebase.
>>>>>
>>>>> To avoid this we thought of couple of solutions -
>>>>>
>>>>> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>>>>> with packaging war - so it generates a war file, a normal jar file and
>>>>> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>>>>>
>>>>> Not sure if this is a good solution. We tried this, but this is
>>>>> working well only in maven 3.0.4. The assembly plugin is not working
>>>>> well with Maven 2 (which is in our build environment) while generating
>>>>> the fat jar.
>>>>>
>>>>> 2. Have a parent pom and put all the dependencies and plugins in that
>>>>> and have 2 child poms in the same codebase with different names
>>>>> inherit from parent pom, one that has packaging of war that generates
>>>>> war file and the other child pom has packaging jar with maven assembly
>>>>> plugin to generate both normal and fat jar. And all new dependencies
>>>>> need to be added only to parent pom.
>>>>>
>>>>> This solution will make us have 3 pom files in codebase, doesnt look
>>>>> very elegant,
>>>>
>>>> actually depends on your point of view. To me this is the more elegant
>>>> solution as you clearly see the relationship between inputs (pom.xml) and
>>>> outputs (artifacts, e.g. jars wars, etc)
>>>>
>>>>
>>>>> but will solve our dependency management issues between
>>>>> the 2 packaging.
>>>>>
>>>>>
>>>>> Are these good solutions? Is there any other good solution available
>>>>> for this scenario ?
>>>>>
>>>>>
>>>>> Regards
>>>>> Narayanan
>>>>>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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


Re: Generating war and Jar from same codebase

Posted by Ron Wheeler <rw...@artifact-software.com>.
https://www.youtube.com/watch?v=WZEJ4OJTgg8 Resistance is futile
https://www.youtube.com/watch?v=CuSDiQhZFgM Resistance is useless

On 23/04/2014 5:01 AM, Stephen Connolly wrote:
> Please do no do it this way. You will have a very sub-optimal Maven
> experience if you do it this way. In short you are picking a fight with
> Maven... you might have won a battle... but Maven is very opinionated and
> when you pick a fight with it... expect a phone call from Maven...
>
> "I don't know who you are. I don't know what you want. If you are looking
> for ransom, I can tell you I don't have money. But what I do have are a
> very particular set of opinions; opinions I have acquired over a decade of
> existence. Opinions that make me a nightmare for people like you. If you
> follow the Maven way now, that'll be the end of it. I will not look for
> you, I will not pursue you. But if you don't, I will look for you, I will
> find you, and I will kill you." https://www.youtube.com/watch?v=OxBH05hcifw
>
> Maven always wins in the end!
>
>
>
>
> On 23 April 2014 05:15, Narayanan K <kn...@gmail.com> wrote:
>
>> Hi Anders
>>
>> The codebase is the same. So having 2 separate directories (for
>> modules) and pom in each of them is not required right ?
>>
>> I can have <modules> in parent pom to specify the 2 child poms that
>> are present in the same project level. Tried below and seems it is
>> working.
>>
>> parent pom will have :
>>
>> <modules>
>>    <module>pom-war.xml</module>
>>    <module>pom-jar.xml</module>
>> <modules>
>>
>> In both child poms,
>>
>> <parent>
>> <relativePath>./pom-parent.xml</relativePath>
>> </parent>
>>
>> Currently including the jar artifact dependency in war project cannot
>> be done due to some restrictions in our development.
>>
>> Narayanan
>>
>> On Tue, Apr 22, 2014 at 11:37 AM, Anders Hammar <an...@hammar.net> wrote:
>>>> My new maven project structure will be :
>>>>
>>>> .
>>>>   | -- pom.xml (parent pom)
>>>>   | -- pom-war.xml (inherits from parent, generates a war)
>>>>   | -- pom-jar.xml (inherits from parent, generates a jar)
>>>>
>>>> There are no modules in the project. All poms are going to be in the
>>>> root path of the project.
>>>>
>>> Wrong!
>>> You should create two modules; one for the jar project and one for the
>> war
>>> project. Follow the Maven standards and you can use any of the many
>>> examples of this on the Internet.
>>> I believe we haven't pushed the mantra for some time now, so here it
>> comes:
>>> Don't fight Maven!
>>>
>>> /Anders
>>>
>>>
>>>> 1. Any examples on how to write the parent pom referencing the same
>>>> codebase for the child poms.
>>>> Will there be a <module> tag for parent pom.  I understand that the
>>>> packaging for parent pom will be "pom".
>>>>
>>>> 2. The child poms will have <relativePath> in <parent> tag as
>>>> ./pom.xml. Please correct me if this is wrong.
>>>>
>>>> Thanks
>>>> Narayanan
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Narayanan
>>>>
>>>> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
>>>> <st...@gmail.com> wrote:
>>>>> On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> We have a default pom file with packaging "war" for our codebase.
>>>>>>
>>>>>>  From the same code base we also want to generate a normal jar and a
>>>>>> fat jar with dependencies.
>>>>>>
>>>>>> Currently solution that has been implemented is another pom-jar.xml
>>>>>> file that has the packaging as jar and maven-assembly-plugin to
>>>>>> generate the jar with dependencies. We use mvn install -f
>> pom-jar.xml.
>>>>>> But we are in a situation where if any new dependency is added to
>>>>>> pom.xml, we need to add to pom-jar.xml as well as it is the same
>>>>>> codebase.
>>>>>>
>>>>>> To avoid this we thought of couple of solutions -
>>>>>>
>>>>>> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>>>>>> with packaging war - so it generates a war file, a normal jar file
>> and
>>>>>> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>>>>>>
>>>>>> Not sure if this is a good solution. We tried this, but this is
>>>>>> working well only in maven 3.0.4. The assembly plugin is not working
>>>>>> well with Maven 2 (which is in our build environment) while
>> generating
>>>>>> the fat jar.
>>>>>>
>>>>>> 2. Have a parent pom and put all the dependencies and plugins in that
>>>>>> and have 2 child poms in the same codebase with different names
>>>>>> inherit from parent pom, one that has packaging of war that generates
>>>>>> war file and the other child pom has packaging jar with maven
>> assembly
>>>>>> plugin to generate both normal and fat jar. And all new dependencies
>>>>>> need to be added only to parent pom.
>>>>>>
>>>>>> This solution will make us have 3 pom files in codebase, doesnt look
>>>>>> very elegant,
>>>>>
>>>>> actually depends on your point of view. To me this is the more elegant
>>>>> solution as you clearly see the relationship between inputs (pom.xml)
>> and
>>>>> outputs (artifacts, e.g. jars wars, etc)
>>>>>
>>>>>
>>>>>> but will solve our dependency management issues between
>>>>>> the 2 packaging.
>>>>>>
>>>>>>
>>>>>> Are these good solutions? Is there any other good solution available
>>>>>> for this scenario ?
>>>>>>
>>>>>>
>>>>>> Regards
>>>>>> Narayanan
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> 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
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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


Re: Generating war and Jar from same codebase

Posted by Stephen Connolly <st...@gmail.com>.
Please do no do it this way. You will have a very sub-optimal Maven
experience if you do it this way. In short you are picking a fight with
Maven... you might have won a battle... but Maven is very opinionated and
when you pick a fight with it... expect a phone call from Maven...

"I don't know who you are. I don't know what you want. If you are looking
for ransom, I can tell you I don't have money. But what I do have are a
very particular set of opinions; opinions I have acquired over a decade of
existence. Opinions that make me a nightmare for people like you. If you
follow the Maven way now, that'll be the end of it. I will not look for
you, I will not pursue you. But if you don't, I will look for you, I will
find you, and I will kill you." https://www.youtube.com/watch?v=OxBH05hcifw

Maven always wins in the end!




On 23 April 2014 05:15, Narayanan K <kn...@gmail.com> wrote:

> Hi Anders
>
> The codebase is the same. So having 2 separate directories (for
> modules) and pom in each of them is not required right ?
>
> I can have <modules> in parent pom to specify the 2 child poms that
> are present in the same project level. Tried below and seems it is
> working.
>
> parent pom will have :
>
> <modules>
>   <module>pom-war.xml</module>
>   <module>pom-jar.xml</module>
> <modules>
>
> In both child poms,
>
> <parent>
> <relativePath>./pom-parent.xml</relativePath>
> </parent>
>
> Currently including the jar artifact dependency in war project cannot
> be done due to some restrictions in our development.
>
> Narayanan
>
> On Tue, Apr 22, 2014 at 11:37 AM, Anders Hammar <an...@hammar.net> wrote:
> >> My new maven project structure will be :
> >>
> >> .
> >>  | -- pom.xml (parent pom)
> >>  | -- pom-war.xml (inherits from parent, generates a war)
> >>  | -- pom-jar.xml (inherits from parent, generates a jar)
> >>
> >> There are no modules in the project. All poms are going to be in the
> >> root path of the project.
> >>
> >
> > Wrong!
> > You should create two modules; one for the jar project and one for the
> war
> > project. Follow the Maven standards and you can use any of the many
> > examples of this on the Internet.
> > I believe we haven't pushed the mantra for some time now, so here it
> comes:
> > Don't fight Maven!
> >
> > /Anders
> >
> >
> >>
> >> 1. Any examples on how to write the parent pom referencing the same
> >> codebase for the child poms.
> >> Will there be a <module> tag for parent pom.  I understand that the
> >> packaging for parent pom will be "pom".
> >>
> >> 2. The child poms will have <relativePath> in <parent> tag as
> >> ./pom.xml. Please correct me if this is wrong.
> >>
> >> Thanks
> >> Narayanan
> >>
> >>
> >>
> >>
> >>
> >> Narayanan
> >>
> >> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
> >> <st...@gmail.com> wrote:
> >> > On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
> >> >
> >> >> Hi
> >> >>
> >> >> We have a default pom file with packaging "war" for our codebase.
> >> >>
> >> >> From the same code base we also want to generate a normal jar and a
> >> >> fat jar with dependencies.
> >> >>
> >> >> Currently solution that has been implemented is another pom-jar.xml
> >> >> file that has the packaging as jar and maven-assembly-plugin to
> >> >> generate the jar with dependencies. We use mvn install -f
> pom-jar.xml.
> >> >>
> >> >> But we are in a situation where if any new dependency is added to
> >> >> pom.xml, we need to add to pom-jar.xml as well as it is the same
> >> >> codebase.
> >> >>
> >> >> To avoid this we thought of couple of solutions -
> >> >>
> >> >> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
> >> >> with packaging war - so it generates a war file, a normal jar file
> and
> >> >> fat jar out of the same pom. So we can do away with the pom-jar.xml.
> >> >>
> >> >> Not sure if this is a good solution. We tried this, but this is
> >> >> working well only in maven 3.0.4. The assembly plugin is not working
> >> >> well with Maven 2 (which is in our build environment) while
> generating
> >> >> the fat jar.
> >> >>
> >> >> 2. Have a parent pom and put all the dependencies and plugins in that
> >> >> and have 2 child poms in the same codebase with different names
> >> >> inherit from parent pom, one that has packaging of war that generates
> >> >> war file and the other child pom has packaging jar with maven
> assembly
> >> >> plugin to generate both normal and fat jar. And all new dependencies
> >> >> need to be added only to parent pom.
> >> >>
> >> >> This solution will make us have 3 pom files in codebase, doesnt look
> >> >> very elegant,
> >> >
> >> >
> >> > actually depends on your point of view. To me this is the more elegant
> >> > solution as you clearly see the relationship between inputs (pom.xml)
> and
> >> > outputs (artifacts, e.g. jars wars, etc)
> >> >
> >> >
> >> >> but will solve our dependency management issues between
> >> >> the 2 packaging.
> >> >>
> >> >>
> >> >> Are these good solutions? Is there any other good solution available
> >> >> for this scenario ?
> >> >>
> >> >>
> >> >> Regards
> >> >> Narayanan
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> 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
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Generating war and Jar from same codebase

Posted by Barrie Treloar <ba...@gmail.com>.
On 23 April 2014 13:45, Narayanan K <kn...@gmail.com> wrote:

> Hi Anders
>
> The codebase is the same. So having 2 separate directories (for
> modules) and pom in each of them is not required right ?
>
> I can have <modules> in parent pom to specify the 2 child poms that
> are present in the same project level. Tried below and seems it is
> working.
>
> parent pom will have :
>
> <modules>
>   <module>pom-war.xml</module>
>   <module>pom-jar.xml</module>
> <modules>


Please have a look at the freely available books at
http://maven.apache.org/articles.html

Spending a few hours reading about how things should be done and the
concepts behind them will be your best use of time.
This will help boost your knowledge and help you to articulate your
questions to get the best answers in the future.

Re: Generating war and Jar from same codebase

Posted by Narayanan K <kn...@gmail.com>.
Hi Anders

The codebase is the same. So having 2 separate directories (for
modules) and pom in each of them is not required right ?

I can have <modules> in parent pom to specify the 2 child poms that
are present in the same project level. Tried below and seems it is
working.

parent pom will have :

<modules>
  <module>pom-war.xml</module>
  <module>pom-jar.xml</module>
<modules>

In both child poms,

<parent>
<relativePath>./pom-parent.xml</relativePath>
</parent>

Currently including the jar artifact dependency in war project cannot
be done due to some restrictions in our development.

Narayanan

On Tue, Apr 22, 2014 at 11:37 AM, Anders Hammar <an...@hammar.net> wrote:
>> My new maven project structure will be :
>>
>> .
>>  | -- pom.xml (parent pom)
>>  | -- pom-war.xml (inherits from parent, generates a war)
>>  | -- pom-jar.xml (inherits from parent, generates a jar)
>>
>> There are no modules in the project. All poms are going to be in the
>> root path of the project.
>>
>
> Wrong!
> You should create two modules; one for the jar project and one for the war
> project. Follow the Maven standards and you can use any of the many
> examples of this on the Internet.
> I believe we haven't pushed the mantra for some time now, so here it comes:
> Don't fight Maven!
>
> /Anders
>
>
>>
>> 1. Any examples on how to write the parent pom referencing the same
>> codebase for the child poms.
>> Will there be a <module> tag for parent pom.  I understand that the
>> packaging for parent pom will be "pom".
>>
>> 2. The child poms will have <relativePath> in <parent> tag as
>> ./pom.xml. Please correct me if this is wrong.
>>
>> Thanks
>> Narayanan
>>
>>
>>
>>
>>
>> Narayanan
>>
>> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
>> <st...@gmail.com> wrote:
>> > On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>> >
>> >> Hi
>> >>
>> >> We have a default pom file with packaging "war" for our codebase.
>> >>
>> >> From the same code base we also want to generate a normal jar and a
>> >> fat jar with dependencies.
>> >>
>> >> Currently solution that has been implemented is another pom-jar.xml
>> >> file that has the packaging as jar and maven-assembly-plugin to
>> >> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>> >>
>> >> But we are in a situation where if any new dependency is added to
>> >> pom.xml, we need to add to pom-jar.xml as well as it is the same
>> >> codebase.
>> >>
>> >> To avoid this we thought of couple of solutions -
>> >>
>> >> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>> >> with packaging war - so it generates a war file, a normal jar file and
>> >> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>> >>
>> >> Not sure if this is a good solution. We tried this, but this is
>> >> working well only in maven 3.0.4. The assembly plugin is not working
>> >> well with Maven 2 (which is in our build environment) while generating
>> >> the fat jar.
>> >>
>> >> 2. Have a parent pom and put all the dependencies and plugins in that
>> >> and have 2 child poms in the same codebase with different names
>> >> inherit from parent pom, one that has packaging of war that generates
>> >> war file and the other child pom has packaging jar with maven assembly
>> >> plugin to generate both normal and fat jar. And all new dependencies
>> >> need to be added only to parent pom.
>> >>
>> >> This solution will make us have 3 pom files in codebase, doesnt look
>> >> very elegant,
>> >
>> >
>> > actually depends on your point of view. To me this is the more elegant
>> > solution as you clearly see the relationship between inputs (pom.xml) and
>> > outputs (artifacts, e.g. jars wars, etc)
>> >
>> >
>> >> but will solve our dependency management issues between
>> >> the 2 packaging.
>> >>
>> >>
>> >> Are these good solutions? Is there any other good solution available
>> >> for this scenario ?
>> >>
>> >>
>> >> Regards
>> >> Narayanan
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>>
>>

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


Re: Generating war and Jar from same codebase

Posted by Anders Hammar <an...@hammar.net>.
> My new maven project structure will be :
>
> .
>  | -- pom.xml (parent pom)
>  | -- pom-war.xml (inherits from parent, generates a war)
>  | -- pom-jar.xml (inherits from parent, generates a jar)
>
> There are no modules in the project. All poms are going to be in the
> root path of the project.
>

Wrong!
You should create two modules; one for the jar project and one for the war
project. Follow the Maven standards and you can use any of the many
examples of this on the Internet.
I believe we haven't pushed the mantra for some time now, so here it comes:
Don't fight Maven!

/Anders


>
> 1. Any examples on how to write the parent pom referencing the same
> codebase for the child poms.
> Will there be a <module> tag for parent pom.  I understand that the
> packaging for parent pom will be "pom".
>
> 2. The child poms will have <relativePath> in <parent> tag as
> ./pom.xml. Please correct me if this is wrong.
>
> Thanks
> Narayanan
>
>
>
>
>
> Narayanan
>
> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
> <st...@gmail.com> wrote:
> > On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
> >
> >> Hi
> >>
> >> We have a default pom file with packaging "war" for our codebase.
> >>
> >> From the same code base we also want to generate a normal jar and a
> >> fat jar with dependencies.
> >>
> >> Currently solution that has been implemented is another pom-jar.xml
> >> file that has the packaging as jar and maven-assembly-plugin to
> >> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
> >>
> >> But we are in a situation where if any new dependency is added to
> >> pom.xml, we need to add to pom-jar.xml as well as it is the same
> >> codebase.
> >>
> >> To avoid this we thought of couple of solutions -
> >>
> >> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
> >> with packaging war - so it generates a war file, a normal jar file and
> >> fat jar out of the same pom. So we can do away with the pom-jar.xml.
> >>
> >> Not sure if this is a good solution. We tried this, but this is
> >> working well only in maven 3.0.4. The assembly plugin is not working
> >> well with Maven 2 (which is in our build environment) while generating
> >> the fat jar.
> >>
> >> 2. Have a parent pom and put all the dependencies and plugins in that
> >> and have 2 child poms in the same codebase with different names
> >> inherit from parent pom, one that has packaging of war that generates
> >> war file and the other child pom has packaging jar with maven assembly
> >> plugin to generate both normal and fat jar. And all new dependencies
> >> need to be added only to parent pom.
> >>
> >> This solution will make us have 3 pom files in codebase, doesnt look
> >> very elegant,
> >
> >
> > actually depends on your point of view. To me this is the more elegant
> > solution as you clearly see the relationship between inputs (pom.xml) and
> > outputs (artifacts, e.g. jars wars, etc)
> >
> >
> >> but will solve our dependency management issues between
> >> the 2 packaging.
> >>
> >>
> >> Are these good solutions? Is there any other good solution available
> >> for this scenario ?
> >>
> >>
> >> Regards
> >> Narayanan
> >>
> >> ---------------------------------------------------------------------
> >> 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: Generating war and Jar from same codebase

Posted by Ron Wheeler <rw...@artifact-software.com>.
Code is in jar project. Jar produces x.jar,
No code in Parent
No code in war. War depends on jar project output x.jar. It includes web 
resources but no code. Produces x.war.

Ron


On 22/04/2014 1:15 PM, Narayanan K wrote:
> Thanks all for replying.
>
> So having a parent pom and inheriting common dependencies to the 2
> child poms is the best solution.
>
> My new maven project structure will be :
>
> .
>   | -- pom.xml (parent pom)
>   | -- pom-war.xml (inherits from parent, generates a war)
>   | -- pom-jar.xml (inherits from parent, generates a jar)
>
> There are no modules in the project. All poms are going to be in the
> root path of the project.
>
> 1. Any examples on how to write the parent pom referencing the same
> codebase for the child poms.
> Will there be a <module> tag for parent pom.  I understand that the
> packaging for parent pom will be "pom".
>
> 2. The child poms will have <relativePath> in <parent> tag as
> ./pom.xml. Please correct me if this is wrong.
>
> Thanks
> Narayanan
>
>
>
>
>
> Narayanan
>
> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
> <st...@gmail.com> wrote:
>> On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>>
>>> Hi
>>>
>>> We have a default pom file with packaging "war" for our codebase.
>>>
>>>  From the same code base we also want to generate a normal jar and a
>>> fat jar with dependencies.
>>>
>>> Currently solution that has been implemented is another pom-jar.xml
>>> file that has the packaging as jar and maven-assembly-plugin to
>>> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>>>
>>> But we are in a situation where if any new dependency is added to
>>> pom.xml, we need to add to pom-jar.xml as well as it is the same
>>> codebase.
>>>
>>> To avoid this we thought of couple of solutions -
>>>
>>> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>>> with packaging war - so it generates a war file, a normal jar file and
>>> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>>>
>>> Not sure if this is a good solution. We tried this, but this is
>>> working well only in maven 3.0.4. The assembly plugin is not working
>>> well with Maven 2 (which is in our build environment) while generating
>>> the fat jar.
>>>
>>> 2. Have a parent pom and put all the dependencies and plugins in that
>>> and have 2 child poms in the same codebase with different names
>>> inherit from parent pom, one that has packaging of war that generates
>>> war file and the other child pom has packaging jar with maven assembly
>>> plugin to generate both normal and fat jar. And all new dependencies
>>> need to be added only to parent pom.
>>>
>>> This solution will make us have 3 pom files in codebase, doesnt look
>>> very elegant,
>>
>> actually depends on your point of view. To me this is the more elegant
>> solution as you clearly see the relationship between inputs (pom.xml) and
>> outputs (artifacts, e.g. jars wars, etc)
>>
>>
>>> but will solve our dependency management issues between
>>> the 2 packaging.
>>>
>>>
>>> Are these good solutions? Is there any other good solution available
>>> for this scenario ?
>>>
>>>
>>> Regards
>>> Narayanan
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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


Re: Generating war and Jar from same codebase

Posted by Olivier Lamy <ol...@apache.org>.
Have a look at this option:
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#archiveClasses



On 23 April 2014 03:15, Narayanan K <kn...@gmail.com> wrote:
> Thanks all for replying.
>
> So having a parent pom and inheriting common dependencies to the 2
> child poms is the best solution.
>
> My new maven project structure will be :
>
> .
>  | -- pom.xml (parent pom)
>  | -- pom-war.xml (inherits from parent, generates a war)
>  | -- pom-jar.xml (inherits from parent, generates a jar)
>
> There are no modules in the project. All poms are going to be in the
> root path of the project.
>
> 1. Any examples on how to write the parent pom referencing the same
> codebase for the child poms.
> Will there be a <module> tag for parent pom.  I understand that the
> packaging for parent pom will be "pom".
>
> 2. The child poms will have <relativePath> in <parent> tag as
> ./pom.xml. Please correct me if this is wrong.
>
> Thanks
> Narayanan
>
>
>
>
>
> Narayanan
>
> On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
> <st...@gmail.com> wrote:
>> On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>>
>>> Hi
>>>
>>> We have a default pom file with packaging "war" for our codebase.
>>>
>>> From the same code base we also want to generate a normal jar and a
>>> fat jar with dependencies.
>>>
>>> Currently solution that has been implemented is another pom-jar.xml
>>> file that has the packaging as jar and maven-assembly-plugin to
>>> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>>>
>>> But we are in a situation where if any new dependency is added to
>>> pom.xml, we need to add to pom-jar.xml as well as it is the same
>>> codebase.
>>>
>>> To avoid this we thought of couple of solutions -
>>>
>>> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>>> with packaging war - so it generates a war file, a normal jar file and
>>> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>>>
>>> Not sure if this is a good solution. We tried this, but this is
>>> working well only in maven 3.0.4. The assembly plugin is not working
>>> well with Maven 2 (which is in our build environment) while generating
>>> the fat jar.
>>>
>>> 2. Have a parent pom and put all the dependencies and plugins in that
>>> and have 2 child poms in the same codebase with different names
>>> inherit from parent pom, one that has packaging of war that generates
>>> war file and the other child pom has packaging jar with maven assembly
>>> plugin to generate both normal and fat jar. And all new dependencies
>>> need to be added only to parent pom.
>>>
>>> This solution will make us have 3 pom files in codebase, doesnt look
>>> very elegant,
>>
>>
>> actually depends on your point of view. To me this is the more elegant
>> solution as you clearly see the relationship between inputs (pom.xml) and
>> outputs (artifacts, e.g. jars wars, etc)
>>
>>
>>> but will solve our dependency management issues between
>>> the 2 packaging.
>>>
>>>
>>> Are these good solutions? Is there any other good solution available
>>> for this scenario ?
>>>
>>>
>>> Regards
>>> Narayanan
>>>
>>> ---------------------------------------------------------------------
>>> 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
>



-- 
Olivier Lamy
Ecetera: http://ecetera.com.au
http://twitter.com/olamy | http://linkedin.com/in/olamy

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


Re: Generating war and Jar from same codebase

Posted by Narayanan K <kn...@gmail.com>.
Thanks all for replying.

So having a parent pom and inheriting common dependencies to the 2
child poms is the best solution.

My new maven project structure will be :

.
 | -- pom.xml (parent pom)
 | -- pom-war.xml (inherits from parent, generates a war)
 | -- pom-jar.xml (inherits from parent, generates a jar)

There are no modules in the project. All poms are going to be in the
root path of the project.

1. Any examples on how to write the parent pom referencing the same
codebase for the child poms.
Will there be a <module> tag for parent pom.  I understand that the
packaging for parent pom will be "pom".

2. The child poms will have <relativePath> in <parent> tag as
./pom.xml. Please correct me if this is wrong.

Thanks
Narayanan





Narayanan

On Tue, Apr 22, 2014 at 12:38 AM, Stephen Connolly
<st...@gmail.com> wrote:
> On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:
>
>> Hi
>>
>> We have a default pom file with packaging "war" for our codebase.
>>
>> From the same code base we also want to generate a normal jar and a
>> fat jar with dependencies.
>>
>> Currently solution that has been implemented is another pom-jar.xml
>> file that has the packaging as jar and maven-assembly-plugin to
>> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>>
>> But we are in a situation where if any new dependency is added to
>> pom.xml, we need to add to pom-jar.xml as well as it is the same
>> codebase.
>>
>> To avoid this we thought of couple of solutions -
>>
>> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
>> with packaging war - so it generates a war file, a normal jar file and
>> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>>
>> Not sure if this is a good solution. We tried this, but this is
>> working well only in maven 3.0.4. The assembly plugin is not working
>> well with Maven 2 (which is in our build environment) while generating
>> the fat jar.
>>
>> 2. Have a parent pom and put all the dependencies and plugins in that
>> and have 2 child poms in the same codebase with different names
>> inherit from parent pom, one that has packaging of war that generates
>> war file and the other child pom has packaging jar with maven assembly
>> plugin to generate both normal and fat jar. And all new dependencies
>> need to be added only to parent pom.
>>
>> This solution will make us have 3 pom files in codebase, doesnt look
>> very elegant,
>
>
> actually depends on your point of view. To me this is the more elegant
> solution as you clearly see the relationship between inputs (pom.xml) and
> outputs (artifacts, e.g. jars wars, etc)
>
>
>> but will solve our dependency management issues between
>> the 2 packaging.
>>
>>
>> Are these good solutions? Is there any other good solution available
>> for this scenario ?
>>
>>
>> Regards
>> Narayanan
>>
>> ---------------------------------------------------------------------
>> 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: Generating war and Jar from same codebase

Posted by Stephen Connolly <st...@gmail.com>.
On 22 April 2014 01:18, Narayanan K <kn...@gmail.com> wrote:

> Hi
>
> We have a default pom file with packaging "war" for our codebase.
>
> From the same code base we also want to generate a normal jar and a
> fat jar with dependencies.
>
> Currently solution that has been implemented is another pom-jar.xml
> file that has the packaging as jar and maven-assembly-plugin to
> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>
> But we are in a situation where if any new dependency is added to
> pom.xml, we need to add to pom-jar.xml as well as it is the same
> codebase.
>
> To avoid this we thought of couple of solutions -
>
> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
> with packaging war - so it generates a war file, a normal jar file and
> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>
> Not sure if this is a good solution. We tried this, but this is
> working well only in maven 3.0.4. The assembly plugin is not working
> well with Maven 2 (which is in our build environment) while generating
> the fat jar.
>
> 2. Have a parent pom and put all the dependencies and plugins in that
> and have 2 child poms in the same codebase with different names
> inherit from parent pom, one that has packaging of war that generates
> war file and the other child pom has packaging jar with maven assembly
> plugin to generate both normal and fat jar. And all new dependencies
> need to be added only to parent pom.
>
> This solution will make us have 3 pom files in codebase, doesnt look
> very elegant,


actually depends on your point of view. To me this is the more elegant
solution as you clearly see the relationship between inputs (pom.xml) and
outputs (artifacts, e.g. jars wars, etc)


> but will solve our dependency management issues between
> the 2 packaging.
>
>
> Are these good solutions? Is there any other good solution available
> for this scenario ?
>
>
> Regards
> Narayanan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Generating war and Jar from same codebase

Posted by Aldrin Leal <al...@leal.eng.br>.
I believe the Tomcat Plugin offers a way to create a fat jar with tomcat +
your deps.

http://tomcat.apache.org/maven-plugin-2.2/executable-war-jar.html

Wouldn't it help perhaps?

--
-- Aldrin Leal, <al...@leal.eng.br>
Master your EC2-fu! Get the latest ekaterminal public beta
http://www.ingenieux.com.br/products/ekaterminal/


On Mon, Apr 21, 2014 at 9:18 PM, Narayanan K <kn...@gmail.com> wrote:

> Hi
>
> We have a default pom file with packaging "war" for our codebase.
>
> From the same code base we also want to generate a normal jar and a
> fat jar with dependencies.
>
> Currently solution that has been implemented is another pom-jar.xml
> file that has the packaging as jar and maven-assembly-plugin to
> generate the jar with dependencies. We use mvn install -f pom-jar.xml.
>
> But we are in a situation where if any new dependency is added to
> pom.xml, we need to add to pom-jar.xml as well as it is the same
> codebase.
>
> To avoid this we thought of couple of solutions -
>
> 1. Add maven-jar-plugin and maven-assembly-plugin to the default pom
> with packaging war - so it generates a war file, a normal jar file and
> fat jar out of the same pom. So we can do away with the pom-jar.xml.
>
> Not sure if this is a good solution. We tried this, but this is
> working well only in maven 3.0.4. The assembly plugin is not working
> well with Maven 2 (which is in our build environment) while generating
> the fat jar.
>
> 2. Have a parent pom and put all the dependencies and plugins in that
> and have 2 child poms in the same codebase with different names
> inherit from parent pom, one that has packaging of war that generates
> war file and the other child pom has packaging jar with maven assembly
> plugin to generate both normal and fat jar. And all new dependencies
> need to be added only to parent pom.
>
> This solution will make us have 3 pom files in codebase, doesnt look
> very elegant, but will solve our dependency management issues between
> the 2 packaging.
>
>
> Are these good solutions? Is there any other good solution available
> for this scenario ?
>
>
> Regards
> Narayanan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>