Ich habe meinen Standard-Git-Repository-Ordner verschoben und hatte daher das gleiche Problem. Ich habe meine eigene Klasse geschrieben, um den Eclipse-Standort zu verwalten, und damit die Standortdatei geändert.
File locationfile
= new File("<workspace>"
+"/.metadata/.plugins/org.eclipse.core.resources/.projects/"
+"<project>/"
+".location");
byte data[] = Files.readAllBytes(locationfile.toPath());
EclipseLocation eclipseLocation = new EclipseLocation(data);
eclipseLocation.changeUri("<new path to project>");
byte newData[] = eclipseLocation.getData();
Files.write(locationfile.toPath(),newData);
Hier meine EclipseLocation-Klasse:
public class EclipseLocation {
private byte[] data;
private int length;
private String uri;
public EclipseLocation(byte[] data) {
init(data);
}
public String getUri() {
return uri;
}
public byte[] getData() {
return data;
}
private void init(byte[] data) {
this.data = data;
this.length = (data[16] * 256) + data[17];
this.uri = new String(data,18,length);
}
public void changeUri(String newUri) {
int newLength = newUri.length();
byte[] newdata = new byte[data.length + newLength - length];
int y = 0;
int x = 0;
//header
while(y < 16) newdata[y++] = data[x++];
//length
newdata[16] = (byte) (newLength / 256);
newdata[17] = (byte) (newLength % 256);
y += 2;
x += 2;
//Uri
for(int i = 0;i < newLength;i++)
{
newdata[y++] = (byte) newUri.charAt(i);
}
x += length;
//footer
while(y < newdata.length) newdata[y++] = data[x++];
if(y != newdata.length)
throw new IndexOutOfBoundsException();
if(x != data.length)
throw new IndexOutOfBoundsException();
init(newdata);
}
}