Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,10 @@ private void basicBuild(final IBuildConfiguration buildConfiguration, final int
try {
final IProject project = buildConfiguration.getProject();
final ICommand[] commands;
if (project.isAccessible())
commands = ((Project) project).internalGetDescription().getBuildSpec(false);
else
if (project.isAccessible()) {
ProjectDescription description = ((Project) project).internalGetDescription();
commands = description == null ? null : description.getBuildSpec(false);
} else
commands = null;
int work = commands == null ? 0 : commands.length;
monitor.beginTask(NLS.bind(Messages.events_building_1, project.getFullPath()), work);
Expand Down Expand Up @@ -708,6 +709,9 @@ public ArrayList<BuilderPersistentInfo> createBuildersPersistentInfo(IProject pr
ArrayList<BuilderPersistentInfo> oldInfos = getBuildersPersistentInfo(project);

ProjectDescription desc = ((Project) project).internalGetDescription();
if (desc == null) {
return null;
}
ICommand[] commands = desc.getBuildSpec(false);
if (commands.length == 0)
return null;
Expand Down Expand Up @@ -1577,7 +1581,8 @@ public ISchedulingRule getRule(IBuildConfiguration buildConfiguration, int trigg
final ICommand[] commands;
if (project.isAccessible()) {
Set<ISchedulingRule> rules = new HashSet<>();
commands = ((Project) project).internalGetDescription().getBuildSpec(false);
ProjectDescription description = ((Project) project).internalGetDescription();
commands = description == null ? new ICommand[0] : description.getBuildSpec(false);
boolean hasNullBuildRule = false;
BuildContext context = new BuildContext(buildConfiguration);
for (int i = 0; i < commands.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.internal.events.BuildCommand;
import org.eclipse.core.internal.localstore.SafeChunkyInputStream;
import org.eclipse.core.internal.localstore.SafeChunkyOutputStream;
import org.eclipse.core.internal.utils.Messages;
import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
Expand Down Expand Up @@ -330,6 +334,8 @@ public ProjectDescription readOldDescription(IProject project) throws CoreExcept
* location should be used. In the case of failure, log the exception and
* return silently, thus reverting to using the default location and no
* dynamic references. The current format of the location file is:
*
* <pre>
* UTF - project location
* int - number of dynamic project references
* UTF - project reference 1
Expand All @@ -347,6 +353,19 @@ public ProjectDescription readOldDescription(IProject project) throws CoreExcept
* UTF - configName if hasConfigName
* ... repeat for number of referenced configurations
* ... repeat for number of build configurations with references
* since 3.23:
* bool - private flag if project should only be read from its private project configuration
* int - number of natures
* UTF - nature id
* ... repeated for N natures
* int - number of buildspecs
* byte - type of buildspec
* (type 1) UTF - name of builder
* int - number of arguments
* UTF arg key
* UTF arg value
* UTF - triggers string
* </pre>
*/
public void readPrivateDescription(IProject target, ProjectDescription description) {
IPath locationFile = locationFor(target).append(F_PROJECT_LOCATION);
Expand All @@ -357,6 +376,17 @@ public void readPrivateDescription(IProject target, ProjectDescription descripti
if (!file.exists())
return;
}
try {
readFromFile(target, description, file);
} catch (IOException e) {
//ignore - this is an old location file or an exception occurred
// closing the stream
}
}

@SuppressWarnings("deprecation")
public void readFromFile(IProject target, ProjectDescription description, java.io.File file) throws IOException {
description.setName(target.getName());
try (DataInputStream dataIn = new DataInputStream(new SafeChunkyInputStream(file, 500))) {
try {
String location = dataIn.readUTF();
Expand Down Expand Up @@ -408,9 +438,34 @@ public void readPrivateDescription(IProject target, ProjectDescription descripti
m.put(configName, refs);
}
description.setBuildConfigReferences(m);
} catch (IOException e) {
//ignore - this is an old location file or an exception occurred
// closing the stream
// read parts since 3.23
int natures = dataIn.readInt();
String[] natureIds = new String[natures];
for (int i = 0; i < natures; i++) {
natureIds[i] = dataIn.readUTF();
}
description.setNatureIds(natureIds);
int buildspecs = dataIn.readInt();
ICommand[] buildSpecData = new ICommand[buildspecs];
for (int i = 0; i < buildspecs; i++) {
BuildCommand command = new BuildCommand();
buildSpecData[i] = command;
int type = dataIn.read();
if (type == 1) {
command.setName(dataIn.readUTF());
int args = dataIn.readInt();
Map<String, String> map = new LinkedHashMap<>();
for (int j = 0; j < args; j++) {
map.put(dataIn.readUTF(), dataIn.readUTF());
}
command.setArguments(map);
String trigger = dataIn.readUTF();
if (!trigger.isEmpty()) {
ProjectDescriptionReader.parseBuildTriggers(command, trigger);
}
}
}
description.setBuildSpec(buildSpecData);
}
}

Expand All @@ -426,13 +481,25 @@ public void writePrivateDescription(IProject target) throws CoreException {
Workspace.clear(file);
//don't write anything if there is no interesting private metadata
ProjectDescription desc = ((Project) target).internalGetDescription();
try {
writeToFile(desc, file);
} catch (IOException e) {
String message = NLS.bind(Messages.resources_exSaveProjectLocation, target.getName());
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, message, e);
}
}

public void writeToFile(ProjectDescription desc, java.io.File file) throws IOException {
if (desc == null)
return;
final URI projectLocation = desc.getLocationURI();
final IProject[] prjRefs = desc.getDynamicReferences(false);
final String[] buildConfigs = desc.configNames;
final Map<String, IBuildConfiguration[]> configRefs = desc.getBuildConfigReferences(false);
if (projectLocation == null && prjRefs.length == 0 && buildConfigs.length == 0 && configRefs.isEmpty())
final String[] natureIds = desc.getNatureIds();
final ICommand[] buildSpec = desc.getBuildSpec(false);
if (projectLocation == null && prjRefs.length == 0 && buildConfigs.length == 0 && configRefs.isEmpty()
&& natureIds.length == 0 && buildSpec.length == 0)
return;
//write the private metadata file
try (SafeChunkyOutputStream output = new SafeChunkyOutputStream(file); DataOutputStream dataOut = new DataOutputStream(output);) {
Expand Down Expand Up @@ -470,10 +537,33 @@ public void writePrivateDescription(IProject target) throws CoreException {
}
}
}
// write parts since 3.23
dataOut.writeInt(natureIds.length);
for (String id : natureIds) {
dataOut.writeUTF(id);
}
dataOut.writeInt(buildSpec.length);
for (ICommand command : buildSpec) {
if (command instanceof BuildCommand b) {
dataOut.write(1);
dataOut.writeUTF(b.getName());
Map<String, String> arguments = b.getArguments();
dataOut.writeInt(arguments.size());
for (Entry<String, String> entry : arguments.entrySet()) {
dataOut.writeUTF(entry.getKey());
dataOut.writeUTF(entry.getValue());
}
if (ModelObjectWriter.shouldWriteTriggers(b)) {
dataOut.writeUTF(ModelObjectWriter.triggerString(b));
} else {
dataOut.writeUTF(""); //$NON-NLS-1$
}
} else {
dataOut.write(0);
}
}
dataOut.flush();
output.succeed();
} catch (IOException e) {
String message = NLS.bind(Messages.resources_exSaveProjectLocation, target.getName());
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, message, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ModelObjectWriter implements IModelObjectConstants {
* Returns the string representing the serialized set of build triggers for
* the given command
*/
private static String triggerString(BuildCommand command) {
static String triggerString(BuildCommand command) {
StringBuilder buf = new StringBuilder();
if (command.isBuilding(IncrementalProjectBuilder.AUTO_BUILD))
buf.append(TRIGGER_AUTO).append(',');
Expand Down Expand Up @@ -83,7 +83,7 @@ protected void write(BuildCommand command, XMLWriter writer) {
/**
* Returns whether the build triggers for this command should be written.
*/
private boolean shouldWriteTriggers(BuildCommand command) {
static boolean shouldWriteTriggers(BuildCommand command) {
//only write triggers if command is configurable and there exists a trigger
//that the builder does NOT respond to. I.e., don't write out on the default
//cases to avoid dirtying .project files unnecessarily.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,11 @@ protected void internalCopyProjectOnly(IResource destination, IProjectDescriptio
* @see #getActiveBuildConfig()
*/
IBuildConfiguration internalGetActiveBuildConfig() {
String configName = internalGetDescription().activeConfiguration;
ProjectDescription description = internalGetDescription();
if (description == null) {
return new BuildConfiguration(this, IBuildConfiguration.DEFAULT_CONFIG_NAME);
}
String configName = description.activeConfiguration;
try {
if (configName != null)
return getBuildConfig(configName);
Expand Down Expand Up @@ -827,6 +831,9 @@ public ProjectDescription internalGetDescription() {
*/
public IBuildConfiguration[] internalGetReferencedBuildConfigs(String configName, boolean includeMissing) {
ProjectDescription description = internalGetDescription();
if (description == null) {
return new IBuildConfiguration[0];
}
IBuildConfiguration[] refs = description.getAllBuildConfigReferences(this, configName, false);
Collection<IBuildConfiguration> configs = new LinkedHashSet<>(refs.length);
for (IBuildConfiguration ref : refs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.internal.events.BuildCommand;
Expand Down Expand Up @@ -546,6 +547,14 @@ public boolean hasPrivateChanges(ProjectDescription description) {
// Configuration level references
if (configRefsHaveChanges(dynamicConfigRefs, description.dynamicConfigRefs))
return true;
// has natures changed?
if (!Set.of(natures).equals(Set.of(description.natures))) {
return true;
}
// has buildspec changed?
if (!Objects.deepEquals(buildSpec, description.buildSpec)) {
return true;
}

return false;
}
Expand Down Expand Up @@ -978,4 +987,5 @@ private static IProject[] computeDynamicReferencesForProject(IBuildConfiguration
}
return result.toArray(new IProject[0]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,31 @@ private void endBuildTriggersElement(String elementName) {
state = S_BUILD_COMMAND;
BuildCommand command = (BuildCommand) objectStack.peek();
//presence of this element indicates the builder is configurable
String string = charBuffer.toString();
command.setConfigurable(true);
//clear all existing values
command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);

//set new values according to value in the triggers element
StringTokenizer tokens = new StringTokenizer(charBuffer.toString(), ","); //$NON-NLS-1$
while (tokens.hasMoreTokens()) {
String next = tokens.nextToken();
if (next.equalsIgnoreCase(TRIGGER_AUTO)) {
command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_CLEAN)) {
command.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_FULL)) {
command.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_INCREMENTAL)) {
command.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
}
parseBuildTriggers(command, string);
}
}

static void parseBuildTriggers(BuildCommand command, String string) {
command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
command.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);

// set new values according to value in the triggers element
StringTokenizer tokens = new StringTokenizer(string, ","); //$NON-NLS-1$
while (tokens.hasMoreTokens()) {
String next = tokens.nextToken();
if (next.equalsIgnoreCase(TRIGGER_AUTO)) {
command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_CLEAN)) {
command.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_FULL)) {
command.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
} else if (next.equalsIgnoreCase(TRIGGER_INCREMENTAL)) {
command.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Core Tests Resources
Bundle-SymbolicName: org.eclipse.core.tests.resources; singleton:=true
Bundle-Version: 3.11.900.qualifier
Bundle-Version: 3.11.1000.qualifier
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.core.tests.filesystem,
org.eclipse.core.tests.internal.alias,
Expand Down
2 changes: 1 addition & 1 deletion resources/tests/org.eclipse.core.tests.resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<version>4.37.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.core.tests.resources</artifactId>
<version>3.11.900-SNAPSHOT</version>
<version>3.11.1000-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Loading
Loading