简体   繁体   中英

Prevent Eclipse Java Builder from Compiling Java-Like Source

I'm in the process of writing an eclipse plugin for my programming language Whiley (see http://whiley.org ). The plugin is working reasonably well, although there's lots to do. Two pieces of the jigsaw are:

  • I've created a "Whiley Builder" by subclassing incremental project builder. This handles building and cleaning of "*.whiley" files.

  • I've created a content-type called "Whiley Source Files" for "*.whiley" files, which extends "org.eclipse.jdt.core.javaSource" (this follows Andrew Eisenberg's suggestion ).

The advantage of having the content-type extend javaSource is that it immediately fits into the package explorer, etc. In principle, I could fleshout ICompilationUnit to provide more useful info, although I haven't done that yet.

The disadvantage is that the Java builder is trying to compile my whiley files ... and it obviously can't. Originally, I had the Java Builder run first, then the Whiley builder. Superficially, this actually worked out quite well since all of the errors from the Java Builder were discarded by the Whiley Builder (for whiley files). However, I actually want the Whiley Builder to run first, as this is the best way for me to resolve dependencies between Java and Whiley files.

Which leads me to my question: can I stop the Java builder from trying to compile certain java-like resources? Specifically, in my case, those with the "*.whiley" extension. As an alternative, I was wondering whether my Whiley Builder could somehow update the resource delta to remove those files which it has dealt with.

Thoughts?

A quick way:

- Right-click on the offending item (Can be a file or folder)
- Select Java Build Path > Exclude

This adds an "exclude pattern" to your project the "pattern" is the exact path to the file or folder you right-clicked on.

To add a general pattern you can do:

- Project > Properties > Java Build Path > Source 
- Click on "Excluded"
- Click on "Edit"
- Click on "Add"

I like to add these exclude patterns:

**/*.Old
**/Old/             Trailing slash is required

These will get Eclipse to ignore all files with ".Old" extension and all folders called "Old".


Source : http://www.davekb.com/browse_programming_tips:eclipse_exclude_ignore_certian_files_extensions:txt

I'm not a Java guy so pardon the stuidity on this answer...

If you wrote the whiley builder can't you just change the "whiley spec" so that all whiley code must be enclosed in a Java comment block... there by preventing eclipse from compling it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM