maven-example-en icon indicating copy to clipboard operation
maven-example-en copied to clipboard

Extra parent level in ch-multi example code

Open apjanke opened this issue 9 years ago • 6 comments

In the chapter on Multi-Module Projects, it describes a parent project in simple-parent, and two submodules underneath it. The example POMs in the chapter text itself reflect this structure. But in the examples/ch-multi code, there are three levels of modules: the simple-parent project itself is a submodule underneath the top ch-multi directory, which has its own POM.

This also has the effect of breaking the mvn jetty:run example for me if I'm following the examples in the book exactly. In the section "Building the Multimodule Project", it has you run mvn clean install from the simple-parent directory. But if I do this, the later mvn jetty:run call from within simple-webapp/ will fail with an error like this.

[ERROR] Failed to execute goal on project simple-webapp: Could not resolve dependencies for project org.sonatype.mavenbook.multi:simple-webapp:war:0.8-SNAPSHOT: Failed to collect dependencies at org.sonatype.mavenbook.multi:simple-weather:jar:0.8-SNAPSHOT: Failed to read artifact descriptor for org.sonatype.mavenbook.multi:simple-weather:jar:0.8-SNAPSHOT: Could not find artifact org.sonatype.mavenbook.multi:parent:pom:0.8-SNAPSHOT -> [Help 1]

I think this is because it's not finding that extra top-level artifact. If I move up to ch-multi and do mvn clean install from there, then the mvn jetty:run example works.

This seems a little confusing. Should the examples code be changed to match the two-level structure in the chapter text?

apjanke avatar May 26 '15 11:05 apjanke

I agree I had the same issue-- thanks for pointing it out.

unk1911 avatar Jul 17 '15 13:07 unk1911

This is a requirement from the publishing point of view. I might be able to change that if I try to refactor the publishing process. Let me think about this for a bit.

mosabua avatar Jul 18 '15 23:07 mosabua

Anything new? At least this bug shows up when searching for "org.sonatype.mavenbook.multi:parent:pom:0.8-SNAPSHOT" when people encuounter this problem.

Workaround by @apjanke worked :) Thanks.

Zaijo avatar Nov 14 '17 13:11 Zaijo

@Zaijo I was able to run jetty but I know from Chapter 5 that the yahoo weather api changed. If you are using weather.yahooapis.com as your weather endpoint, it is retiring soon. Please update your apps to use weather via YQL https://query.yahooapis.com. So you will have to change two files to make it work: YahooRetriever (https://gist.github.com/fabeliflow/ef8e499a892d1b276e4d05f6b8bfe20b) and YahooParser (https://gist.github.com/fabeliflow/f5396e66ca40434e0ad566770b53c51c).

I hope this helps! The book is great (and free) but it needs some updates!

Fabio

fabeliflow avatar Dec 02 '17 22:12 fabeliflow

@apjanke And thanks for not letting me waste a day trying to figure that out! This proves that you really have to follow Maven's convention! Once you do, then it runs smooth!

fabeliflow avatar Dec 02 '17 22:12 fabeliflow

same problem, half a day wasted :( Thx @apjanke for saving my life

sophister avatar Dec 06 '19 11:12 sophister