Skip to content

Commit 200ca6a

Browse files
committed
Add support for creating workspace private project descriptions
Currently importing a project into eclipse requires the creation of a physical file name .project in the root of the project. this has several drawbacks for tools that automatically discover projects and import them for the user as it creates new files and possibly dirty their working tree. Other tools use a single folder for this purpose or don't require any permanent files in the working-tree itself. Even Eclipse has already such concept that is used when a project is located outside the workspace. This now adds a new feature called "workspace private project" that only holds the basic information in the location file in the workspace directory, any additional information might be needed to restore by a tool that uses workspace private projects.
1 parent a791b17 commit 200ca6a

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
5-
Bundle-Version: 3.22.200.qualifier
5+
Bundle-Version: 3.23.0.qualifier
66
Bundle-Activator: org.eclipse.core.resources.ResourcesPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java

+5
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ public ProjectDescription readOldDescription(IProject project) throws CoreExcept
347347
* UTF - configName if hasConfigName
348348
* ... repeat for number of referenced configurations
349349
* ... repeat for number of build configurations with references
350+
* since 3.23:
351+
* bool - private flag if project should only be read from its private project configuration
350352
*/
351353
public void readPrivateDescription(IProject target, ProjectDescription description) {
352354
IPath locationFile = locationFor(target).append(F_PROJECT_LOCATION);
@@ -408,6 +410,8 @@ public void readPrivateDescription(IProject target, ProjectDescription descripti
408410
m.put(configName, refs);
409411
}
410412
description.setBuildConfigReferences(m);
413+
// read parts since 4.36
414+
description.setWorkspacePrivate(dataIn.readBoolean());
411415
} catch (IOException e) {
412416
//ignore - this is an old location file or an exception occurred
413417
// closing the stream
@@ -470,6 +474,7 @@ public void writePrivateDescription(IProject target) throws CoreException {
470474
}
471475
}
472476
}
477+
dataOut.writeBoolean(desc.isWorkspacePrivate());
473478
output.succeed();
474479
} catch (IOException e) {
475480
String message = NLS.bind(Messages.resources_exSaveProjectLocation, target.getName());

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public void create(IProjectDescription description, int updateFlags, IProgressMo
326326
updateDescription();
327327
// make sure the .location file is written
328328
workspace.getMetaArea().writePrivateDescription(this);
329-
} else {
329+
} else if (!desc.isWorkspacePrivate()) {
330330
// write out the project
331331
writeDescription(IResource.FORCE);
332332
}

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescription.java

+11
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public class ProjectDescription extends ModelObject implements IProjectDescripti
124124
protected URI location = null;
125125
protected volatile String[] natures = EMPTY_STRING_ARRAY;
126126
protected URI snapshotLocation = null;
127+
private boolean privateFlag;
127128

128129
public ProjectDescription() {
129130
super();
@@ -978,4 +979,14 @@ private static IProject[] computeDynamicReferencesForProject(IBuildConfiguration
978979
}
979980
return result.toArray(new IProject[0]);
980981
}
982+
983+
@Override
984+
public boolean isWorkspacePrivate() {
985+
return privateFlag;
986+
}
987+
988+
@Override
989+
public void setWorkspacePrivate(boolean privateFlag) {
990+
this.privateFlag = privateFlag;
991+
}
981992
}

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IProjectDescription.java

+15
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ public interface IProjectDescription {
175175
*/
176176
ICommand newCommand();
177177

178+
/**
179+
* @return <code>true</code> if this project is only persisted in the private
180+
* workspace area
181+
* @since 3.23
182+
*/
183+
boolean isWorkspacePrivate();
184+
178185
/**
179186
* Sets the active configuration for the described project.
180187
* <p>
@@ -385,4 +392,12 @@ public interface IProjectDescription {
385392
* @see #getReferencedProjects()
386393
*/
387394
void setReferencedProjects(IProject[] projects);
395+
396+
/**
397+
* Sets the project to be only persisted into the private workspace area and not
398+
* into a physical <code>.project</code> file in the root of the project folder.
399+
*
400+
* @since 3.23
401+
*/
402+
void setWorkspacePrivate(boolean privateFlag);
388403
}

0 commit comments

Comments
 (0)