You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alex Ditu <di...@gmail.com> on 2015/08/10 13:12:23 UTC

Use 2 pom.xml files with different names

Hello,

I want to use pom.xml files for my project with 2 different names:
pom.xml and pom2.xml.
In order to select wich one to execute/use I use -f <pom-name> like this:

mvn -f pom2.xml deploy

Using this aproach I've encountered some problems in 2 scenarios:

1. If both pom.xml and pom2.xml exist when running the install phase,
altough I've specified -f pom2.xml, maven is still using 'pom.xml'
when installing my jar in .m2: output looks like this:

installing .../project/pom.xml ..../.m2/.../project/artifact-1.0.0-SNAPSHOT.pom

it should be:
installing .../project/pom2.xml ..../.m2/.../project/artifact-1.0.0-SNAPSHOT.pom

but because it finds pom.xml it passes this phase, and when it reaches
deploy phase it gives this error:

deploy failed: Cannot add two different pieces of metadata for:
project dvh.web.sockets.push.server:webSocketsPushServerCommon


2. If I have just one pom file but with a different name (for eg.
pom2.xml) it doesn't pass the install phase, because it searches for
pom.xml not for pom2.xml (so it appears that 'mvn -f otherPomName.xml'
doesn't work for install phase).

Am I missing something here? Or is just a bug?

P.S. Don't ask me why I want to use 2 pom files, if anyone encountered
this situation and knows how to deal with it, help will be much
appreciated :)

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


Re: Use 2 pom.xml files with different names

Posted by Benson Margulies <bi...@gmail.com>.
Formally, a project has can only produce one POM artifact. So, you can
do whatever you want with -f, but when it comes to install or deploy,
you are pushing the one-and-only pom (selected from the file system
with -f), and it gets the immutable, conventional, name of the pom
artifact in the repository. Perhaps if you explained what you want to
accomplish we could be more helpful.


On Mon, Aug 10, 2015 at 7:12 AM, Alex Ditu <di...@gmail.com> wrote:
> Hello,
>
> I want to use pom.xml files for my project with 2 different names:
> pom.xml and pom2.xml.
> In order to select wich one to execute/use I use -f <pom-name> like this:
>
> mvn -f pom2.xml deploy
>
> Using this aproach I've encountered some problems in 2 scenarios:
>
> 1. If both pom.xml and pom2.xml exist when running the install phase,
> altough I've specified -f pom2.xml, maven is still using 'pom.xml'
> when installing my jar in .m2: output looks like this:
>
> installing .../project/pom.xml ..../.m2/.../project/artifact-1.0.0-SNAPSHOT.pom
>
> it should be:
> installing .../project/pom2.xml ..../.m2/.../project/artifact-1.0.0-SNAPSHOT.pom
>
> but because it finds pom.xml it passes this phase, and when it reaches
> deploy phase it gives this error:
>
> deploy failed: Cannot add two different pieces of metadata for:
> project dvh.web.sockets.push.server:webSocketsPushServerCommon
>
>
> 2. If I have just one pom file but with a different name (for eg.
> pom2.xml) it doesn't pass the install phase, because it searches for
> pom.xml not for pom2.xml (so it appears that 'mvn -f otherPomName.xml'
> doesn't work for install phase).
>
> Am I missing something here? Or is just a bug?
>
> P.S. Don't ask me why I want to use 2 pom files, if anyone encountered
> this situation and knows how to deal with it, help will be much
> appreciated :)
>
> ---------------------------------------------------------------------
> 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: Use 2 pom.xml files with different names

Posted by Ron Wheeler <rw...@artifact-software.com>.
Everyone needs to do this.
It is the basic concept behind java servlets.
You put all the code in the project that creates the jar and you make 
that jar a dependency in the war which has all your servlet 
configuration and resources.

Ron


