3

We are developing an Eclipse product made of several plugins, some of them developed by us. Each of our plugins has be defined as an Eclipse plugin project in workspace and has two folders, source and test. Recently I noticed that we are delivering the test classes to the user like the our source classes. Now I want to remove the test classes from the result of our product. Shall I remove the test folder from the Java build path (see the attachment)? And what else I should do to don't deploy our tests to the end-user?

enter image description here

To build the project we are using the eclipse standard ant script to create our zip file. I don't find where can I exclude test files. Here is the the Ant script:

<property name="allElementsFile" value="${eclipse.pdebuild.scripts}/productBuild/allElements.xml"/>
<import file="${eclipse.pdebuild.scripts}/build.xml"/>
<property name="pluginPath" value=""/>
<property name="pluginList" value=""/>
<property name="featureList" value=""/>
<property name="includeLaunchers" value="true"/>
<property name="generatedBuildProperties" value=""/>
<condition property="nestedInclusions" value="true">
    <istrue value="${p2.gathering}" />
</condition>

<!-- ===================================================================== -->
<!-- main entry point to setup, fetch, generate, build etc. Use -->
<!-- the customTargets.xml to modify the build behaviour. -->
<!-- ===================================================================== -->
<target name="main" description="the main build target">    
    <antcall target="preBuild" />
    <antcall target="processRepos"/>
    <antcall target="generateFeature"> <!-- Generate the feature to drive the fetch -->
        <param name="verify" value="false"/>
    </antcall>
    <antcall target="fetch" />
    <antcall target="generateFeature"> <!-- We are calling generate feature a second time so that we can get the pack / unpack clause fixed -->
        <param name="verify" value="true"/>
    </antcall> 
    <antcall target="generate" /> 
    <antcall target="process" /> 
    <antcall target="assemble" />
    <antcall target="package" />
    <antcall target="postBuild" />
</target>

<!-- ===================================================================== -->
<!-- Generate a container feature based on the product file                -->
<!-- The plugin or feature containing the .product file will need to exist -->
<!-- already, use preSetup or postSetup to fetch it if necessary           -->
<!-- ===================================================================== -->
<target name="generateFeature">
    <eclipse.generateFeature
        featureId="org.eclipse.pde.build.container.feature"
        buildDirectory="${buildDirectory}"
        baseLocation="${baseLocation}"
        productFile="${product}"
        verify="${verify}"
        pluginPath="${transformedRepoLocation}${path.separator}${pluginPath}"
        configInfo="${configs}"
        pluginList="${pluginList}"
        featureList="${featureList}"
        includeLaunchers="${includeLaunchers}"
        buildPropertiesFile="${generatedBuildProperties}"
        nestedInclusions="${nestedInclusions}"
        filterP2Base="${filterP2Base}"
    />
</target>


</project>
oberlies
  • 11,503
  • 4
  • 63
  • 110
Govan
  • 2,079
  • 4
  • 31
  • 53
  • 1
    I'm not overly familiar with developing Eclipse plugins, but I'd suggest the place you need to fix this is in the *deployment* phase of your build. I would presume you need your unit tests on your build path for development purposes. I won't post an answer, as I suspect someone can advise how to do this. – Duncan Jones Feb 06 '13 at 14:14

2 Answers2

1

This is an issue with your deployment procedure/script. Are you using Eclipse to build the jar ? It should not have to do with the build path, you should keep your test source in the build path if you use Eclipse to code them. Usually a deployment procedure using Ant or Maven will exclude the test classes from the result (jar, war, ...). It is also advisable to automatically run the tests before the jar is created.

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
  • We are using ant and ant is calling out product file to create the deploy-able zip file. We are running our tests separately with another ant-script. when I am looking to the plugin.xml files we have chosen to not include the test folder to source or binary build. But the test.class files are there anyway! – Govan Feb 06 '13 at 14:32
  • Ok so you need to read the Ant script and find the part where it takes the java files and there you should exclude the test files. – Christophe Roussy Feb 06 '13 at 14:33
  • I don't find where to exclude the test folders! Could you look at the the script. I added it to the question! – Govan Feb 06 '13 at 14:50
  • Your build.xml is including another build.xml `` – Christophe Roussy Feb 06 '13 at 14:53
  • The build file was the pde-standard build file. I found the place to control this but not via reading ant files. – Govan Feb 08 '13 at 08:18
0

To remove test files (if you defined for every plugin project a source folder and a test folder) from the code while building a pde project using pde ant scripts you should remove the test folder from the build.properties of that project. The build.properties is a part of plugin.xml

Govan
  • 2,079
  • 4
  • 31
  • 53