Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 114563 | Differences between
and this patch

Collapse All | Expand All

(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java (-16 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-18 Link Here
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import java.util.HashMap;
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.Map;
14
import java.util.Map;
17
15
18
import org.eclipse.ant.internal.ui.AntUIImages;
16
import org.eclipse.ant.internal.ui.AntUIImages;
Lines 296-322 Link Here
296
    }
294
    }
297
295
298
    public void performApply(ILaunchConfigurationWorkingCopy configuration) {
296
    public void performApply(ILaunchConfigurationWorkingCopy configuration) {
299
        HashSet kinds = new HashSet(4);
297
        StringBuffer buffer= new StringBuffer();
300
        if (!fAfterCleanTargetText.getText().equals(NOT_ENABLED)) {
298
        if (!fAfterCleanTargetText.getText().equals(NOT_ENABLED)) {
301
            kinds.add(IExternalToolConstants.BUILD_TYPE_FULL);
299
            buffer.append(IExternalToolConstants.BUILD_TYPE_FULL).append(',');
302
        } 
300
        } 
303
        if (!fManualBuildTargetText.getText().equals(NOT_ENABLED)){
301
        if (!fManualBuildTargetText.getText().equals(NOT_ENABLED)){
304
        	kinds.add(IExternalToolConstants.BUILD_TYPE_FULL);
302
            buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL).append(','); 
305
            kinds.add(IExternalToolConstants.BUILD_TYPE_INCREMENTAL); 
306
        } 
303
        } 
307
        if (!fAutoBuildTargetText.getText().equals(NOT_ENABLED)) {
304
        if (!fAutoBuildTargetText.getText().equals(NOT_ENABLED)) {
308
            kinds.add(IExternalToolConstants.BUILD_TYPE_AUTO);
305
            buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO).append(',');
309
        }
306
        }
310
        if (!fDuringCleanTargetText.getText().equals(NOT_ENABLED)) {
307
        if (!fDuringCleanTargetText.getText().equals(NOT_ENABLED)) {
311
            kinds.add(IExternalToolConstants.BUILD_TYPE_CLEAN);
308
            buffer.append(IExternalToolConstants.BUILD_TYPE_CLEAN);
312
        }
309
        }
313
        StringBuffer buffer= new StringBuffer();
314
		for(Iterator i = kinds.iterator(); i.hasNext();) {
315
			buffer.append(i.next());
316
			if(i.hasNext()) {
317
				buffer.append(',');
318
			}
319
		}
320
        configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
310
        configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
321
        
311
        
322
        String targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
312
        String targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
