Muhammad Hewedy
Muhammad Hewedy

Reputation: 30058

exclude some source files from being deployed to the container

I have a EJB project in Eclipse that contains two source folder "ejbModule" and "test"

where ejbModule contains source code for ejbs and test contains source code for the JUnit tests.

when I export the ear file using the right click -> export, I found the the .class files of the Junit tests are being exported within the EAR.

EDIT:

So, how I can prevent these source files from being deployed to the container, but in the same time I still need eclipse to consider them as source files??

(I am not asking the same question here: exclude files from jar or war in eclipse )

Upvotes: 3

Views: 5508

Answers (1)

Gábor Lipták
Gábor Lipták

Reputation: 9776

In eclipse 3.6 right click on the project, press properties. Then go to "deployment assembly" property page. There you can define, what are the parts of the project artifact.

Update: On the other hand, the GUI of WTP do not support everything the builder can handle. Source folders can be easily excluded, if you edit the .settings/org.eclipse.wst.common.component file (both in 3.5 and 3.6 eclipse) in project root. It does look like this (example from one of my projects):

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="gui">
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/aoprules/aoprules">
            <dependency-type>uses</dependency-type>
        </dependent-module>
        <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/base/base">
            <dependency-type>uses</dependency-type>
        </dependent-module>
        <property name="context-root" value="gui"/>
        <property name="java-output-path" value="/gui/target/classes"/>
    </wb-module>
</project-modules>

You simply remove the project-modules/wb-module/wb-resource element, which has the src/testas source-path attribute. Then refresh project.

Upvotes: 2

Related Questions