Assume Project B needs Project A to compile and execute... We want whenever we modify code in A then B to get updated...An easy solution would be to add the jar of A in WEB-INF/lib of B but every time we changed A we would need a manual "mvn package".
Senario: B depends on A
Assuming the pom.xml of A is:
<project ... <groupId>CORE</groupId> <artifactId>CORE</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>CORE</name> ... </project>
install A on local repository:
on A: mvn clean install
Add a as dependency on B's pom.xml:
<dependency> <groupId>CORE</groupId> <artifactId>CORE</artifactId> <version>0.0.1-SNAPSHOT</version> <scope>compile</scope> </dependency>
updates B's Eclipse project configurations (i.e. .classpath):
$ mvn eclipse:eclipse
[INFO] B's .classpath after 'mvn eclipse:eclipse':
<classpath> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="src/test/java" output="target/test-classes"/> <classpathentry kind="output" path="target/classes"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="M2_REPO/com/maventest/mytest/1.0-SNAPSHOT/mytest-1.0-SNAPSHOT.jar"/> <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/> </classpath>The above .classpath has been taken from the references...
[TROUBLESHOOTING] If you get in Eclipse the error "Classpath entry ... jar will not be exported or published. Runtime ClassNotFoundExceptions may result."
On Eclipse right click on project B > Java Build Path > Order and Export > select all!Also check Java Build Path > Libraries and
Deployment Assembly
[TROUBLESHOOTING] If you the in Eclipse the error "implementation of version 6.0 of project facet"
edit .settings/org.eclipse.wst.common.project.facet.ccore.xml (assuming you use Tomcat 7.0):<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <runtime name="Apache Tomcat v7.0"/> <fixed facet="jst.web"/> <fixed facet="wst.jsdt.web"/> <fixed facet="java"/> <installed facet="jst.web" version="3.0"/> <installed facet="wst.jsdt.web" version="1.0"/> <installed facet="jst.jsf" version="2.0"/> <installed facet="java" version="1.6"/> </faceted-project>
[TROUBLESHOOTING] If you get the error that the MANIFEST.MF is not found...
Edit pom.xml in orer the build process to create the MANIFEST.MF (it must exist - see wikipedia):<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <!-- <configuration> --> <!-- <useDefaultManifestFile>true</useDefaultManifestFile> --> <!-- </configuration> --> <configuration> <archive> <index>true</index> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <mode>development</mode> <url>${pom.url}</url> <key>value</key> </manifestEntries> </archive> </configuration> </plugin>
No comments:
Post a Comment