(-)src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java (-28 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 39-44 Link Here
39
public class BuilderCoreUtils {
39
public class BuilderCoreUtils {
40
40
41
	public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$
41
	public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$
42
	/**
43
	 * Constant added to the build command to determine if we are doing an incremental build after a clean
44
	 * 
45
	 * @since 3.7
46
	 */
47
	public static final String INC_CLEAN = "incclean"; //$NON-NLS-1$
42
48
43
	/**
49
	/**
44
	 * Constant used to find a builder using the 3.0-interim format
50
	 * Constant used to find a builder using the 3.0-interim format
Lines 113-153 Link Here
113
		return configuration;
119
		return configuration;
114
	}
120
	}
115
121
116
	public static void configureTriggers(ILaunchConfiguration config,
122
	public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException {
117
			ICommand newCommand) throws CoreException {
118
		newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
123
		newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
119
		newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD,
124
		newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);
120
				false);
121
		newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
125
		newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
122
		newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
126
		newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
123
		String buildKinds = config.getAttribute(
127
		Map args = newCommand.getArguments();
124
				IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null);
128
		String buildKinds = config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null);
125
		int[] triggers = BuilderCoreUtils.buildTypesToArray(buildKinds);
129
		int[] triggers = buildTypesToArray(buildKinds);
130
		boolean isfull = false, isinc = false;
126
		for (int i = 0; i < triggers.length; i++) {
131
		for (int i = 0; i < triggers.length; i++) {
127
			switch (triggers[i]) {
132
			switch (triggers[i]) {
128
			case IncrementalProjectBuilder.FULL_BUILD:
133
				case IncrementalProjectBuilder.FULL_BUILD:
129
				newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD,
134
					newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
130
						true);
135
					isfull = true;
131
				break;
136
					break;
132
			case IncrementalProjectBuilder.INCREMENTAL_BUILD:
137
				case IncrementalProjectBuilder.INCREMENTAL_BUILD:
133
				newCommand.setBuilding(
138
					newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
134
						IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
139
					isinc = true;
135
				break;
140
					break;
136
			case IncrementalProjectBuilder.AUTO_BUILD:
141
				case IncrementalProjectBuilder.AUTO_BUILD:
137
				newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD,
142
					newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true);
138
						true);
143
					break;
139
				break;
144
				case IncrementalProjectBuilder.CLEAN_BUILD:
140
			case IncrementalProjectBuilder.CLEAN_BUILD:
145
					newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true);
141
				newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD,
146
					break;
142
						true);
143
				break;
144
			}
147
			}
145
		}
148
		}
146
		if (!config.getAttribute(
149
		if(!isfull && isinc) {
147
				IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) {
150
			newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
151
			args.put(INC_CLEAN, Boolean.TRUE.toString());
152
			newCommand.setArguments(args);
153
		}
154
		if (!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) {
148
			ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
155
			ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
149
			copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED,
156
			copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
150
					true);
151
			copy.doSave();
157
			copy.doSave();
152
		}
158
		}
153
	}
159
	}
(-)src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java (-289 / +296 lines)
Lines 1-290 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Conway  - Bug 175186
10
 *     Matthew Conway  - Bug 175186
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.core.externaltools.internal.model;
12
package org.eclipse.core.externaltools.internal.model;
13
13
14
14
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
17
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
19
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
19
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
20
import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration;
20
import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration;
21
import org.eclipse.core.resources.ICommand;
21
import org.eclipse.core.resources.ICommand;
22
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProject;
24
import org.eclipse.core.resources.IProjectDescription;
24
import org.eclipse.core.resources.IProjectDescription;
25
import org.eclipse.core.resources.IResource;
25
import org.eclipse.core.resources.IResource;
26
import org.eclipse.core.resources.IResourceDelta;
26
import org.eclipse.core.resources.IResourceDelta;
27
import org.eclipse.core.resources.IResourceDeltaVisitor;
27
import org.eclipse.core.resources.IResourceDeltaVisitor;
28
import org.eclipse.core.resources.IncrementalProjectBuilder;
28
import org.eclipse.core.resources.IncrementalProjectBuilder;
29
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
31
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
34
import org.eclipse.debug.core.ILaunchManager;
34
import org.eclipse.debug.core.ILaunchManager;
35
import org.eclipse.osgi.util.NLS;
35
import org.eclipse.osgi.util.NLS;
36
import org.osgi.framework.Bundle;
36
import org.osgi.framework.Bundle;
37
37
38
/**
38
/**
39
 * This project builder implementation will run an external tool during the
39
 * This project builder implementation will run an external tool during the
40
 * build process. 
40
 * build process. 
41
 */
41
 */
42
public final class ExternalToolBuilder extends IncrementalProjectBuilder {
42
public final class ExternalToolBuilder extends IncrementalProjectBuilder {
43
	private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor {
43
	private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor {
44
		private boolean[] fTrueChange;
44
		private boolean[] fTrueChange;
45
		private IgnoreTeamPrivateChanges(boolean[] trueChange) {
45
		private IgnoreTeamPrivateChanges(boolean[] trueChange) {
46
			super();
46
			super();
47
			fTrueChange= trueChange;
47
			fTrueChange= trueChange;
48
		}
48
		}
49
		public boolean visit(IResourceDelta visitDelta) throws CoreException {
49
		public boolean visit(IResourceDelta visitDelta) throws CoreException {
50
			IResource resource= visitDelta.getResource();
50
			IResource resource= visitDelta.getResource();
51
			if (resource instanceof IFile) {
51
			if (resource instanceof IFile) {
52
				fTrueChange[0]= true;
52
				fTrueChange[0]= true;
53
				return false;
53
				return false;
54
			}
54
			}
55
			return true;
55
			return true;
56
		}
56
		}
57
	}
57
	}
58
58
59
	public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
59
	public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
60
60
61
	private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
61
	private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
62
	
62
	
63
	private static IProject buildProject= null;
63
	private static IProject buildProject= null;
64
    private static IResourceDelta buildDelta= null;
64
    private static IResourceDelta buildDelta= null;
65
	
65
	
66
	/* (non-Javadoc)
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
67
	 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
68
	 */
68
	 */
69
	protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {		
69
	protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {		
70
		if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) {
70
		if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) {
71
			return null;
71
			return null;
72
		}
72
		}
73
		
73
		
74
		ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[1]);
74
		ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[1]);
75
        if (config == null) {
75
        if (config == null) {
76
            throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
76
            throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
77
        }
77
        }
78
		IProject[] projectsWithinScope= null;
78
		IProject[] projectsWithinScope= null;
79
		IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config);
79
		IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config);
80
		if (resources != null) {
80
		if (resources != null) {
81
			projectsWithinScope= new IProject[resources.length];
81
			projectsWithinScope= new IProject[resources.length];
82
			for (int i = 0; i < resources.length; i++) {
82
			for (int i = 0; i < resources.length; i++) {
83
				projectsWithinScope[i]= resources[i].getProject();
83
				projectsWithinScope[i]= resources[i].getProject();
84
			}
84
			}
85
		}
85
		}
86
        boolean kindCompatible= commandConfiguredForKind(config, kind);
86
        boolean kindCompatible= commandConfiguredForKind(config, kind);
87
        if (kindCompatible && configEnabled(config)) {
87
        if (kindCompatible && configEnabled(config)) {
88
            doBuildBasedOnScope(resources, kind, config, monitor);
88
            doBuildBasedOnScope(resources, kind, config, args, monitor);
89
        }
89
        }
90
        
90
        
91
		return projectsWithinScope;
91
		return projectsWithinScope;
92
	}