On 10/08/2015 9:52 AM, Alex Ditu wrote:
> Ok, look what I am trying to achieve: I have a project with 2
> profileDeployments (it produces 2 types of artifacts: a jar and a war)
> but from the same sources. So, I did the following thing: I have
> written 2 pom.xml files with 2 different names (for example: pom.xml
> and pom2.xml). When I want to build the .jar artifact I would use the
> command 'mvn deploy' when I want the .war artifact I would use: 'mvn
> -f pom2.xml' ---> after this, I encounter the problem I mentioned
> earlier.
>
> Note that the artifactIds are different.
>
>
> On Mon, Aug 10, 2015 at 4:38 PM, Greg Trasuk <tr...@stratuscom.com> wrote:
>>> On Aug 10, 2015, at 7:12 AM, Alex Ditu <di...@gmail.com> wrote:
>>>
>>> Hello,
>>>
>>> I want to use pom.xml files for my project with 2 different names:
>>> pom.xml and pom2.xml.
>>> In order to select wich one to execute/use I use -f <pom-name> like this:
>>>
>> (…snip…)
>>
>>> P.S. Don't ask me why I want to use 2 pom files, if anyone encountered
>>> this situation and knows how to deal with it, help will be much
>>> appreciated :)
>>>
>> The problem is, it’s kind of like asking “When I try to drive on the railroad tracks with my car, I keep falling off the rails - has anyone else encountered this problem?”  The fundamental concept of Maven is that an artifact is uniquely identified, and the pom file describes the artifact.  As such, when Maven puts the artifact into the local repository, it follows the naming conventions.
>>
>> You might be better off to describe what you’re actually trying to achieve, and then we can suggest how to do that.
>>
>> Cheers,
>>
>> Greg Trasuk
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Use 2 pom.xml files with different names

Posted by "Daniel Johnson (danijoh2)" <da...@cisco.com>.
I would expect this behavior that Martin has shown.

Create a pom.xml and pom2.xml, and run 'mvn clean install -f pom2.xml’, you will see pom2.xml get installed into local maven repository. As Martin shows, pom.xml or pom2.xml name is not what is copied to repository, but instead the <artifactId>-<version>.pom naming convention is used. Even with pom.xml in same directory I see pom2.xml information was used.
DANIJOH2-M-V0MA:Desktop danijoh2$ ls pom*
pom.xml		pom2.xml

[INFO] Installing /Users/danijoh2/Desktop/pom2.xml to /Users/danijoh2/.m2/repository/com/danijoh2/sample2/1.0.0-SNAPSHOT/sample2-1.0.0-SNAPSHOT.pom

If however you get to maven release plugin, release:prepare and release:perform goals, I believe you need to also include -Darguments='-f pom2.xml’, or something similar, I am not sure of the exact syntax.

But as others suggested, there are probably better ways to get what you want.

Cheers,
Daniel






On 8/11/15, 3:45 AM, "Martin Hoeller" <ma...@xss.co.at> wrote:

