39

Normally when we check Project->Build automatically, it will build when our project's source has change, But when i check this option my eclipse is always building-- about every 2 or 3 seconds-- no matter it has changes or not. I can see from the right bottom state bar show "building workspace...".

It's annoying that this behavior drive my eclispe really slow and the CPU is always in high usage.

I'm using eclipse 3.7 for java EE developers, m2e, maven integration for WTP, git plugin, subclipse and Google plugin for eclipse, checkstyle, findbugs, etc.

Any ideas?

P.S I'm on Win 7 with 8GB RAM

Mike
  • 3,515
  • 10
  • 44
  • 67
  • Either the build is stuck..never completes.. Is it start and stop.or always there? whenever u do any change. Slightest possible..it will isssue a build. – Mukul Goel Nov 25 '12 at 14:48
  • As i said it's not always building... it is building about every 2-3 seconds, continue a few seconds and then stop, and then building.... if i uncheck the "build automatically", it will stop. – Mike Nov 25 '12 at 14:51
  • 2
    it looks like, some part of your build process is modifying the source packages. go through your build process and you shall see it – Mukul Goel Nov 26 '12 at 10:52
  • 3
    I have discovered that that in **'Workspace':'Refresh using native hooks or polling'** is the culprit. May be worth to know. – Rudy Vissers Oct 13 '15 at 06:17
  • @Rudy You should transform your comment as an answer if this is a solution. This put me on the good path to resolve my problem. – L. G. Feb 22 '16 at 14:45
  • I had similar issue,what I did is ,unchecked "build automatically". Go to Project--Build Automatically – rajeev pani.. May 21 '17 at 07:20

15 Answers15

20

I just disabled my project to build automatically. Really annoying to be in that endless loop.

Goto:

Project->Build automatically

javaPlease42
  • 4,699
  • 7
  • 36
  • 65
18

I have seen this effect with an ant-based build before.

You probably have something in your maven build that outputs to one of the source folders or one of it subdirectories. Eclipse detects that a file has changed and starts a new build.

Axel
  • 13,939
  • 5
  • 50
  • 79
  • 1
    Thanks, root cause is i added annotation processing to my project which interfere the build process. – Mike Nov 27 '12 at 05:30
  • My maven build generated a "Version.java" into the source directory and thus triggering the endless loop. - keywords: resource, filtering, targetPath – koppor Nov 26 '13 at 13:41
  • 1
    Eclipse should add an option to explicitly exclude certain files or folders from being monitored for change, or from triggering a work-space build if they change (i.e. simply mark certain files as generated). If I remove generated sources from the build path, eclipse complains about compilation errors. If I add generated sources to the build path, eclipse's auto-build cycle triggers itself in a loop because generated sources changed during source generation (duuh!). If I ignore certain m2e plugins during incremental builds or disable auto-build all together, things get stale. It's a PAIN! – Robin479 Jul 10 '19 at 17:42
  • @Robin479: Good suggestion. I think you should create an issue/rfe in the eclipse issue tracker for this. – Axel Jul 11 '19 at 15:28
8

In Eclipse, I had to disable Preferences -> Workspace -> Refresh on access thanks to Rudy Vissers comment that put me on the right way.

L. G.
  • 9,642
  • 7
  • 56
  • 78
  • 3
    First, it was `Preferences ->` **General** `--> Work space -> Refresh on access`. Second, unchecking that option did not fix the problem for me. However, unchecking `Build automatically` **did* stop the constant building. On the third hand, now I'm going to need to build my project manually whenever I need to... not sure if I like this solution, since the whole point of an IDE is to do manual work for me. – Tihamer Jan 22 '19 at 17:18
5

I had the same problem.

At one "Project X" i added a Library-Reference with "Project->Properties->Android->Library->Add...".

The Library-Project is set on "Is Library"=true. In this Library-Project I selected under "Project->Properties->Project References" the other "Project X".

So the both projects were referenced to each other and causes like an endless loop when building automatically.

Remove one of this references to stop this endless building. Maybe this could help someone.

Patrick S.
  • 59
  • 1
  • 1
  • This works for me. I just right-clicked appcompat_v7 project > Properties > Android > Uncheck "Is Library". – Tom Lenc Jul 12 '15 at 21:05
5

A source of this problem could be a target folder that marked as a source folder.

To check and resolve this: Right click on project -> Preferences -> Java Build Path -> Source

Remove target folder from the list if present