92
	}
93
93
94
    private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) {
94
    private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) {
95
        try {
95
        try {
96
            if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
96
            if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
97
                ICommand command= getCommand();
97
                ICommand command= getCommand();
98
                //adapt the builder command to make use of the 3.1 support for setting command build kinds
98
                //adapt the builder command to make use of the 3.1 support for setting command build kinds
99
                //this will only happen once for builder/command defined before the support existed
99
                //this will only happen once for builder/command defined before the support existed
100
                BuilderCoreUtils.configureTriggers(config, command);
100
                BuilderCoreUtils.configureTriggers(config, command);
101
                IProjectDescription desc= getProject().getDescription();
101
                IProjectDescription desc= getProject().getDescription();
102
                ICommand[] commands= desc.getBuildSpec();
102
                ICommand[] commands= desc.getBuildSpec();
103
                int index= getBuilderCommandIndex(commands, command);
103
                int index= getBuilderCommandIndex(commands, command);
104
                if (index != -1) {
104
                if (index != -1) {
105
                    commands[index]= command;
105
                    commands[index]= command;
106
                    desc.setBuildSpec(commands);
106
                    desc.setBuildSpec(commands);
107
                    getProject().setDescription(desc, null);
107
                    getProject().setDescription(desc, null);
108
                    ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
108
                    ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
109
                    copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
109
                    copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
110
                    copy.doSave();
110
                    copy.doSave();
111
                }
111
                }
112
                return command.isBuilding(kind);
112
                return command.isBuilding(kind);
113
            }
113
            }
114
        } catch (CoreException e) {
114
        } catch (CoreException e) {
115
           ExternalToolsCore.log(e);
115
           ExternalToolsCore.log(e);
116
           return true;
116
           return true;
117
        }
117
        }
118
        return true;
118
        return true;
119
    }
119
    }
120
    
120
    
121
    private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) {
121
    private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) {
122
        Map commandArgs= command.getArguments();
122
        Map commandArgs= command.getArguments();
123
        if (commandArgs == null) {
123
        if (commandArgs == null) {
124
            return -1;
124
            return -1;
125
        }
125
        }
126
        String handle= (String) commandArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
126
        String handle= (String) commandArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
127
        if (handle == null) {
127
        if (handle == null) {
128
            return -1;
128
            return -1;
129
        }
129
        }
130
        for (int i = 0; i < buildSpec.length; ++i) {
130
        for (int i = 0; i < buildSpec.length; ++i) {
131
            ICommand buildSpecCommand= buildSpec[i];
131
            ICommand buildSpecCommand= buildSpec[i];
132
            if (ID.equals(buildSpecCommand.getBuilderName())) {
132
            if (ID.equals(buildSpecCommand.getBuilderName())) {
133
                Map buildSpecArgs= buildSpecCommand.getArguments();
133
                Map buildSpecArgs= buildSpecCommand.getArguments();
134
                if (buildSpecArgs != null) {
134
                if (buildSpecArgs != null) {
135
                    String buildSpecHandle= (String) buildSpecArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
135
                    String buildSpecHandle= (String) buildSpecArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
136
                    if (handle.equals(buildSpecHandle)) {
136
                    if (handle.equals(buildSpecHandle)) {
137
                        return i;
137
                        return i;
138
                    }
138
                    }
139
                }
139
                }
140
            }
140
            }
141
        }
141
        }
142
        return -1;
142
        return -1;
143
    }