>Hi!
>
>Am Mon, 10 Aug 2015 19:23:51 +0300 schrieb Alex Ditu <di...@gmail.com>:
>
>> I cannot test right now, but it can be tested very simple: in a simple
>> project, rename pom.xml and run install/deploy, and see if it works.
>> If it is ok, then is smth that I've done wrong. Else maybe it is the
>> desired effect (wich I don't understand).
>
>I created a simple quickstart project with
>
>  mvn archetype:generate
>
>moved the pom.xml to some-pom.xml and executed
>
>  mvn -f some-pom.xml install
>
>without any problems. The project was installed correctly in
>~/.m2/repository:
>
>  $ ls -1 ~/.m2/repository/test/quickstart/1.0-SNAPSHOT/
>  _remote.repositories
>  maven-metadata-local.xml
>  quickstart-1.0-SNAPSHOT.jar
>  quickstart-1.0-SNAPSHOT.pom
>
>So something must be different in your setup.
>
>hth,
>- martin

Re: Use 2 pom.xml files with different names

Posted by Martin Hoeller <ma...@xss.co.at>.
Hi!

Am Mon, 10 Aug 2015 19:23:51 +0300 schrieb Alex Ditu <di...@gmail.com>:

> I cannot test right now, but it can be tested very simple: in a simple
> project, rename pom.xml and run install/deploy, and see if it works.
> If it is ok, then is smth that I've done wrong. Else maybe it is the
> desired effect (wich I don't understand).

I created a simple quickstart project with

  mvn archetype:generate

moved the pom.xml to some-pom.xml and executed

  mvn -f some-pom.xml install

without any problems. The project was installed correctly in
~/.m2/repository:

  $ ls -1 ~/.m2/repository/test/quickstart/1.0-SNAPSHOT/
  _remote.repositories
  maven-metadata-local.xml
  quickstart-1.0-SNAPSHOT.jar
  quickstart-1.0-SNAPSHOT.pom

So something must be different in your setup.

hth,
- martin

Re: Use 2 pom.xml files with different names

Posted by Alex Ditu <di...@gmail.com>.
I don't have acces to the files right now (i don't have my laptop with me),
but I am not sure it matters what they contain because the command 'mvn -f
otherPom.xml deploy' works fine (it builds the project in the correct way),
so the package phase works, but when it reaches the install phase it is
trying to install pom.xml in .m2, not otherPom.xml like it should.

I cannot test right now, but it can be tested very simple: in a simple
project, rename pom.xml and run install/deploy, and see if it works. If it
is ok, then is smth that I've done wrong. Else maybe it is the desired
effect (wich I don't understand).

Thank you for your patience :)

On Monday, August 10, 2015, Sander Verhagen <sa...@sanderverhagen.net>
wrote:

> Hi,
>
>
>
>
>
> I think you're being treated unfairly ;-)
>
>
>
> Yes, it's not the Maven way, but you have acknowledged that. But sometimes
> projects are the way they are. I do my best to deliver nice Maven projects,
> but I have one project also where the sources are so intertwined that I
> cannot possibly split them up. This is a documentation project, and its
> "sources", from Maven's perspective, are generated for me (not just once),
> so refactoring these sources is out of my hands. I wish it were different,
> but for now this is what it is, and I've decided that for me this is still
> a valid use case for Maven. So, give the guy a break ;-)
>
>
>
> By the way, I think the discussion mixes up artifacts and folders. Yes,
> the POM uniquely describes an artifact, no argument there. It does not
> constitute exclusive ownership of a folder – in my humble opinion.
>
>
>
> That all being said: it's working for me. We deploy and release these
> modules, and these are the POM files:
>
> ·         pom.xml // parent the following modules
>
> ·         pom-onpremises.xml // parent.relativePath=./pom.xml
>
> ·         pom-hosted.xml
>
>
>
> I don’t think I did much out of the ordinary to make this setup work. I
> feel it’s pretty much the same as what you’re doing. So, at this point we
> start dissecting POM files?
>
>
>
> Sander.
>
>
> Sander Verhagen
> [  sander@sanderverhagen.net <javascript:;><mailto:
> sander@sanderverhagen.net <javascript:;>>  ]
>
> NOTICE: my e-mail address has changed. Please remove Verhagen@Sander.com
> <mailto:Verhagen@Sander.com <javascript:;>> now and start using
> Sander@SanderVerhagen.net<mailto:Sander@SanderVerhagen.net <javascript:;>>
> from now on. Please update your address book. Thank  you!
>
>
>
> > -----Original Message-----
>
> > From: Alex Ditu [mailto:ditu.alexandru@gmail.com <javascript:;>]
>
> > Sent: Monday, August 10, 2015 8:17
>
> > To: Maven Users List
>
> > Subject: Re: Use 2 pom.xml files with different names
>
> >
>
> > So the answer is: one cannot use a pom file with a different name than
>
> > 'pom.xml'.
>
> >
>
> > In such case, why the -f option exists?
>
> > On Aug 10, 2015 6:13 PM, "Benson Margulies" <bimargulies@gmail.com
> <javascript:;><mailto:bimargulies@gmail.com <javascript:;>>>
>
> > wrote:
>
> >
>
> > > On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu
>
> > <ditu.alexandru@gmail.com <javascript:;><mailto:ditu.alexandru@gmail.com
> <javascript:;>>>
>
> > > wrote:
>
> > > > I know how to solve my problem (by changing the project
> configuration).
>
> > > >
>
> > > > My question is: why mvn -f otherPomName.xml deploy doesen't work?
>
> > > > And I said above how it fails.
>
> > >
>
> > > It does not _fail_. It does precisely what it is designed to do.
>
> > >
>
> > > mvn -f says, 'read the model of this project from an alternative
>
> > > location, and then do what you do.'
>
> > >
>
> > > Once Maven has read the XML, it has no idea where the file came from,
>
> > > and it's not supposed to have any idea where the file came from.
>
> > > Maven's job is to do the build as specified by the POM abstract data
>
> > > model. That makes no provisions for your scheme.
>
> > >
>
> > >
>
> > >
>
> > > > On Aug 10, 2015 5:59 PM, "Barrie Treloar" <baerrach@gmail.com
> <javascript:;><mailto:baerrach@gmail.com <javascript:;>>> wrote:
>
> > > >
>
> > > >> On 10 August 2015 at 23:22, Alex Ditu <ditu.alexandru@gmail.com
> <javascript:;><mailto:ditu.alexandru@gmail.com <javascript:;>>>
>
> > wrote:
>
> > > >>
>
> > > >> > Ok, look what I am trying to achieve: I have a project with 2
>
> > > >> > profileDeployments (it produces 2 types of artifacts: a jar and a
>
> > > >> > war) but from the same sources. So, I did the following thing: I
>
> > > >> > have written 2 pom.xml files with 2 different names (for example:
>
> > > >> > pom.xml and pom2.xml). When I want to build the .jar artifact I
>
> > > >> > would use the command 'mvn deploy' when I want the .war artifact
>
> > > >> > I would use: 'mvn -f pom2.xml' ---> after this, I encounter the
>
> > > >> > problem I mentioned earlier.
>
> > > >> >
>
> > > >> > Note that the artifactIds are different.
>
> > > >>
>
> > > >>
>
> > > >> You solution is simple: do not have one project, split it into
>
> > > >> multiple projects.
>
> > > >>
>
> > > >> A war file should not have any java code in it. So there is no need
>
> > > >> for
>
> > > you
>
> > > >> do be having two poms. You war project depends on the jar project
>
> > > >> and
>
> > > you
>
> > > >> are done.
>
> > > >>
>
> > > >> There are plenty of examples on how to do this in the freely
>
> > > >> available maven books at http://maven.apache.org/articles.html
>
> > > >>
>
> > >
>
> > > ---------------------------------------------------------------------
>
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> <javascript:;><mailto:users-unsubscribe@maven.apache.org <javascript:;>>
>
> > > For additional commands, e-mail: users-help@maven.apache.org
> <javascript:;><mailto:users-help@maven.apache.org <javascript:;>>
>
> > >
>
> > >
>

