12

Question

I want to refresh eclipse from the command line. How can I do this?

Context

Typically I run builds like this:

$ myCompaniesSpecialBuildScript.sh

This does some project setup that is needed for Eclipse to display a project without compilation errors.

This means that whenever I run a build my steps are:

  • $ myCompaniesSpecialBuildScript.sh
  • Inside eclipse:

    • Select the project I am working on -> Right click and select Refresh, OR
    • From the top menu: Project -> Clean... -> Clean all

Ideally, rather than doing this I would much rather run this from the command line:

$ myCompaniesSpecialBuildScript.sh && myScriptToRefreshEclipse.sh

I am looking into how to make myScriptToRefreshEclipse.sh.

Progress

This is what I have found so far:

  • IResource.refresh - Allows resources to be refreshed.
  • There is also ant task that can be used, that wraps IResource.refresh

It seems like both of these things need to run inside Eclipse's JVM. Is there a way to get this from the command line?

sixtyfootersdude
  • 25,859
  • 43
  • 145
  • 213
  • You can specify '-refresh' on the Eclipse command line when you start it, but there is nothing that will do a refresh without running Eclipse. – greg-449 May 28 '15 at 15:39

4 Answers4

1

In your workspace Preferences, enable General > Workspace > Refresh using native hooks or polling. That should cause Eclipse to automatically refresh the workspace resources when it is started the first time after they've been modified.

E-Riz
  • 31,431
  • 9
  • 97
  • 134
1

Although not a direct answer to the question, I believe the best integration with Eclipse can be achieved by running even the shell script from within Eclipse: Create an External Tool Configuration filling in the path to your script file, and then visit the "Refresh" tab to select which parts of the workspace should be refreshed after running the script.

Stephan Herrmann
  • 7,963
  • 2
  • 27
  • 38
0

I think the easiest way to achieve this without writing java code it's just write an ant build.xml file containing both:

  • the eclipse.refreshLocal task you previously linked
  • a task to launch the executionmyCompaniesSpecialBuildScript.s

Something like this

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <target name="nameofyourtarget">
      <exec executable="/bin/bash">
        <arg value="/path/to/myCompaniesSpecialBuildScript.sh"/>
      </exec>
      <eclipse.refreshLocal resource="MyProject/src" depth="infinite"/>
  </target>
</project>

Then you'll be able to launch the whole process from the command line with

ant nameofyourtarget
alessiop86
  • 1,285
  • 2
  • 19
  • 38
0

I tried to close this as a duplicate but I cannot because of the bounty.

However, please look here : Is there a way to refresh eclipse workspace from console before launching eclipse? and Refresh eclipse projects via command line

Community
  • 1
  • 1
crafter
  • 6,246
  • 1
  • 34
  • 46