7

I'm looking for a solution that will force Eclipse to automatically clean a project before I run it (I'm talking about running a project using just Eclipse- no Maven, no Ant). For building I already have a Maven configuration, but sometimes I run the build directly from Eclipse as well and this is when I need that cleaning.

s4nk
  • 647
  • 1
  • 9
  • 18
  • just curious... what needs to be cleaned? Do you have a tool that's not behaving well? – Chris Gerken Oct 08 '12 at 11:58
  • Well, I have two projects- one of them is a standard Android project and the other one is a project containing unit tests. In the POM files of these projects I've configured code coverage with EMMA. Now the problem is that when I run the build with Maven it checks the code coverage, thus the resulting artifact of the main project contains EMMA-instrumented code. If then I try to run just the test project, directly from Eclipse, it uses the main project artifact built previously with Maven (since it depends on it). This causes the test project to fail due to some unresolved EMMA classes. – s4nk Oct 08 '12 at 12:17

1 Answers1

3

Shouldn't it be possible to have Maven and Eclipse use different class folders, e.g. /target for the Maven build and /bin for the Eclipse internal Java compiler? If so, you should be able to have 2 different launch configurations running the code from 2 different locations.

Second alternative: You can create a small Ant script to clear the target directory. That Ant script can be run from inside Eclipse, so a workaround is running the Ant launch configuration first and your Java launch configuration afterwards. To make this a one-step process, please install the launch groups feature from Eclipse CDT (you only need that small feature, not the whole CDT!), then you can create a "batch" like launch configuration from the other two launch configurations. Now everything is inside Eclipse with a single launch configuration!

Community
  • 1
  • 1
Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
  • The second solution works perfectly. I've just modified it a bit by using Maven instead of Ant. Thanks! – s4nk Oct 09 '12 at 08:22