RE: Use 2 pom.xml files with different names

Posted by Sander Verhagen <sa...@sanderverhagen.net>.
Hi,





I think you're being treated unfairly ;-)



Yes, it's not the Maven way, but you have acknowledged that. But sometimes projects are the way they are. I do my best to deliver nice Maven projects, but I have one project also where the sources are so intertwined that I cannot possibly split them up. This is a documentation project, and its "sources", from Maven's perspective, are generated for me (not just once), so refactoring these sources is out of my hands. I wish it were different, but for now this is what it is, and I've decided that for me this is still a valid use case for Maven. So, give the guy a break ;-)



By the way, I think the discussion mixes up artifacts and folders. Yes, the POM uniquely describes an artifact, no argument there. It does not constitute exclusive ownership of a folder – in my humble opinion.



That all being said: it's working for me. We deploy and release these modules, and these are the POM files:

·         pom.xml // parent the following modules

·         pom-onpremises.xml // parent.relativePath=./pom.xml

·         pom-hosted.xml



I don’t think I did much out of the ordinary to make this setup work. I feel it’s pretty much the same as what you’re doing. So, at this point we start dissecting POM files?



Sander.


Sander Verhagen
[  sander@sanderverhagen.net<ma...@sanderverhagen.net>  ]

NOTICE: my e-mail address has changed. Please remove Verhagen@Sander.com<ma...@Sander.com> now and start using Sander@SanderVerhagen.net<ma...@SanderVerhagen.net> from now on. Please update your address book. Thank  you!



> -----Original Message-----

> From: Alex Ditu [mailto:ditu.alexandru@gmail.com]

> Sent: Monday, August 10, 2015 8:17

> To: Maven Users List

> Subject: Re: Use 2 pom.xml files with different names

>

> So the answer is: one cannot use a pom file with a different name than

> 'pom.xml'.

>

> In such case, why the -f option exists?

> On Aug 10, 2015 6:13 PM, "Benson Margulies" <bi...@gmail.com>>

> wrote:

>

> > On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu

> <di...@gmail.com>>

> > wrote:

> > > I know how to solve my problem (by changing the project configuration).

> > >

> > > My question is: why mvn -f otherPomName.xml deploy doesen't work?

> > > And I said above how it fails.

> >

> > It does not _fail_. It does precisely what it is designed to do.

> >

> > mvn -f says, 'read the model of this project from an alternative

> > location, and then do what you do.'

> >

> > Once Maven has read the XML, it has no idea where the file came from,

> > and it's not supposed to have any idea where the file came from.

> > Maven's job is to do the build as specified by the POM abstract data

