markvgti
markvgti

Reputation: 4619

Want to share common code between two GAE maven projects imported into Eclipse

I have two GAE Java projects, A and B. I want to use some of the mature classes from A in B (and continue to use them in A too, of course). Both projects were created using maven and then imported into Eclipse (in my mind, this kinda makes maven primary and Eclipse secondary :-).

What is the best way to do this, keeping maven primary?

I expect the solution will be something like:

Hopefully after this I will be able to run and test (mostly done by running mvn appengine:devserver) A and B independent of each other.

My knowledge of maven is limited, so how do I create (e.g., which archetype to use) this project C such that:

If there is a better but completely different solution, I wouldn't mind considering that too.

Configuration:

Thanks!!

Upvotes: 0

Views: 178

Answers (2)

GlobalVariable
GlobalVariable

Reputation: 181

Regarding which archetype to use, you can use maven quickstart archetype:

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart

from : https://maven.apache.org/archetype/maven-archetype-bundles/maven-archetype-quickstart/

Upvotes: 1

OhadR
OhadR

Reputation: 8869

Well, you are very close to the "good and right" solution. You write it in your question :-)

  • Create a new maven project C.
  • Move the common classes to C. Build (mvn clean install) project C. As a result, the JAR will be in your local repo.
  • Now you can include C as dependency in pom.xml of A and B.

Note that as you have mentioned, if there is any change in project C, projects A+B will have to be re-compiled.

Of course, C.JAR is ready for use and there it is not related to any IDE such as Eclipse.

Upvotes: 1

Related Questions