Maven and Eclipse code organization -
i'm new maven, , after having read docs on maven site , sonatype's online maven book, i'm still not clear on how best organize things.
i have 2 apps, , b share code mylib. different developers work on apps , app b, released independently. before started maven, in eclipse, i'd have workspace apps , b , mylib. classpath app contained mylib. if made change in mylib, pressing run within eclipse, contained latest changes.
in maven, can create parent pom.xml, references app , mylib. makes mylib subdirectory of app a. how can keep 1 instance of mylib , not link building of apps , b?
we use svn our scm
thanks
you have multiple options, however, potentially simplest approach separate out mylib own maven project own life-cycle. benefit of approach can support having multiple versions of mylib , apps , b can reference different versions of mylib needed. if mylib , appa open in eclipse (and mylib references version of mylib have open), can build application in same manner did prior using maven.
this approach not mandate dependencies between directory structures of applications, go similar following:
/myapps/mylib
/myapps/appa
/myapps/appb
the downside approach maven not automatically build both appa , mylib (or appb , mylib) treated separate applications. however, may not of issue if applications using pre-defined , built versions of mylib (that have been uploaded local maven repository using "mvn install").
here example of poms these projects:
mylib:
<project> <modelversion>4.0.0</modelversion> <groupid>com.test</groupid> <artifactid>mylib</artifactid> <versioning>0.0.1</versioning> <packaging>jar</packaging> <name>mylib</name> ... </project>
appa:
<project> <modelversion>4.0.0</modelversion> <groupid>com.test</groupid> <artifactid>appa</artifactid> <packaging>jar</packaging> <name>appa</name> ... <dependencies> <groupid>com.text</groupid> <artifactid>mylib</artifactid</artifactid> <version>0.0.1</version> </dependencies> ... </project>
appb:
<project> <modelversion>4.0.0</modelversion> <groupid>com.test</groupid> <artifactid>appb</artifactid> <packaging>jar</packaging> <name>appb</name> ... <dependencies> <groupid>com.text</groupid> <artifactid>mylib</artifactid</artifactid> <version>0.0.1</version> </dependencies> ... </project>
if still want convenience of parent pom (one mvn package comment), create master pom in /myapps folder similar following:
<project> <groupid>com.test</groupid> <version>0.0.1</version> <artifactid>myapps</artifactid> <packaging>pom</packaging> <name>myapps</name> <modules> <module>shared</modules> <module>appa</modules> <module>appb</modules> </modules> </project>
this pom automatically build myapp, appa , appb. if desired create appa , appb specific pom (pom-appa.xml). not cleanest approach maven perspective, function. issue run if version of mylib not version on appa or appb dependent. in case appa or appb code compiling against version in maven repository (if version exists).
there many other options can use , have seen plenty of discussions on blogs , wikis best various scenarios. however, comes down works best , organization. long works , not going off building custom, non-portable maven solution, doing ok.
hopefully gives thoughts can use.
Comments
Post a Comment