> > model. That makes no provisions for your scheme.

> >

> >

> >

> > > On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com>> wrote:

> > >

> > >> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com>>

> wrote:

> > >>

> > >> > Ok, look what I am trying to achieve: I have a project with 2

> > >> > profileDeployments (it produces 2 types of artifacts: a jar and a

> > >> > war) but from the same sources. So, I did the following thing: I

> > >> > have written 2 pom.xml files with 2 different names (for example:

> > >> > pom.xml and pom2.xml). When I want to build the .jar artifact I

> > >> > would use the command 'mvn deploy' when I want the .war artifact

> > >> > I would use: 'mvn -f pom2.xml' ---> after this, I encounter the

> > >> > problem I mentioned earlier.

> > >> >

> > >> > Note that the artifactIds are different.

> > >>

> > >>

> > >> You solution is simple: do not have one project, split it into

> > >> multiple projects.

> > >>

> > >> A war file should not have any java code in it. So there is no need

> > >> for

> > you

> > >> do be having two poms. You war project depends on the jar project

> > >> and

> > you

> > >> are done.

> > >>

> > >> There are plenty of examples on how to do this in the freely

> > >> available maven books at http://maven.apache.org/articles.html

> > >>

> >

> > ---------------------------------------------------------------------

> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org<ma...@maven.apache.org>

> > For additional commands, e-mail: users-help@maven.apache.org<ma...@maven.apache.org>

> >

> >

Re: [EXTERNAL] Use 2 pom.xml files with different names

Posted by Mark Derricutt <ma...@talios.com>.
On 11 Aug 2015, at 3:25, Alex Ditu wrote:

