1 11 package org.eclipse.core.resources.ant; 12 13 import java.util.Hashtable ; 14 import org.apache.tools.ant.BuildException; 15 import org.apache.tools.ant.Task; 16 import org.eclipse.ant.core.AntCorePlugin; 17 import org.eclipse.core.resources.*; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 21 27 public class IncrementalBuild extends Task { 28 private String builder; 29 private String project; 30 private int kind = IncrementalProjectBuilder.INCREMENTAL_BUILD; 31 32 36 public final static String KIND_INCREMENTAL = "incremental"; 38 42 public final static String KIND_FULL = "full"; 44 48 public final static String KIND_AUTO = "auto"; 50 54 public final static String KIND_CLEAN = "clean"; 56 59 public IncrementalBuild() { 60 super(); 61 } 62 63 68 public void execute() throws BuildException { 69 try { 70 IProgressMonitor monitor = null; 71 Hashtable references = getProject().getReferences(); 72 if (references != null) 73 monitor = (IProgressMonitor) references.get(AntCorePlugin.ECLIPSE_PROGRESS_MONITOR); 74 if (project == null) { 75 ResourcesPlugin.getWorkspace().build(kind, monitor); 76 } else { 77 IProject targetProject = ResourcesPlugin.getWorkspace().getRoot().getProject(project); 78 if (builder == null) 79 targetProject.build(kind, monitor); 80 else 81 targetProject.build(kind, builder, null, monitor); 82 } 83 } catch (CoreException e) { 84 throw new BuildException(e); 85 } 86 } 87 88 93 public void setBuilder(String value) { 94 builder = value; 95 } 96 97 106 public void setKind(String value) { 107 if (IncrementalBuild.KIND_FULL.equalsIgnoreCase(value)) 108 kind = IncrementalProjectBuilder.FULL_BUILD; 109 else if (IncrementalBuild.KIND_AUTO.equalsIgnoreCase(value)) 110 kind = IncrementalProjectBuilder.AUTO_BUILD; 111 else if (IncrementalBuild.KIND_CLEAN.equalsIgnoreCase(value)) 112 kind = IncrementalProjectBuilder.CLEAN_BUILD; 113 else if (IncrementalBuild.KIND_INCREMENTAL.equalsIgnoreCase(value)) 114 kind = IncrementalProjectBuilder.INCREMENTAL_BUILD; 115 } 116 117 122 public void setProject(String value) { 123 project = value; 124 } 125 } 126 | Popular Tags |