Denis.Kipchakbaev
  • 970
  • 15
  • 24
  • I use cxf-codegen-plugin to generate SOAP endpoints into target/generated-sources/ and it works nice without problems with constant running build. – andrej Aug 16 '16 at 14:01
  • If you do this, eclipse might complain about compilation problems due to missing sources. – Robin479 Jul 10 '19 at 17:44
2

Extending javaPlease42 answer as

Project-> Properties -> WorkSpace -> Build automatically

Uncheck and then "apply and close"


Unrelated to above answer, I have moved by project to c drive, I found my shared drive was too slow to access which was also one of the cause of showing building again and again with slow process

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
0

Both projects are referenced to each other.

Go to "Project->Properties->Project References" and check the references on both projects, that causes like an endless loop when building automatically.

0

We found that when using Chrome for our debugging, we end up with a boatload of chromedriver .exe processes running. Large numbers of them seem to cause eclipse to choke.

Restarting your computer will fix this, but you can also run a command to kill them. On my current test system, the driver is:

chromedriver-win32-2.14.exe

The command prompt kill command to kill all running copies of a process is:

taskkill /F /IM

So, for me, to kill the offending processes:

Open the command prompt

Enter:

taskkill /F /IM chromedriver-win32-2.14.exe

After the spurious processes are eliminated, eclipse returns to being a happy puppy ... until the next time excessive processes are generated.

Community
  • 1
  • 1
liantics
  • 9
  • 1
0

For me it is worked as follows in Eclipse Kepler.

Right click on project / Click on Project Menu -> Properties -> Java Build Path -> Select Source Tab -> Remove Target folder if it is there

The above one did the job for me but before that I have tried following ways which didn't worked.

  • End eclipse process and restart
  • Restart java.exe process
  • Restart my PC
Code Spark
  • 178
  • 14
0

I had the same issue on Ubuntu Linux. When it happened, my packages started to appear as folders rather than a single package name with square icon.

When I looked into eclipse folder, I had one extra folder named C:. This was a mirror image of my computer folder structure with installation of eclipse folder. I just removed this folder and restarted and it worked like a charm.

Try it if you see extra folder. Of course, delete at your own risk.

Piyush Patel
  • 1,646
  • 1
  • 14
  • 26
0

See Rudy Vissor above, I de-selected "Refresh using native hooks or polling" and "Refresh on access" and the issue resolved immediately. Using Eclipse Oxygen 4.7.1

0

In out case, the issue was caused by generating the JAXB classes in the target directory (which is good) but with the project's main JAVA package. So say the project's main JAVA package is com.proj then the JAXB classes had the com.proj.schema package. This somehow confused Eclipse (Jenkins was fine). Changing the JAXB classes' package from com.proj.schema to schema did the trick.

Erikson
  • 549
  • 1
  • 6
  • 16
0

I think I have found a way to enable Refresh using native hooks or polling, Refresh on access and Build automatically, without endless compilation loop.

Please follow the below steps to do so

Right-click the project->Properties->C/C++ Build->Refresh Policy tab->Add only the Debug or Release directory, not the whole project.

Surenthar Pitchai
  • 1,231
  • 15
  • 18
0

If you generate code that needs to be included in the Build Path then you can add the following to your pom.xml so that Eclipse Maven Builder skips the generating step for the relevant plug-in. See the <ignore/> part.

In below example, it was the openapi-generator-maven-plugin that caused the target/generated-sources to be re-generated and since that folder was added to the Build Path it caused Eclipse to re-generate the code again, and again, and again...

You can still manually generate the code anytime you like by menu Run As-> Maven generate-sources

        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.openapitools</groupId>
                                        <artifactId>openapi-generator-maven-plugin</artifactId>
                                        <versionRange>[0.1,)</versionRange>
                                        <goals>
                                            <goal>generate</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                                                                
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>     
Stef
  • 93
  • 1
  • 12
0

An old question I know but have just come across another possible cause of this problem:

I have a separate source tree for some code-generated classes, which by it's nature is slightly cyclically dependant on the 'main' source tree.

Every so often Eclipse seemed to get its knickers in a twist and was constantly refreshing the code-generated tree and re-building.

For some reason the output folder of the code-generated tree was set to 'default' rather than target/classes as the main and test folders were. Setting it the same seemed to prevent the constant rebuilds.

Right-click source folder > Java Build Path > Output folder > Edit...

stridecolossus
  • 1,449
  • 10
  • 24