> No, but is irrelevant, because the search on the install phase is purely
> based on the name pom.xml (it dosent take into account the -f option, or
> the pom's content). later I will look into the sources for a better
> understanding.

So the root cause here is that the maven-install-plugin ( and possibly, the maven-deploy-plugin ) need someway of knowing to use this alternate pom.xml instead of the normal one.

Is that configurable at all? At a long shot, can use of the build-helper-plugin "replace" the pom.xml artifact in the build?


-- 
Mark Derricutt
http://www.theoryinpractice.net
http://www.chaliceofblood.net
http://plus.google.com/+MarkDerricutt
http://twitter.com/talios
http://facebook.com/mderricutt

RE: [EXTERNAL] Re: Use 2 pom.xml files with different names

Posted by Alex Ditu <di...@gmail.com>.
No, but is irrelevant, because the search on the install phase is purely
based on the name pom.xml (it dosent take into account the -f option, or
the pom's content). later I will look into the sources for a better
understanding.
On Aug 10, 2015 6:20 PM, "Justin Georgeson" <JG...@lgc.com> wrote:

> Do you have the same groupId, artifactId, and version specified in both
> POM files?
>
> > -----Original Message-----
> > From: Alex Ditu [mailto:ditu.alexandru@gmail.com]
> > Sent: Monday, August 10, 2015 10:17 AM
> > To: Maven Users List
> > Subject: [EXTERNAL] Re: Use 2 pom.xml files with different names
> >
> > So the answer is: one cannot use a pom file with a different name than
> > 'pom.xml'.
> >
> > In such case, why the -f option exists?
> > On Aug 10, 2015 6:13 PM, "Benson Margulies" <bi...@gmail.com>
> > wrote:
> >
> > > On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu <di...@gmail.com>
> > > wrote:
> > > > I know how to solve my problem (by changing the project
> configuration).
> > > >
> > > > My question is: why mvn -f otherPomName.xml deploy doesen't work?
> > > > And I said above how it fails.
> > >
> > > It does not _fail_. It does precisely what it is designed to do.
> > >
> > > mvn -f says, 'read the model of this project from an alternative
> > > location, and then do what you do.'
> > >
> > > Once Maven has read the XML, it has no idea where the file came from,
> > > and it's not supposed to have any idea where the file came from.
> > > Maven's job is to do the build as specified by the POM abstract data
> > > model. That makes no provisions for your scheme.
> > >
> > >
> > >
> > > > On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com>
> wrote:
> > > >
> > > >> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com>
> > wrote:
> > > >>
> > > >> > Ok, look what I am trying to achieve: I have a project with 2
> > > >> > profileDeployments (it produces 2 types of artifacts: a jar and a
> > > >> > war) but from the same sources. So, I did the following thing: I
> > > >> > have written 2 pom.xml files with 2 different names (for example:
> > > >> > pom.xml and pom2.xml). When I want to build the .jar artifact I
> > > >> > would use the command 'mvn deploy' when I want the .war artifact
> > > >> > I would use: 'mvn -f pom2.xml' ---> after this, I encounter the
> > > >> > problem I mentioned earlier.
> > > >> >
> > > >> > Note that the artifactIds are different.
> > > >>
> > > >>
> > > >> You solution is simple: do not have one project, split it into
> > > >> multiple projects.
> > > >>
> > > >> A war file should not have any java code in it. So there is no need
> > > >> for
> > > you
> > > >> do be having two poms. You war project depends on the jar project
> > > >> and
> > > you
> > > >> are done.
> > > >>
> > > >> There are plenty of examples on how to do this in the freely
> > > >> available maven books at http://maven.apache.org/articles.html
> > > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
>
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and
> privileged information for the sole use of the intended recipient.  Any
> review, use, distribution, or disclosure by others is strictly prohibited.
> If you are not the intended recipient (or authorized to receive information
> for the intended recipient), please contact the sender by reply e-mail and
> delete all copies of this message.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

RE: [EXTERNAL] Re: Use 2 pom.xml files with different names

Posted by Justin Georgeson <JG...@lgc.com>.
Do you have the same groupId, artifactId, and version specified in both POM files?

> -----Original Message-----
> From: Alex Ditu [mailto:ditu.alexandru@gmail.com]
> Sent: Monday, August 10, 2015 10:17 AM
> To: Maven Users List
> Subject: [EXTERNAL] Re: Use 2 pom.xml files with different names
> 
> So the answer is: one cannot use a pom file with a different name than
> 'pom.xml'.
> 
> In such case, why the -f option exists?
> On Aug 10, 2015 6:13 PM, "Benson Margulies" <bi...@gmail.com>
> wrote:
> 
> > On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu <di...@gmail.com>
> > wrote:
> > > I know how to solve my problem (by changing the project configuration).
> > >
> > > My question is: why mvn -f otherPomName.xml deploy doesen't work?
> > > And I said above how it fails.
> >
> > It does not _fail_. It does precisely what it is designed to do.
> >
> > mvn -f says, 'read the model of this project from an alternative
> > location, and then do what you do.'
> >
> > Once Maven has read the XML, it has no idea where the file came from,
> > and it's not supposed to have any idea where the file came from.
> > Maven's job is to do the build as specified by the POM abstract data
> > model. That makes no provisions for your scheme.
> >
> >
> >
> > > On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com> wrote:
> > >
> > >> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com>
> wrote:
> > >>
> > >> > Ok, look what I am trying to achieve: I have a project with 2
> > >> > profileDeployments (it produces 2 types of artifacts: a jar and a
> > >> > war) but from the same sources. So, I did the following thing: I
> > >> > have written 2 pom.xml files with 2 different names (for example:
> > >> > pom.xml and pom2.xml). When I want to build the .jar artifact I
> > >> > would use the command 'mvn deploy' when I want the .war artifact
> > >> > I would use: 'mvn -f pom2.xml' ---> after this, I encounter the
> > >> > problem I mentioned earlier.
> > >> >
> > >> > Note that the artifactIds are different.
> > >>
> > >>
> > >> You solution is simple: do not have one project, split it into
> > >> multiple projects.
> > >>
> > >> A war file should not have any java code in it. So there is no need
> > >> for
> > you
> > >> do be having two poms. You war project depends on the jar project
> > >> and
> > you
> > >> are done.
> > >>
> > >> There are plenty of examples on how to do this in the freely
> > >> available maven books at http://maven.apache.org/articles.html
> > >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

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

Re: Use 2 pom.xml files with different names

Posted by Alex Ditu <di...@gmail.com>.
So the answer is: one cannot use a pom file with a different name than
'pom.xml'.

In such case, why the -f option exists?
On Aug 10, 2015 6:13 PM, "Benson Margulies" <bi...@gmail.com> wrote:

> On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu <di...@gmail.com>
> wrote:
> > I know how to solve my problem (by changing the project configuration).
> >
> > My question is: why mvn -f otherPomName.xml deploy doesen't work? And I
> > said above how it fails.
>
> It does not _fail_. It does precisely what it is designed to do.
>
> mvn -f says, 'read the model of this project from an alternative
> location, and then do what you do.'
>
> Once Maven has read the XML, it has no idea where the file came from,
> and it's not supposed to have any idea where the file came from.
> Maven's job is to do the build as specified by the POM abstract data
> model. That makes no provisions for your scheme.
>
>
>
> > On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com> wrote:
> >
> >> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com> wrote:
> >>
> >> > Ok, look what I am trying to achieve: I have a project with 2
> >> > profileDeployments (it produces 2 types of artifacts: a jar and a war)
> >> > but from the same sources. So, I did the following thing: I have
> >> > written 2 pom.xml files with 2 different names (for example: pom.xml
> >> > and pom2.xml). When I want to build the .jar artifact I would use the
> >> > command 'mvn deploy' when I want the .war artifact I would use: 'mvn
> >> > -f pom2.xml' ---> after this, I encounter the problem I mentioned
> >> > earlier.
> >> >
> >> > Note that the artifactIds are different.
> >>
> >>
> >> You solution is simple: do not have one project, split it into multiple
> >> projects.
> >>
> >> A war file should not have any java code in it. So there is no need for
> you
> >> do be having two poms. You war project depends on the jar project and
> you
> >> are done.
> >>
> >> There are plenty of examples on how to do this in the freely available
> >> maven books at http://maven.apache.org/articles.html
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Use 2 pom.xml files with different names

Posted by Benson Margulies <bi...@gmail.com>.
On Mon, Aug 10, 2015 at 11:04 AM, Alex Ditu <di...@gmail.com> wrote:
> I know how to solve my problem (by changing the project configuration).
>
> My question is: why mvn -f otherPomName.xml deploy doesen't work? And I
> said above how it fails.

It does not _fail_. It does precisely what it is designed to do.

mvn -f says, 'read the model of this project from an alternative
location, and then do what you do.'

Once Maven has read the XML, it has no idea where the file came from,
and it's not supposed to have any idea where the file came from.
Maven's job is to do the build as specified by the POM abstract data
model. That makes no provisions for your scheme.



> On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com> wrote:
>
>> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com> wrote:
>>
>> > Ok, look what I am trying to achieve: I have a project with 2
>> > profileDeployments (it produces 2 types of artifacts: a jar and a war)
>> > but from the same sources. So, I did the following thing: I have
>> > written 2 pom.xml files with 2 different names (for example: pom.xml
>> > and pom2.xml). When I want to build the .jar artifact I would use the
>> > command 'mvn deploy' when I want the .war artifact I would use: 'mvn
>> > -f pom2.xml' ---> after this, I encounter the problem I mentioned
>> > earlier.
>> >
>> > Note that the artifactIds are different.
>>
>>
>> You solution is simple: do not have one project, split it into multiple
>> projects.
>>
>> A war file should not have any java code in it. So there is no need for you
>> do be having two poms. You war project depends on the jar project and you
>> are done.
>>
>> There are plenty of examples on how to do this in the freely available
>> maven books at http://maven.apache.org/articles.html
>>

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


Re: Use 2 pom.xml files with different names

Posted by Alex Ditu <di...@gmail.com>.
I know how to solve my problem (by changing the project configuration).

My question is: why mvn -f otherPomName.xml deploy doesen't work? And I
said above how it fails.
On Aug 10, 2015 5:59 PM, "Barrie Treloar" <ba...@gmail.com> wrote:

> On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com> wrote:
>
> > Ok, look what I am trying to achieve: I have a project with 2
> > profileDeployments (it produces 2 types of artifacts: a jar and a war)
> > but from the same sources. So, I did the following thing: I have
> > written 2 pom.xml files with 2 different names (for example: pom.xml
> > and pom2.xml). When I want to build the .jar artifact I would use the
> > command 'mvn deploy' when I want the .war artifact I would use: 'mvn
> > -f pom2.xml' ---> after this, I encounter the problem I mentioned
> > earlier.
> >
> > Note that the artifactIds are different.
>
>
> You solution is simple: do not have one project, split it into multiple
> projects.
>
> A war file should not have any java code in it. So there is no need for you
> do be having two poms. You war project depends on the jar project and you
> are done.
>
> There are plenty of examples on how to do this in the freely available
> maven books at http://maven.apache.org/articles.html
>

Re: Use 2 pom.xml files with different names

Posted by Barrie Treloar <ba...@gmail.com>.
On 10 August 2015 at 23:22, Alex Ditu <di...@gmail.com> wrote:

> Ok, look what I am trying to achieve: I have a project with 2
> profileDeployments (it produces 2 types of artifacts: a jar and a war)
> but from the same sources. So, I did the following thing: I have
> written 2 pom.xml files with 2 different names (for example: pom.xml
> and pom2.xml). When I want to build the .jar artifact I would use the
> command 'mvn deploy' when I want the .war artifact I would use: 'mvn
> -f pom2.xml' ---> after this, I encounter the problem I mentioned
> earlier.
>
> Note that the artifactIds are different.


You solution is simple: do not have one project, split it into multiple
projects.

A war file should not have any java code in it. So there is no need for you
do be having two poms. You war project depends on the jar project and you
are done.

There are plenty of examples on how to do this in the freely available
maven books at http://maven.apache.org/articles.html

Re: Use 2 pom.xml files with different names

Posted by Jörg Schaible <jo...@swisspost.com>.
Hi Alex,

Alex Ditu wrote:

> Ok, look what I am trying to achieve: I have a project with 2
> profileDeployments (it produces 2 types of artifacts: a jar and a war)
> but from the same sources. So, I did the following thing: I have
> written 2 pom.xml files with 2 different names (for example: pom.xml
> and pom2.xml). When I want to build the .jar artifact I would use the
> command 'mvn deploy' when I want the .war artifact I would use: 'mvn
> -f pom2.xml' ---> after this, I encounter the problem I mentioned
> earlier.

We produce war and jar at once, but give the war a classifier ("webapp"). 
Might be an alternative for you also.

Cheers,
Jörg


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


Re: Use 2 pom.xml files with different names

Posted by Alex Ditu <di...@gmail.com>.
Ok, look what I am trying to achieve: I have a project with 2
profileDeployments (it produces 2 types of artifacts: a jar and a war)
but from the same sources. So, I did the following thing: I have
written 2 pom.xml files with 2 different names (for example: pom.xml
and pom2.xml). When I want to build the .jar artifact I would use the
command 'mvn deploy' when I want the .war artifact I would use: 'mvn
-f pom2.xml' ---> after this, I encounter the problem I mentioned
earlier.

Note that the artifactIds are different.


On Mon, Aug 10, 2015 at 4:38 PM, Greg Trasuk <tr...@stratuscom.com> wrote:
>
>> On Aug 10, 2015, at 7:12 AM, Alex Ditu <di...@gmail.com> wrote:
>>
>> Hello,
>>
>> I want to use pom.xml files for my project with 2 different names:
>> pom.xml and pom2.xml.
>> In order to select wich one to execute/use I use -f <pom-name> like this:
>>
>
> (…snip…)
>
>>
>> P.S. Don't ask me why I want to use 2 pom files, if anyone encountered
>> this situation and knows how to deal with it, help will be much
>> appreciated :)
>>
>
> The problem is, it’s kind of like asking “When I try to drive on the railroad tracks with my car, I keep falling off the rails - has anyone else encountered this problem?”  The fundamental concept of Maven is that an artifact is uniquely identified, and the pom file describes the artifact.  As such, when Maven puts the artifact into the local repository, it follows the naming conventions.
>
> You might be better off to describe what you’re actually trying to achieve, and then we can suggest how to do that.
>
> Cheers,
>
> Greg Trasuk
>
>
>
> ---------------------------------------------------------------------
> 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: Use 2 pom.xml files with different names

Posted by Greg Trasuk <tr...@stratuscom.com>.
> On Aug 10, 2015, at 7:12 AM, Alex Ditu <di...@gmail.com> wrote:
> 
> Hello,
> 
> I want to use pom.xml files for my project with 2 different names:
> pom.xml and pom2.xml.
> In order to select wich one to execute/use I use -f <pom-name> like this:
> 

(…snip…)

> 
> P.S. Don't ask me why I want to use 2 pom files, if anyone encountered
> this situation and knows how to deal with it, help will be much
> appreciated :)
> 

The problem is, it’s kind of like asking “When I try to drive on the railroad tracks with my car, I keep falling off the rails - has anyone else encountered this problem?”  The fundamental concept of Maven is that an artifact is uniquely identified, and the pom file describes the artifact.  As such, when Maven puts the artifact into the local repository, it follows the naming conventions.

You might be better off to describe what you’re actually trying to achieve, and then we can suggest how to do that.

Cheers,

Greg Trasuk



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