Over a million developers have joined DZone.

Exclude Source Files from Build in Eclipse

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

Sometimes I have source files in my project which I do not want to get compiled (or excluded from build). Because as I’m using the ‘managed make’, all source files matching certain extensions (like *.c) are automatically included into the build.

To exclude a file from build, I right-click on it to get to the properties. There I can select a check box to have it excluded from the build:

File Excluded from Build

File Excluded from Build

That file gets marked with an icon decorator:

File with Icon Decorator

File with Icon Decorator

To include it again into the build, simply remove that check mark again.

Another way is to use the ‘Exclude from build’ context menu which does the same:

Resource Configuration to Exclude from Build

Resource Configuration to Exclude from Build

Here it offers a dialog with the choice of build configurations where I can set a check mark from which build configuration I want to have it excluded:

Exclude from Build with Build Configurations

Exclude from Build with Build Configurations

This applies to all sources files to be compiled (usually *.c, *.cpp, *.cxx) and even linker files (*.ld, …). But what about header files????? The answer is that for header files it does not make any sense to exclude them: they are included by the compiler based on the include path (compiler) settings. So you cannot ‘exclude’ a single header file to be included. What you could do is to remove a path from the compiler settings, but then all header files will not be included.

Happy Excluding :-)

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.


Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}