143
    }
144
144
145
	/**
145
	/**
146
	 * Returns whether the given builder config is enabled or not.
146
	 * Returns whether the given builder config is enabled or not.
147
	 * 
147
	 * 
148
	 * @param config the config to examine
148
	 * @param config the config to examine
149
	 * @return whether the config is enabled
149
	 * @return whether the config is enabled
150
	 */
150
	 */
151
	private boolean configEnabled(ILaunchConfiguration config) {
151
	private boolean configEnabled(ILaunchConfiguration config) {
152
		try {
152
		try {
153
			return ExternalToolsCoreUtil.isBuilderEnabled(config);
153
			return ExternalToolsCoreUtil.isBuilderEnabled(config);
154
		} catch (CoreException e) {
154
		} catch (CoreException e) {
155
			ExternalToolsCore.log(e);
155
			ExternalToolsCore.log(e);
156
		}
156
		}
157
		return true;
157
		return true;
158
	}
158
	}
159
159
160
	private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
160
	private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, Map args, IProgressMonitor monitor) throws CoreException {
161
		boolean buildForChange = true;
161
		boolean buildForChange = true;
162
		if (kind != FULL_BUILD) { //scope not applied for full builds
162
		if (kind != FULL_BUILD) { //scope not applied for full builds
163
			if (resources != null && resources.length > 0) {
163
			if (resources != null && resources.length > 0) {
164
				buildForChange = buildScopeIndicatesBuild(resources);
164
				buildForChange = buildScopeIndicatesBuild(resources);
165
			}
165
			}
166
		}
166
		}
167
167
168
		if (buildForChange) {
168
		if (buildForChange) {
169
			launchBuild(kind, config, monitor);
169
			launchBuild(kind, config, args, monitor);
170
		}
170
		}
171
	}
171
	}
172
	
172
	
173
	private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
173
	private void launchBuild(int kind, ILaunchConfiguration config, Map args, IProgressMonitor monitor) throws CoreException {
174
		monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()}));
174
		monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()}));
175
		buildStarted(kind);
175
		buildStarted(kind, args);
176
		// The default value for "launch in background" is true in debug core. If
176
		// The default value for "launch in background" is true in debug core. If
177
		// the user doesn't go through the UI, the new attribute won't be set. This means
177
		// the user doesn't go through the UI, the new attribute won't be set. This means
178
		// that existing Ant builders will try to run in the background (and likely conflict with
178
		// that existing Ant builders will try to run in the background (and likely conflict with
179
		// each other) without migration.
179
		// each other) without migration.
180
		config= ExternalToolMigration.migrateRunInBackground(config);
180
		ILaunchConfiguration newconfig= ExternalToolMigration.migrateRunInBackground(config);
181
		config.launch(ILaunchManager.RUN_MODE, monitor);
181
		newconfig.launch(ILaunchManager.RUN_MODE, monitor);
182
		buildEnded();
182
		buildEnded();
183
	}
183
	}
184
184
185
	/**
185
	/**
186
	 * Returns the build type being performed if the
186
	 * Returns the build type being performed if the
187
	 * external tool is being run as a project builder.
187
	 * external tool is being run as a project builder.
188
	 * 
188
	 * 
189
	 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
189
	 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
190
	 */
190
	 */
191
	public static String getBuildType() {
191
	public static String getBuildType() {
192
		return buildType;
192
		return buildType;
193
	}
193
	}
194
	
194
	
195
	/**
195
	/**
196
	 * Returns the project that is being built and has triggered the current external
196
	 * Returns the project that is being built and has triggered the current external
197
	 * tool builder. <code>null</code> is returned if no build is currently occurring.
197
	 * tool builder. <code>null</code> is returned if no build is currently occurring.
198
	 * 
198
	 * 
199
	 * @return project being built or <code>null</code>.
199
	 * @return project being built or <code>null</code>.
200
	 */
200
	 */
