Dynamic WebProject import another project and dependencies

713 views Asked by At

I have a dynamic web Project which we will call "project A" and another regular java project which we will call "project B" in eclipse. I have added project b to B to project A by going into project properties Properties -> Deployment Assembly -> Add -> Project. This works and adds the jar "project B.jar" to the project A/WEB-INF/lib folder. However the external jar files configured on "project B" are not included in "project B.jar". Additionally i have gone to project b -> Properties -> Java Build Path -> Order and Export and i have checked all required dependencies for "project B" and it still does not include them in the jar. How can i get eclipse to include these jars in the "project B.jar" file.

If you need to know I'm using eclipse Indigo and we are not using mavin for this project its only this one jar we need. Thanks in advance.

1

There are 1 answers

4
Hein Blöd On BEST ANSWER

You should turn project B into the faceted form (go to the project properties, "Project Facets" -> "Convert to faceted form..."). The only facets required are "Java" and "Utility Module". If I remember correctly, at that point Eclipse gives you a warning that those additional JAR dependencies may be missing at runtime of project A, giving you the quick fix option to add them as dependencies. This will add an attributes element to the .classpath file of project B for each referenced JAR file, for example like this:

<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.2.jar">
   <attributes>
      <attribute name="org.eclipse.jst.component.dependency" value="../"/>
   </attributes>
</classpathentry>

JARs that don't have to be included will get this attribute instead:

<attributes>
   <attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>

If you don't get said warnings, you might be able to just add the attributes element directly. Note: this is all for Eclipse Luna, but I know at least in Kepler it already worked like this.