/** * Find the specific Java command amongst the given build spec * and return its index or -1 if not found. */ private int getJavaCommandIndex(ICommand[] buildSpec) { for (int i = 0; i < buildSpec.length; ++i) { if (buildSpec[i].getBuilderName().equals(JavaCore.BUILDER_ID)) { return i; } } return -1; }
ICommand command = description.newCommand(); command.setBuilderName(builderID);
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; }
private static ICommand toCommand(String name, Map<String, String> arguments, IProjectDescription description) { ICommand command = description.newCommand(); command.setBuilderName(name); command.setArguments(arguments); return command; } }
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.AUTO_BUILD, false); newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false); String buildKinds = config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null); int[] triggers = buildTypesToArray(buildKinds); switch (triggers[i]) { 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; Map args = newCommand.getArguments(); if(args == null) { args = new HashMap(); newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true); args.put(INC_CLEAN, Boolean.TRUE.toString());
public void configure() throws CoreException { IProjectDescription desc = project.getDescription(); ICommand[] commands = desc.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(XtextBuilder.BUILDER_ID)) { return; } } ICommand[] newCommands = new ICommand[commands.length + 1]; System.arraycopy(commands, 0, newCommands, 1, commands.length); ICommand command = desc.newCommand(); command.setBuilderName(XtextBuilder.BUILDER_ID); newCommands[0] = command; desc.setBuildSpec(newCommands); project.setDescription(desc, null); }
buildCommand.setArguments(args); buildCommand.setBuilderName( builderName ); if (builderName.equals(c.getBuilderName())) { bFound = true; break;
ICommand projectCommand = commands[i]; String name = ExternalToolMigration .getNameFromCommandArgs(projectCommand.getArguments()); if (name != null && name.equals(config.getName())) { args = projectCommand.getArguments(); break; args.put(LAUNCH_CONFIG_HANDLE, buffer.toString()); command.setBuilderName(ExternalToolBuilder.ID); command.setArguments(args); return command;
/** * Returns whether one of the projects has a builder whose trigger setting * for the given trigger matches the given value. * * @param projects The projects to check * @param trigger The trigger to look for * @param value The trigger value to look for * @return <code>true</code> if one of the projects has a builder whose * trigger activation matches the provided value, and <code>false</code> otherwise. */ private static boolean matchingTrigger(IProject[] projects, int trigger, boolean value) { for (int i = 0; i < projects.length; i++) { if (!projects[i].isAccessible()) { continue; } try { IProjectDescription description = projects[i].getDescription(); ICommand[] buildSpec = description.getBuildSpec(); for (int j = 0; j < buildSpec.length; j++) { if (buildSpec[j].isBuilding(trigger) == value) { return true; } } } catch (CoreException e) { //ignore projects that are not available } } return false; }
public static String getPath(IProject project, String argument) { try { for (final ICommand command : project.getDescription().getBuildSpec()) { if (isFIDEBuilder(command)) { return command.getArguments().get(argument); } } } catch (final CoreException e) { Logger.logError(e); } return null; }
public void configure() throws CoreException { IProjectDescription desc = project.getDescription(); ICommand[] commands = desc.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(BndBuilder.BUILDER_ID)) { return; } } ICommand[] newCommands = new ICommand[commands.length + 1]; System.arraycopy(commands, 0, newCommands, 0, commands.length); ICommand command = desc.newCommand(); command.setBuilderName(BndBuilder.BUILDER_ID); newCommands[newCommands.length - 1] = command; desc.setBuildSpec(newCommands); project.setDescription(desc, null); }
private ICommand createCommand(IProjectDescription description, String name, Map<String, String> arguments) { ICommand command = description.newCommand(); command.setBuilderName(name); command.setArguments(ImmutableMap.copyOf(arguments)); return command; }
boolean isBuilding = builder.getCommand().isBuilding(trigger); isBuilding = isBuilding || builder.getCommand().isBuilding(trigger);
protected void runNecessaryBuilders(IVirtualComponent component, IProgressMonitor monitor) throws CoreException { try{ monitor.beginTask(null, JAVA_BUILDER_WORK + LIB_BUILDER_WORK); if(!component.isBinary()){ IProject project = component.getProject(); IProjectDescription description = project.getDescription(); ICommand javaBuilder = getJavaCommand(description); if (javaBuilder != null) { project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, javaBuilder.getArguments(), new SubProgressMonitor(monitor, JAVA_BUILDER_WORK)); } ICommand libCopyBuilder = getLibCopyBuilder(description); if (null != libCopyBuilder) { project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, LibCopyBuilder.BUILDER_ID, libCopyBuilder.getArguments(), new SubProgressMonitor(monitor, LIB_BUILDER_WORK)); } } } finally { monitor.done(); } }
public void configure() throws CoreException { IProjectDescription desc = project.getDescription(); ICommand[] commands = desc.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(BndBuilder.BUILDER_ID)) { return; } } ICommand[] newCommands = new ICommand[commands.length + 1]; System.arraycopy(commands, 0, newCommands, 0, commands.length); ICommand command = desc.newCommand(); command.setBuilderName(BndBuilder.BUILDER_ID); newCommands[newCommands.length - 1] = command; desc.setBuildSpec(newCommands); project.setDescription(desc, null); }
@Override public boolean apply(ICommand command) { return !command.getBuilderName().equals(ID); } }).toArray(ICommand.class);
protected void setBuilder(final IProjectDescription projectDescription, final String[] builders) { List<ICommand> commands = Lists.newArrayList(); for (int i = 0; i < builders.length; i++) { ICommand command = projectDescription.newCommand(); command.setBuilderName(builders[i]); commands.add(command); } projectDescription.setBuildSpec(commands.toArray(new ICommand[commands.size()])); }
public String toXml(List<ICommand> commands) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.newDocument(); Element commandsNode = createNode(document, document, TAG_COMMANDS); for (ICommand command : commands) { Element commandNode = createNode(document, commandsNode, TAG_COMMAND); createAttribute(document, commandNode, ATTRIBUTE_NAME, command.getBuilderName()); Map<String, String> arguments = command.getArguments(); if (!arguments.isEmpty()) { for (String key : arguments.keySet()) { String value = arguments.get(key); Element argumentNode = createNode(document, commandNode, TAG_ARGUMENT, value); createAttribute(document, argumentNode, ATTRIBUTE_KEY, key); } } } TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(document); StringWriter writer = new StringWriter(); transformer.transform(source, new StreamResult(writer)); return writer.toString(); } catch (Exception e) { CorePlugin.logger().warn("Cannot save build commands", e); return ""; } }
private List<ICommand> toEntries(String commands) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(new ByteArrayInputStream(commands.getBytes())); List<ICommand> result = Lists.newArrayList(); NodeList commandNodeList = document.getElementsByTagName(TAG_COMMAND); for (int i = 0; i < commandNodeList.getLength(); i++) { Element eElement = (Element) commandNodeList.item(i); ICommand command = this.project.getDescription().newCommand(); command.setBuilderName(eElement.getAttribute(ATTRIBUTE_NAME)); NodeList argumentNodeList = eElement.getElementsByTagName(TAG_ARGUMENT); Map<String, String> argumentsMap = Maps.newHashMap(); for (int j = 0; j < argumentNodeList.getLength(); j++) { Element argumentElement = (Element) argumentNodeList.item(j); argumentsMap.put(argumentElement.getAttribute(ATTRIBUTE_KEY), argumentElement.getTextContent()); } command.setArguments(argumentsMap); result.add(command); } return result; } catch (Exception e) { CorePlugin.logger().warn("Cannot load build commands", e); return Collections.emptyList(); } }
boolean isBuilding = builder.getCommand().isBuilding(trigger); isBuilding = isBuilding || builder.getCommand().isBuilding(trigger);