Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 188199 Details for
Bug 114563
[launching] [builders] Ant Builder doesn't build with Target set to <default>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
update
ant-build_A.patch (text/plain), 33.50 KB, created by
Michael Rennie
on 2011-02-02 17:10:41 EST
(
hide
)
Description:
update
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2011-02-02 17:10:41 EST
Size:
33.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ant.ui >Index: Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java,v >retrieving revision 1.10 >diff -u -r1.10 AntBuilderTargetsTab.java >--- Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java 24 Jan 2011 17:55:58 -0000 1.10 >+++ Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java 2 Feb 2011 21:56:52 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2011 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,8 +11,6 @@ > package org.eclipse.ant.internal.ui.launchConfigurations; > > import java.util.HashMap; >-import java.util.HashSet; >-import java.util.Iterator; > import java.util.Map; > > import org.eclipse.ant.internal.ui.AntUIImages; >@@ -296,27 +294,19 @@ > } > > public void performApply(ILaunchConfigurationWorkingCopy configuration) { >- HashSet kinds = new HashSet(4); >+ StringBuffer buffer= new StringBuffer(); > if (!fAfterCleanTargetText.getText().equals(NOT_ENABLED)) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_FULL); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_FULL).append(','); > } > if (!fManualBuildTargetText.getText().equals(NOT_ENABLED)){ >- kinds.add(IExternalToolConstants.BUILD_TYPE_FULL); >- kinds.add(IExternalToolConstants.BUILD_TYPE_INCREMENTAL); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL).append(','); > } > if (!fAutoBuildTargetText.getText().equals(NOT_ENABLED)) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_AUTO); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO).append(','); > } > if (!fDuringCleanTargetText.getText().equals(NOT_ENABLED)) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_CLEAN); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_CLEAN); > } >- StringBuffer buffer= new StringBuffer(); >- for(Iterator i = kinds.iterator(); i.hasNext();) { >- buffer.append(i.next()); >- if(i.hasNext()) { >- buffer.append(','); >- } >- } > configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString()); > > String targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS); >#P org.eclipse.core.externaltools >Index: src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java,v >retrieving revision 1.2 >diff -u -r1.2 BuilderCoreUtils.java >--- src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java 14 Oct 2009 14:04:59 -0000 1.2 >+++ src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java 2 Feb 2011 21:56:53 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -39,6 +39,12 @@ > public class BuilderCoreUtils { > > public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$ >+ /** >+ * Constant added to the build command to determine if we are doing an incremental build after a clean >+ * >+ * @since 3.7 >+ */ >+ public static final String INC_CLEAN = "incclean"; //$NON-NLS-1$ > > /** > * Constant used to find a builder using the 3.0-interim format >@@ -113,41 +119,41 @@ > return configuration; > } > >- public static void configureTriggers(ILaunchConfiguration config, >- ICommand newCommand) throws CoreException { >+ public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException { > newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false); >- newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, >- false); >+ newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false); > newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false); > newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false); >- String buildKinds = config.getAttribute( >- IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null); >- int[] triggers = BuilderCoreUtils.buildTypesToArray(buildKinds); >+ Map args = newCommand.getArguments(); >+ String buildKinds = config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null); >+ int[] triggers = buildTypesToArray(buildKinds); >+ boolean isfull = false, isinc = false; > for (int i = 0; i < triggers.length; i++) { > switch (triggers[i]) { >- case IncrementalProjectBuilder.FULL_BUILD: >- newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, >- true); >- break; >- case IncrementalProjectBuilder.INCREMENTAL_BUILD: >- newCommand.setBuilding( >- IncrementalProjectBuilder.INCREMENTAL_BUILD, true); >- break; >- case IncrementalProjectBuilder.AUTO_BUILD: >- newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, >- true); >- break; >- case IncrementalProjectBuilder.CLEAN_BUILD: >- newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, >- true); >- break; >+ case IncrementalProjectBuilder.FULL_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true); >+ isfull = true; >+ break; >+ case IncrementalProjectBuilder.INCREMENTAL_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true); >+ isinc = true; >+ break; >+ case IncrementalProjectBuilder.AUTO_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true); >+ break; >+ case IncrementalProjectBuilder.CLEAN_BUILD: >+ newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true); >+ break; > } > } >- if (!config.getAttribute( >- IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) { >+ if(!isfull && isinc) { >+ newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true); >+ args.put(INC_CLEAN, Boolean.TRUE.toString()); >+ newCommand.setArguments(args); >+ } >+ if (!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) { > ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy(); >- copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, >- true); >+ copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true); > copy.doSave(); > } > } >Index: src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java,v >retrieving revision 1.1 >diff -u -r1.1 ExternalToolBuilder.java >--- src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java 8 Oct 2009 18:18:51 -0000 1.1 >+++ src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java 2 Feb 2011 21:56:53 -0000 >@@ -1,290 +1,297 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- * Matthew Conway - Bug 175186 >- *******************************************************************************/ >-package org.eclipse.core.externaltools.internal.model; >- >- >-import java.util.Map; >- >-import org.eclipse.core.externaltools.internal.ExternalToolsCore; >-import org.eclipse.core.externaltools.internal.IExternalToolConstants; >-import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; >-import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration; >-import org.eclipse.core.resources.ICommand; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IProjectDescription; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IResourceDelta; >-import org.eclipse.core.resources.IResourceDeltaVisitor; >-import org.eclipse.core.resources.IncrementalProjectBuilder; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >-import org.eclipse.debug.core.ILaunchManager; >-import org.eclipse.osgi.util.NLS; >-import org.osgi.framework.Bundle; >- >-/** >- * This project builder implementation will run an external tool during the >- * build process. >- */ >-public final class ExternalToolBuilder extends IncrementalProjectBuilder { >- private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor { >- private boolean[] fTrueChange; >- private IgnoreTeamPrivateChanges(boolean[] trueChange) { >- super(); >- fTrueChange= trueChange; >- } >- public boolean visit(IResourceDelta visitDelta) throws CoreException { >- IResource resource= visitDelta.getResource(); >- if (resource instanceof IFile) { >- fTrueChange[0]= true; >- return false; >- } >- return true; >- } >- } >- >- public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$; >- >- private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE; >- >- private static IProject buildProject= null; >- private static IResourceDelta buildDelta= null; >- >- /* (non-Javadoc) >- * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) >- */ >- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { >- if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) { >- return null; >- } >- >- ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[1]); >- if (config == null) { >- throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null); >- } >- IProject[] projectsWithinScope= null; >- IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config); >- if (resources != null) { >- projectsWithinScope= new IProject[resources.length]; >- for (int i = 0; i < resources.length; i++) { >- projectsWithinScope[i]= resources[i].getProject(); >- } >- } >- boolean kindCompatible= commandConfiguredForKind(config, kind); >- if (kindCompatible && configEnabled(config)) { >- doBuildBasedOnScope(resources, kind, config, monitor); >- } >- >- return projectsWithinScope; >- } >- >- private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) { >- try { >- if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >- ICommand command= getCommand(); >- //adapt the builder command to make use of the 3.1 support for setting command build kinds >- //this will only happen once for builder/command defined before the support existed >- BuilderCoreUtils.configureTriggers(config, command); >- IProjectDescription desc= getProject().getDescription(); >- ICommand[] commands= desc.getBuildSpec(); >- int index= getBuilderCommandIndex(commands, command); >- if (index != -1) { >- commands[index]= command; >- desc.setBuildSpec(commands); >- getProject().setDescription(desc, null); >- ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy(); >- copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true); >- copy.doSave(); >- } >- return command.isBuilding(kind); >- } >- } catch (CoreException e) { >- ExternalToolsCore.log(e); >- return true; >- } >- return true; >- } >- >- private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) { >- Map commandArgs= command.getArguments(); >- if (commandArgs == null) { >- return -1; >- } >- String handle= (String) commandArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE); >- if (handle == null) { >- return -1; >- } >- for (int i = 0; i < buildSpec.length; ++i) { >- ICommand buildSpecCommand= buildSpec[i]; >- if (ID.equals(buildSpecCommand.getBuilderName())) { >- Map buildSpecArgs= buildSpecCommand.getArguments(); >- if (buildSpecArgs != null) { >- String buildSpecHandle= (String) buildSpecArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE); >- if (handle.equals(buildSpecHandle)) { >- return i; >- } >- } >- } >- } >- return -1; >- } >- >- /** >- * Returns whether the given builder config is enabled or not. >- * >- * @param config the config to examine >- * @return whether the config is enabled >- */ >- private boolean configEnabled(ILaunchConfiguration config) { >- try { >- return ExternalToolsCoreUtil.isBuilderEnabled(config); >- } catch (CoreException e) { >- ExternalToolsCore.log(e); >- } >- return true; >- } >- >- private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { >- boolean buildForChange = true; >- if (kind != FULL_BUILD) { //scope not applied for full builds >- if (resources != null && resources.length > 0) { >- buildForChange = buildScopeIndicatesBuild(resources); >- } >- } >- >- if (buildForChange) { >- launchBuild(kind, config, monitor); >- } >- } >- >- private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { >- monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()})); >- buildStarted(kind); >- // The default value for "launch in background" is true in debug core. If >- // the user doesn't go through the UI, the new attribute won't be set. This means >- // that existing Ant builders will try to run in the background (and likely conflict with >- // each other) without migration. >- config= ExternalToolMigration.migrateRunInBackground(config); >- config.launch(ILaunchManager.RUN_MODE, monitor); >- buildEnded(); >- } >- >- /** >- * Returns the build type being performed if the >- * external tool is being run as a project builder. >- * >- * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants. >- */ >- public static String getBuildType() { >- return buildType; >- } >- >- /** >- * Returns the project that is being built and has triggered the current external >- * tool builder. <code>null</code> is returned if no build is currently occurring. >- * >- * @return project being built or <code>null</code>. >- */ >- public static IProject getBuildProject() { >- return buildProject; >- } >- >- /** >- * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external >- * tool builder. <code>null</code> is returned if no build is currently occurring. >- * >- * @return resource delta for the build or <code>null</code> >- */ >- public static IResourceDelta getBuildDelta() { >- return buildDelta; >- } >- >- /** >- * Stores the currently active build kind and build project when a build begins >- * @param buildKind >- */ >- private void buildStarted(int buildKind) { >- switch (buildKind) { >- case IncrementalProjectBuilder.INCREMENTAL_BUILD : >- buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; >- buildDelta = getDelta(getProject()); >- break; >- case IncrementalProjectBuilder.FULL_BUILD : >- buildType = IExternalToolConstants.BUILD_TYPE_FULL; >- break; >- case IncrementalProjectBuilder.AUTO_BUILD : >- buildType = IExternalToolConstants.BUILD_TYPE_AUTO; >- buildDelta = getDelta(getProject()); >- break; >- case IncrementalProjectBuilder.CLEAN_BUILD : >- buildType = IExternalToolConstants.BUILD_TYPE_CLEAN; >- break; >- default : >- buildType = IExternalToolConstants.BUILD_TYPE_NONE; >- break; >- } >- buildProject= getProject(); >- } >- >- /** >- * Clears the current build kind, build project and build delta when a build finishes. >- */ >- private void buildEnded() { >- buildType= IExternalToolConstants.BUILD_TYPE_NONE; >- buildProject= null; >- buildDelta= null; >- } >- >- private boolean buildScopeIndicatesBuild(IResource[] resources) { >- for (int i = 0; i < resources.length; i++) { >- IResourceDelta delta = getDelta(resources[i].getProject()); >- if (delta == null) { >- //project just added to the workspace..no previous build tree >- return true; >- } >- IPath path= resources[i].getProjectRelativePath(); >- IResourceDelta change= delta.findMember(path); >- if (change != null) { >- final boolean[] trueChange= new boolean[1]; >- trueChange[0]= false; >- try { >- change.accept(new IgnoreTeamPrivateChanges(trueChange)); >- } catch (CoreException e) { >- ExternalToolsCore.log("Internal error resolving changed resources during build", e); //$NON-NLS-1$ >- } >- >- return trueChange[0]; //filtered out team private changes >- } >- } >- return false; >- } >- >- protected void clean(IProgressMonitor monitor) throws CoreException { >- ICommand command= getCommand(); >- ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]); >- if (!configEnabled(config)) { >- return; >- } >- >- if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >- //old behavior >- super.clean(monitor); >- return; >- } >- >- launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor); >- } >+/******************************************************************************* >+ * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Matthew Conway - Bug 175186 >+ *******************************************************************************/ >+package org.eclipse.core.externaltools.internal.model; >+ >+ >+import java.util.Map; >+ >+import org.eclipse.core.externaltools.internal.ExternalToolsCore; >+import org.eclipse.core.externaltools.internal.IExternalToolConstants; >+import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; >+import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration; >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceDelta; >+import org.eclipse.core.resources.IResourceDeltaVisitor; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.osgi.util.NLS; >+import org.osgi.framework.Bundle; >+ >+/** >+ * This project builder implementation will run an external tool during the >+ * build process. >+ */ >+public final class ExternalToolBuilder extends IncrementalProjectBuilder { >+ private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor { >+ private boolean[] fTrueChange; >+ private IgnoreTeamPrivateChanges(boolean[] trueChange) { >+ super(); >+ fTrueChange= trueChange; >+ } >+ public boolean visit(IResourceDelta visitDelta) throws CoreException { >+ IResource resource= visitDelta.getResource(); >+ if (resource instanceof IFile) { >+ fTrueChange[0]= true; >+ return false; >+ } >+ return true; >+ } >+ } >+ >+ public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$; >+ >+ private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE; >+ >+ private static IProject buildProject= null; >+ private static IResourceDelta buildDelta= null; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { >+ if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) { >+ return null; >+ } >+ >+ ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[1]); >+ if (config == null) { >+ throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null); >+ } >+ IProject[] projectsWithinScope= null; >+ IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config); >+ if (resources != null) { >+ projectsWithinScope= new IProject[resources.length]; >+ for (int i = 0; i < resources.length; i++) { >+ projectsWithinScope[i]= resources[i].getProject(); >+ } >+ } >+ boolean kindCompatible= commandConfiguredForKind(config, kind); >+ if (kindCompatible && configEnabled(config)) { >+ doBuildBasedOnScope(resources, kind, config, args, monitor); >+ } >+ >+ return projectsWithinScope; >+ } >+ >+ private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) { >+ try { >+ if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >+ ICommand command= getCommand(); >+ //adapt the builder command to make use of the 3.1 support for setting command build kinds >+ //this will only happen once for builder/command defined before the support existed >+ BuilderCoreUtils.configureTriggers(config, command); >+ IProjectDescription desc= getProject().getDescription(); >+ ICommand[] commands= desc.getBuildSpec(); >+ int index= getBuilderCommandIndex(commands, command); >+ if (index != -1) { >+ commands[index]= command; >+ desc.setBuildSpec(commands); >+ getProject().setDescription(desc, null); >+ ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy(); >+ copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true); >+ copy.doSave(); >+ } >+ return command.isBuilding(kind); >+ } >+ } catch (CoreException e) { >+ ExternalToolsCore.log(e); >+ return true; >+ } >+ return true; >+ } >+ >+ private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) { >+ Map commandArgs= command.getArguments(); >+ if (commandArgs == null) { >+ return -1; >+ } >+ String handle= (String) commandArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE); >+ if (handle == null) { >+ return -1; >+ } >+ for (int i = 0; i < buildSpec.length; ++i) { >+ ICommand buildSpecCommand= buildSpec[i]; >+ if (ID.equals(buildSpecCommand.getBuilderName())) { >+ Map buildSpecArgs= buildSpecCommand.getArguments(); >+ if (buildSpecArgs != null) { >+ String buildSpecHandle= (String) buildSpecArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE); >+ if (handle.equals(buildSpecHandle)) { >+ return i; >+ } >+ } >+ } >+ } >+ return -1; >+ } >+ >+ /** >+ * Returns whether the given builder config is enabled or not. >+ * >+ * @param config the config to examine >+ * @return whether the config is enabled >+ */ >+ private boolean configEnabled(ILaunchConfiguration config) { >+ try { >+ return ExternalToolsCoreUtil.isBuilderEnabled(config); >+ } catch (CoreException e) { >+ ExternalToolsCore.log(e); >+ } >+ return true; >+ } >+ >+ private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, Map args, IProgressMonitor monitor) throws CoreException { >+ boolean buildForChange = true; >+ if (kind != FULL_BUILD) { //scope not applied for full builds >+ if (resources != null && resources.length > 0) { >+ buildForChange = buildScopeIndicatesBuild(resources); >+ } >+ } >+ >+ if (buildForChange) { >+ launchBuild(kind, config, args, monitor); >+ } >+ } >+ >+ private void launchBuild(int kind, ILaunchConfiguration config, Map args, IProgressMonitor monitor) throws CoreException { >+ monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()})); >+ buildStarted(kind, args); >+ // The default value for "launch in background" is true in debug core. If >+ // the user doesn't go through the UI, the new attribute won't be set. This means >+ // that existing Ant builders will try to run in the background (and likely conflict with >+ // each other) without migration. >+ ILaunchConfiguration newconfig= ExternalToolMigration.migrateRunInBackground(config); >+ newconfig.launch(ILaunchManager.RUN_MODE, monitor); >+ buildEnded(); >+ } >+ >+ /** >+ * Returns the build type being performed if the >+ * external tool is being run as a project builder. >+ * >+ * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants. >+ */ >+ public static String getBuildType() { >+ return buildType; >+ } >+ >+ /** >+ * Returns the project that is being built and has triggered the current external >+ * tool builder. <code>null</code> is returned if no build is currently occurring. >+ * >+ * @return project being built or <code>null</code>. >+ */ >+ public static IProject getBuildProject() { >+ return buildProject; >+ } >+ >+ /** >+ * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external >+ * tool builder. <code>null</code> is returned if no build is currently occurring. >+ * >+ * @return resource delta for the build or <code>null</code> >+ */ >+ public static IResourceDelta getBuildDelta() { >+ return buildDelta; >+ } >+ >+ /** >+ * Stores the currently active build kind and build project when a build begins >+ * @param buildKind >+ * @param args the arguments passed into the builder >+ */ >+ private void buildStarted(int buildKind, Map args) { >+ switch (buildKind) { >+ case IncrementalProjectBuilder.INCREMENTAL_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; >+ buildDelta = getDelta(getProject()); >+ break; >+ case IncrementalProjectBuilder.FULL_BUILD : >+ if(args != null && args.containsKey(BuilderCoreUtils.INC_CLEAN)) { >+ buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL; >+ buildDelta = getDelta(getProject()); >+ } >+ else { >+ buildType = IExternalToolConstants.BUILD_TYPE_FULL; >+ } >+ break; >+ case IncrementalProjectBuilder.AUTO_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_AUTO; >+ buildDelta = getDelta(getProject()); >+ break; >+ case IncrementalProjectBuilder.CLEAN_BUILD : >+ buildType = IExternalToolConstants.BUILD_TYPE_CLEAN; >+ break; >+ default : >+ buildType = IExternalToolConstants.BUILD_TYPE_NONE; >+ break; >+ } >+ buildProject= getProject(); >+ } >+ >+ /** >+ * Clears the current build kind, build project and build delta when a build finishes. >+ */ >+ private void buildEnded() { >+ buildType= IExternalToolConstants.BUILD_TYPE_NONE; >+ buildProject= null; >+ buildDelta= null; >+ } >+ >+ private boolean buildScopeIndicatesBuild(IResource[] resources) { >+ for (int i = 0; i < resources.length; i++) { >+ IResourceDelta delta = getDelta(resources[i].getProject()); >+ if (delta == null) { >+ //project just added to the workspace..no previous build tree >+ return true; >+ } >+ IPath path= resources[i].getProjectRelativePath(); >+ IResourceDelta change= delta.findMember(path); >+ if (change != null) { >+ final boolean[] trueChange= new boolean[1]; >+ trueChange[0]= false; >+ try { >+ change.accept(new IgnoreTeamPrivateChanges(trueChange)); >+ } catch (CoreException e) { >+ ExternalToolsCore.log("Internal error resolving changed resources during build", e); //$NON-NLS-1$ >+ } >+ >+ return trueChange[0]; //filtered out team private changes >+ } >+ } >+ return false; >+ } >+ >+ protected void clean(IProgressMonitor monitor) throws CoreException { >+ ICommand command= getCommand(); >+ ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]); >+ if (!configEnabled(config)) { >+ return; >+ } >+ >+ if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) { >+ //old behavior >+ super.clean(monitor); >+ return; >+ } >+ >+ launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, null, monitor); >+ } > } >\ No newline at end of file >#P org.eclipse.ui.externaltools >Index: External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java,v >retrieving revision 1.49 >diff -u -r1.49 ExternalToolsBuilderTab.java >--- External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java 24 Jan 2011 17:55:59 -0000 1.49 >+++ External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java 2 Feb 2011 21:56:53 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,9 +12,6 @@ > package org.eclipse.ui.externaltools.internal.launchConfigurations; > > >-import java.util.HashSet; >-import java.util.Iterator; >- > import org.eclipse.core.externaltools.internal.IExternalToolConstants; > import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil; > import org.eclipse.core.resources.IResource; >@@ -390,33 +387,25 @@ > fVariables.setEnabled(haveOutputFile); > fAppend.setEnabled(haveOutputFile); > } >- >+ > /* (non-Javadoc) > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) > */ > public void performApply(ILaunchConfigurationWorkingCopy configuration) { > if (fCreateBuildScheduleComponent) { >- HashSet kinds = new HashSet(4); >+ StringBuffer buffer= new StringBuffer(); > if (afterClean.getSelection()) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_FULL); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_FULL).append(','); > } >- if(manualBuild.getSelection()){ >- kinds.add(IExternalToolConstants.BUILD_TYPE_FULL); >- kinds.add(IExternalToolConstants.BUILD_TYPE_INCREMENTAL); >+ if (manualBuild.getSelection()){ >+ buffer.append(IExternalToolConstants.BUILD_TYPE_INCREMENTAL).append(','); > } > if (autoBuildButton.getSelection()) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_AUTO); >+ buffer.append(IExternalToolConstants.BUILD_TYPE_AUTO).append(','); > } > > if (fDuringClean.getSelection()) { >- kinds.add(IExternalToolConstants.BUILD_TYPE_CLEAN); >- } >- StringBuffer buffer= new StringBuffer(); >- for(Iterator i = kinds.iterator(); i.hasNext();) { >- buffer.append(i.next()); >- if(i.hasNext()) { >- buffer.append(','); >- } >+ buffer.append(IExternalToolConstants.BUILD_TYPE_CLEAN); > } > configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString()); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 114563
:
165391
|
184083
|
188199
|
188608