Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using eclipse and maven, is there a quick way to mark all target and subfolder as derived?

I am working with eclipse on a mavenized project which has a significant number of modules/subfolders/maven subprojects.

Whenever I look for a resource, or make any kind of research, it shows me every occurrences in every project times two because of the target folder...

example:

projectA/projectB/src/main/resource/.../Foo.xml

if I look for a string that is in foo.xml, it will show:

  • projectA/projectB/src/main/resource/.../Foo.xml
  • projectB/src/main/resource/.../Foo.xml
  • projectA/projectB/target/main/resource/.../Foo.xml
  • projectA/projectB/target/main/resource/.../Foo.xml

That is a lot for one file. Besides, let say that the prohectA is intended to create a pom, not a war, a jar, or a ear... The problem is now, that if I select this entry, I won't be able to use the auto completion, or the inspect element functionality (that I can't work without!!!!). Even worse: if i select a target directory, my changes will be overwritten on the next maven build...

What can I do? At the moment, I am just paying attention, but it is kind of painful... And I do not have time to go through all the project to mark them one by one as derived (basically around 1000 clicks), so they do not come up in the searches... Besides, the target folder would just appear again after the next maven build.

Any ideas?

The perfect way would be to have eclipse recognize the subproject nature of these, and not show the different occurrences... and maybe setup a filter for the target resources... I do not know if it is possible.

I am also willing to write a tiny script, if people are kind enough to explain to me what eclipse files it should modify in order to accomplish this.

like image 330
alith Avatar asked Nov 04 '22 02:11

alith


2 Answers

Import the sub projects as separate Eclipse projects (this should happen automatically if you point the Maven import wizard at the master project directory). Keep the master project closed if you're not editing it. You'll still get the target folder version of resources, but at least only once.

like image 144
artbristol Avatar answered Nov 10 '22 13:11

artbristol


You could use that AutoDeriv Eclipse plugin here AutoDeriv to list the paths you'd like to mark as derived, and discard from research etc. as you would do in a .gitignore file.

Once it's done, resources are always correctly marked as derived, even after a maven clean/install.

[edit] You can write rules at workspace level, to handle several projects at once. Exclusion rules allows you to mark everything as derived, except for a peculiar folder or file. Since the 1.3.0 version, Eclipse decoration helps you to quickly see the effects of the plugin.

Disclamer, I wrote it =)

like image 30
johan d Avatar answered Nov 10 '22 12:11

johan d