201
	public static IProject getBuildProject() {
201
	public static IProject getBuildProject() {
202
		return buildProject;
202
		return buildProject;
203
	}
203
	}
204
204
205
    /**
205
    /**
206
     * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external
206
     * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external
207
     * tool builder. <code>null</code> is returned if no build is currently occurring.
207
     * tool builder. <code>null</code> is returned if no build is currently occurring.
208
     * 
208
     * 
209
     * @return resource delta for the build or <code>null</code>
209
     * @return resource delta for the build or <code>null</code>
210
     */
210
     */
211
    public static IResourceDelta getBuildDelta() {
211
    public static IResourceDelta getBuildDelta() {
212
        return buildDelta;
212
        return buildDelta;
213
    }
213
    }
214
    
214
    
215
	/**
215
	/**
216
	 * Stores the currently active build kind and build project when a build begins
216
	 * Stores the currently active build kind and build project when a build begins
217
	 * @param buildKind
217
	 * @param buildKind
218
	 */
218
	 * @param args the arguments passed into the builder
219
	private void buildStarted(int buildKind) {
219
	 */
220
		switch (buildKind) {
220
	private void buildStarted(int buildKind, Map args) {
221
			case IncrementalProjectBuilder.INCREMENTAL_BUILD :
221
		switch (buildKind) {
222
				buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
222
			case IncrementalProjectBuilder.INCREMENTAL_BUILD :
223
				buildDelta = getDelta(getProject());
223
				buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
224
				break;
224
				buildDelta = getDelta(getProject());
225
			case IncrementalProjectBuilder.FULL_BUILD :
225
				break;
226
				buildType = IExternalToolConstants.BUILD_TYPE_FULL;
226
			case IncrementalProjectBuilder.FULL_BUILD :
227
				break;
227
				if(args != null && args.containsKey(BuilderCoreUtils.INC_CLEAN)) {
228
			case IncrementalProjectBuilder.AUTO_BUILD :
228
					buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
229
				buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
229
					buildDelta = getDelta(getProject());
230
				buildDelta = getDelta(getProject());
230
				}
231
				break;
231
				else {
232
            case IncrementalProjectBuilder.CLEAN_BUILD :
232
					buildType = IExternalToolConstants.BUILD_TYPE_FULL;
233
                buildType = IExternalToolConstants.BUILD_TYPE_CLEAN;
233
				}
234
                break;
234
				break;
235
			default :
235
			case IncrementalProjectBuilder.AUTO_BUILD :
236
				buildType = IExternalToolConstants.BUILD_TYPE_NONE;
236
				buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
237
				break;
237
				buildDelta = getDelta(getProject());
238
		}
238
				break;
239
		buildProject= getProject();
239
            case IncrementalProjectBuilder.CLEAN_BUILD :
240
	}
240
                buildType = IExternalToolConstants.BUILD_TYPE_CLEAN;
241
	
241
                break;
242
	/**
242
			default :
243
	 * Clears the current build kind, build project and build delta when a build finishes.
243
				buildType = IExternalToolConstants.BUILD_TYPE_NONE;
244
	 */
244
				break;
245
	private void buildEnded() {
245
		}
246
		buildType= IExternalToolConstants.BUILD_TYPE_NONE;
246
		buildProject= getProject();
247
		buildProject= null;
247
	}
248
        buildDelta= null;
248
	
249
	}
249
	/**
250
	
250
	 * Clears the current build kind, build project and build delta when a build finishes.
251
	private boolean buildScopeIndicatesBuild(IResource[] resources) {
251
	 */
