cescoffier / vertx-microservices-workshop

Vert.x Microservices Hand's on lab
http://escoffier.me/vertx-hol/
Apache License 2.0
331 stars 196 forks source link

How to build individual modules without installing parent project #19

Closed dancingfrog closed 7 years ago

dancingfrog commented 7 years ago

I began the tutorial believing that I would be able to compile, package and install individual modules as the tutorial chapters progressed. However, if one does not begin by running mvn clean install in the project root, which means installing all of the modules into the user's local repository, the only module that can be built in isolation is vertx-workshop-common.

This seems counter-intuitive to me, as many of the source files in each module are incomplete. Does this mean that the parent pom is configured to compile sources from the solutions directory and ignore the src directories of each individual modules?

Also, if I were beginning this project from scratch, how would I progressively create each module, knowing that the parent project could not be installed until all of the child modules were complete?

cescoffier commented 7 years ago

You actually can. The mvn install from the beginning is there to install all dependencies in your maven repo and build the common library (containing only utils).

This call does not build the solutions, the provided code compiles (even with all the holes).

dancingfrog commented 7 years ago

OK, so I think you are saying that vertx-workshop-common is the only module that needs to be installed initially... but if I cd in to vertx-workshop-common and then mvn install without having first run install for the parent project, the common module will build and install, but none of the other modules will. For instance quote-generator reports:

[ERROR] Failed to execute goal on project quote-generator: Could not resolve dependencies for project io.vertx.workshop:quote-generator:jar:1.0-SNAPSHOT: Failed to collect dependencies at io.vertx.workshop:vertx-workshop-common:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for io.vertx.workshop:vertx-workshop-common:jar:1.0-SNAPSHOT: Could not find artifact io.vertx.workshop:vertx-microservice-workshop:pom:1.0-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]

Is there any way (using mvn) to install only the utility code for the parent project so that the other modules can be built (and installed) one-by-one? At the moment mvn clean install from root creates all of these folders with jars containing what I can only guess are incomplete classes: .../.m2/repository/io/vertx/workshop/audit-service .../.m2/repository/io/vertx/workshop/compulsive-traders .../.m2/repository/io/vertx/workshop/portfolio-service .../.m2/repository/io/vertx/workshop/quote-generator .../.m2/repository/io/vertx/workshop/trader-dashboard .../.m2/repository/io/vertx/workshop/vertx-microservice-workshop .../.m2/repository/io/vertx/workshop/vertx-workshop-common

dancingfrog commented 7 years ago

Actually just figured out how to fix this error when building quote-generator:

[ERROR] Failed to execute goal on project quote-generator: Could not resolve dependencies for project io.vertx.workshop:quote-generator:jar:1.0-SNAPSHOT: Failed to collect dependencies at io.vertx.workshop:vertx-workshop-common:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for io.vertx.workshop:vertx-workshop-common:jar:1.0-SNAPSHOT: Could not find artifact io.vertx.workshop:vertx-microservice-workshop:pom:1.0-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots) -> [Help 1]

After cd'ing into vertx-workshop-common and running mvn clean install, these files are installed in the user's Maven repository:

.../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/_remote.repositories .../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/maven-metadata-local.xml .../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/vertx-workshop-common-1.0-SNAPSHOT.jar .../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/vertx-workshop-common-1.0-SNAPSHOT.pom .../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/vertx-workshop-common-1.0-SNAPSHOT-sources.jar .../.m2/repository/io/vertx/workshop/vertx-workshop-common/1.0-SNAPSHOT/vertx-workshop-common-1.0-SNAPSHOT-tests.jar .../.m2/repository/io/vertx/workshop/vertx-workshop-common/maven-metadata-local.xml

If I create a new directory in the maven repository:

.../.m2/repository/io/vertx/workshop/vertx-microservice-workshop/1.0-SNAPSHOT/

... then I can copy the parent pom file for this project into that directory, giving it the name vertx-microservice-workshop-1.0-SNAPSHOT.pom so that I end up with:

.../.m2/repository/io/vertx/workshop/vertx-microservice-workshop/1.0-SNAPSHOT/vertx-microservice-workshop-1.0-SNAPSHOT.pom

Now I'm able to run mvn clean package within the other modules and all the maven dependencies will resolve without error.

Thanks.

cescoffier commented 7 years ago

Actually, would you mind writing this in a .md file at the root of the project. I think it can be useful.