2

I have this structure

          **** child C

Parent (A)


          **** child B

If I try to install child B without the parent, maven throws me an error, I know by convention I should have the parent installed in my repository, but is there any way for someone to pull the child and during the install process, install the Parent automatically?


@edit I'm going to try to be clearer, I have a project B that depends on project A (Project A is parent, same as in project B) I would like to be able to build in project B without needing the existence of A in my ' Local '(m2> repository) Repository, I would like some way, from B also install A, so that a developer who will act on B does not have to manually install A before

Progmatoz
  • 99
  • 9
  • This is unclear to me. Referencing the child automatically downloads the parent, _if it is available in the repository_. – J Fabian Meier Jul 11 '17 at 12:58
  • Your "structure" looks rather unstructured. ;) Whom do you mean by "_someone_" and "_pull_" is a SCM term, not a Maven term. – Gerold Broser Jul 11 '17 at 12:58
  • I'm going to try to be clearer, I have a project B that depends on project A (Project A is parent, same as in project B) I would like to be able to build in project B without needing the existence of A in my ' Local '(m2> repository) Repository, I would like some way, from B also install A, so that a developer who will act on B does not have to manually install A before. – Progmatoz Jul 11 '17 at 13:11
  • Which role plays `child A`? Is this "_project A_" you're referring to now or is _project A_ the parent you mentioned in your question. I think it becomes clearer if you update/edit the question accordingly. – Gerold Broser Jul 11 '17 at 13:17
  • Gerold, I'm sorry for the confusion, I've edited the question, – Progmatoz Jul 11 '17 at 13:20

1 Answers1

2

Long story short: No. (Not directly, at least.)

You can't run a build of a project from another one (but from an aggregator/multi-module project or with the Maven Invoker Plugin or a Groovy or Ant script or the like. But at the time you'd perform one of the latter in your case the dependency resolution would have been done already, and would have failed.)

You can do it the other way round like:

+- aggregator
   +- pom.xml: <packaging>pom, <module>parent (A), <module>child B
   |
   +- parent (A)
   |  +- pom.xml
   |
   +- child B
   |  +- pom.xml: <parent>parent (A), <relativePath>../parent (A), <dependency>parent (A)
   |
   +- child C
      +- pom.xml: <parent>parent (A), <relativePath>../parent (A)

Building aggregator builds parent (A) and child B in that order since the Maven Reactor recognizes the dependency of child B on parent (A).

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Sorry for the confusion, I'm still very young with maven, but your response was spectacular, thank you very much! – Progmatoz Jul 11 '17 at 14:02
  • @JeffSilva See [this answer](https://stackoverflow.com/a/30953905/1744774) for a few of the basic concepts and for links to good references/books. – Gerold Broser Jul 12 '17 at 22:48