252
		for (int i = 0; i < resources.length; i++) {
252
	private void buildEnded() {
253
			IResourceDelta delta = getDelta(resources[i].getProject());
253
		buildType= IExternalToolConstants.BUILD_TYPE_NONE;
254
			if (delta == null) {
254
		buildProject= null;
255
				//project just added to the workspace..no previous build tree
255
        buildDelta= null;
256
				return true;
256
	}
257
			} 
257
	
258
			IPath path= resources[i].getProjectRelativePath();
258
	private boolean buildScopeIndicatesBuild(IResource[] resources) {
259
			IResourceDelta change= delta.findMember(path);
259
		for (int i = 0; i < resources.length; i++) {
260
			if (change != null) {
260
			IResourceDelta delta = getDelta(resources[i].getProject());
261
				final boolean[] trueChange= new boolean[1];
261
			if (delta == null) {
262
				trueChange[0]= false;
262
				//project just added to the workspace..no previous build tree
263
				try {
263
				return true;
264
					change.accept(new IgnoreTeamPrivateChanges(trueChange));
264
			} 
265
				} catch (CoreException e) {
265
			IPath path= resources[i].getProjectRelativePath();
266
					ExternalToolsCore.log("Internal error resolving changed resources during build", e); //$NON-NLS-1$
266
			IResourceDelta change= delta.findMember(path);
267
				}
267
			if (change != null) {
268
				
268
				final boolean[] trueChange= new boolean[1];
269
				return trueChange[0]; //filtered out team private changes
269
				trueChange[0]= false;
270
			}
270
				try {
271
		}
271
					change.accept(new IgnoreTeamPrivateChanges(trueChange));
272
		return false;
272
				} catch (CoreException e) {
273
	}
273
					ExternalToolsCore.log("Internal error resolving changed resources during build", e); //$NON-NLS-1$
274
    
274
				}
275
    protected void clean(IProgressMonitor monitor) throws CoreException {
275
				
276
	    ICommand command= getCommand();
276
				return trueChange[0]; //filtered out team private changes
277
        ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]);
277
			}
278
    	if (!configEnabled(config)) {
278
		}
279
	    	return;
279
		return false;
280
	    }
280
	}
281
        
281
    
282
        if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
282
    protected void clean(IProgressMonitor monitor) throws CoreException {
283
            //old behavior
283
	    ICommand command= getCommand();
284
            super.clean(monitor);
284
        ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]);
285
            return;
285
    	if (!configEnabled(config)) {
286
        }
286
	    	return;
287
	
287
	    }
288
		launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor);
288
        
289
    }
289
        if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
290
            //old behavior
291
            super.clean(monitor);
292
            return;
293
        }
294
	
295
		launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, null, monitor);
296
    }
290
}
297
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java (-19 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-20 Link Here
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
13
13
14
14
15
import java.util.HashSet;
16
import java.util.Iterator;
17
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
15
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
19
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
16
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
20
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
Lines 390-422 Link Here
390
        fVariables.setEnabled(haveOutputFile);
387
        fVariables.setEnabled(haveOutputFile);
391
        fAppend.setEnabled(haveOutputFile);
388
        fAppend.setEnabled(haveOutputFile);
392
    }
389
    }
393
    
390
394
	/* (non-Javadoc)
391
	/* (non-Javadoc)
395
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
392
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
396
	 */
393
	 */
397
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
394
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
398
        if (fCreateBuildScheduleComponent) {
395
        if (fCreateBuildScheduleComponent) {
399
        	HashSet kinds = new HashSet(4);
396
        	StringBuffer buffer= new StringBuffer();
400
    		if (afterClean.getSelection()) {
397
    		if (afterClean.getSelection()) {
401
    			kinds.add(IExternalToolConstants.BUILD_TYPE_FULL);
398
    			buffer.append(IExternalToolConstants.BUILD_TYPE_FULL).append(',');
402
    		} 
399
    		} 
403
    		if(manualBuild.getSelection()){
400
    		if (manualBuild.getSelection()){
404
    			kinds.add(IExternalToolConstants.BUILD_TYPE_FULL);
401
    			buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL).append(','); 
405
    			kinds.add(IExternalToolConstants.BUILD_TYPE_INCREMENTAL); 
406
    		} 
402
    		} 
407
    		if (autoBuildButton.getSelection()) {
403
    		if (autoBuildButton.getSelection()) {
408
    			kinds.add(IExternalToolConstants.BUILD_TYPE_AUTO);
404
    			buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO).append(',');
409
    		}
405
    		}
410
    		
406
    		
411
    		if (fDuringClean.getSelection()) {
407
    		if (fDuringClean.getSelection()) {
412
    			kinds.add(IExternalToolConstants.BUILD_TYPE_CLEAN);
408
    			buffer.append(IExternalToolConstants.BUILD_TYPE_CLEAN);
413
    		}
414
    		StringBuffer buffer= new StringBuffer();
415
    		for(Iterator i = kinds.iterator(); i.hasNext();) {
416
    			buffer.append(i.next());
417
    			if(i.hasNext()) {
418
    				buffer.append(',');
419
    			}
420
    		}
409
    		}
421
    		configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
410
    		configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
422
        }
411
        }

Return to bug 114563