You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Shashank Tiwari <an...@gmail.com> on 2019/04/28 02:02:28 UTC

Importing pom in dependency management

Reading from the doc
<https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html>
 ,


   1.

   Do not attempt to import a pom that is defined in a submodule of the
   current pom. Attempting to do that will result in the build failing since
   it won't be able to locate the pom.
   2.

   Never declare the pom importing a pom as the parent (or grandparent,
   etc) of the target pom. There is no way to resolve the circularity and an
   exception will be thrown.

What is difference between the 2 points ? Are not they same ? Also, in
point 1 , why would maven not be able to locate pom ?

Re: Importing pom in dependency management

Posted by Jason Young <ja...@procentive.com>.
   - A multi-module project may contain other projects as submodules, so
   it's a _composite project_ consisting of itself non-recursively and of its
   submodules. That is, if I run `mvn install` on BigProject, then Maven will
   start a _reactor build_ that runs `mvn install` on BigProject itself
   non-recursively, and also runs `mvn install` on each sub-module
   _recursively_ (that is, also running their submodules, if any).
   - A project may have a parent from which it inherits stuff.

These are 2 separate relationships, or at least they used to be in previous
versions of Maven. That is, there can be a parent-child relationship
without a submodule relationship (consider that the official super project
does not contain your project as a sub-module), and a multi-module project
need not be the parent of its sub-project. A project could even declare its
own parent as a sub-module IIRC.

This distinction would be awfully useful in some cases, e.g. if you want to
change parents or sub-modules dynamically with a separate repo. However,
some plugins, even in the`org.apache.maven.plugins`groupId, _implicitly
assume_ that every sub-module will declare the multi-module project which
it is part of as a parent, and I would expect things to break if you
venture far from common Maven tutorials.

On Sat, Apr 27, 2019 at 9:20 PM Shashank Tiwari <
anddowncametherain@gmail.com> wrote:

> Okay , I understood that 1st point is for sub module and 2nd is for child
> module. But don;t sub module build before the parent ? In that case , won't
> maven be able to locate the pom as in 1st point ?
> Also, there is a 3rd point , which I need help in understanding : (from the
> same doc)
>
>
>
>    - When referring to artifacts whose poms have transitive dependencies
>    the project will need to specify versions of those artifacts as managed
>    dependencies. Not doing so will result in a build failure since the
>    artifact may not have a version specified. (This should be considered a
>    best practice in any case as it keeps the versions of artifacts from
>    changing from one build to the next).
>
> What does this mean?
>
> On Sun, Apr 28, 2019 at 7:32 AM Shashank Tiwari <
> anddowncametherain@gmail.com> wrote:
>
> > Reading from the doc
> > <
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
> >
> >  ,
> >
> >
> >    1.
> >
> >    Do not attempt to import a pom that is defined in a submodule of the
> >    current pom. Attempting to do that will result in the build failing
> since
> >    it won't be able to locate the pom.
> >    2.
> >
> >    Never declare the pom importing a pom as the parent (or grandparent,
> >    etc) of the target pom. There is no way to resolve the circularity
> and an
> >    exception will be thrown.
> >
> > What is difference between the 2 points ? Are not they same ? Also, in
> > point 1 , why would maven not be able to locate pom ?
> >
>

Re: Importing pom in dependency management

Posted by Shashank Tiwari <an...@gmail.com>.
Okay , I understood that 1st point is for sub module and 2nd is for child
module. But don;t sub module build before the parent ? In that case , won't
maven be able to locate the pom as in 1st point ?
Also, there is a 3rd point , which I need help in understanding : (from the
same doc)



   - When referring to artifacts whose poms have transitive dependencies
   the project will need to specify versions of those artifacts as managed
   dependencies. Not doing so will result in a build failure since the
   artifact may not have a version specified. (This should be considered a
   best practice in any case as it keeps the versions of artifacts from
   changing from one build to the next).

What does this mean?

On Sun, Apr 28, 2019 at 7:32 AM Shashank Tiwari <
anddowncametherain@gmail.com> wrote:

> Reading from the doc
> <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html>
>  ,
>
>
>    1.
>
>    Do not attempt to import a pom that is defined in a submodule of the
>    current pom. Attempting to do that will result in the build failing since
>    it won't be able to locate the pom.
>    2.
>
>    Never declare the pom importing a pom as the parent (or grandparent,
>    etc) of the target pom. There is no way to resolve the circularity and an
>    exception will be thrown.
>
> What is difference between the 2 points ? Are not they same ? Also, in
> point 1 , why would maven not be able to locate pom ?
>