private AntBuildFileBase registerAntInstallation( final File platformDir, final File extensionDir, final List<String> desiredTargets ) { final AntBuildFileBase antBuildFile = findBuildFile(extensionDir); if (antBuildFile == null) { return null; } final List<TargetFilter> filterList = getFilteredTargets(antBuildFile, desiredTargets); final AbstractProperty.AbstractPropertyContainer allOptions = antBuildFile.getAllOptions(); final EditPropertyContainer editPropertyContainer = new EditPropertyContainer(allOptions); setAntProperties(editPropertyContainer, platformDir, filterList); editPropertyContainer.apply(); return antBuildFile; }
private AntBuildFileBase findBuildFile(final File dir) { final File buildxml = new File(dir, HybrisConstants.ANT_BUILD_XML); if (!buildxml.exists()) { return null; } final VirtualFile buildFile = VfsUtil.findFileByIoFile(buildxml, true); if (buildFile == null) { return null; } final AntBuildFile antBuildFile; try { antBuildFile = antConfiguration.addBuildFile(buildFile); } catch (AntNoFileException e) { return null; } if (antBuildFile instanceof AntBuildFileBase) { return (AntBuildFileBase) antBuildFile; } return null; }
private static AntBuildMessageView prepareMessageView(@Nullable AntBuildMessageView buildMessageViewToReuse, AntBuildFileBase buildFile, String[] targets) throws RunCanceledException { AntBuildMessageView messageView; if (buildMessageViewToReuse != null) { messageView = buildMessageViewToReuse; messageView.emptyAll(); } else { messageView = AntBuildMessageView.openBuildMessageView(buildFile.getProject(), buildFile, targets); if (messageView == null) { throw new RunCanceledException(AntBundle.message("canceled.by.user.error.message")); } } return messageView; }
private AntBuildMessageView(Project project, AntBuildFileBase buildFile, String[] targets) { super(new BorderLayout(2, 0)); myProject = project; myBuildFile = buildFile; myTargets = targets; setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); myPlainTextView = new PlainTextView(project); myTreeView = new TreeView(project, buildFile); myCardLayout = new CardLayout(); myContentPanel = new JPanel(myCardLayout); myContentPanel.add(myTreeView.getComponent(), myTreeView.getId()); myContentPanel.add(myPlainTextView.getComponent(), myPlainTextView.getId()); myMessagePanel = JBUI.Panels.simplePanel(myContentPanel); setVerboseMode(AntBuildFileImpl.VERBOSE.value(buildFile.getAllOptions())); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); showAntView(AntBuildFileImpl.TREE_VIEW.value(buildFile.getAllOptions())); }
private AntBuildMessageView(Project project, AntBuildFileBase buildFile, String[] targets) { super(new BorderLayout(2, 0)); myProject = project; setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); myPlainTextView = new PlainTextView(project); myTreeView = new TreeView(project, buildFile); myMessagePanel = new JPanel(new BorderLayout()); myBuildFile = buildFile; myTargets = targets; showAntView(AntBuildFileImpl.TREE_VIEW.value(buildFile.getAllOptions())); setVerboseMode(AntBuildFileImpl.VERBOSE.value(buildFile.getAllOptions())); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); }
@Override public AntBuildFile[] getFilesForGroup(@NotNull AntBuildFileGroup group) { final List<VirtualFile> virtualFiles = myFileGroupList.get(group); if (virtualFiles == null || virtualFiles.isEmpty()) { return AntBuildFile.EMPTY_ARRAY; } List<AntBuildFile> files = new ArrayList<AntBuildFile>(); final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject); final PsiManager manager = PsiManager.getInstance(myProject); for (VirtualFile virtualFile : virtualFiles) { final PsiFile file = manager.findFile(virtualFile); if (!(file instanceof XmlFile)) { continue; } final AntBuildFileBase antBuildFile = antConfiguration.getAntBuildFile(file); if (antBuildFile == null) { continue; } files.add(antBuildFile); } return files.toArray(new AntBuildFile[files.size()]); }
@Override public void configure( @NotNull HybrisProjectDescriptor hybrisProjectDescriptor, @NotNull final List<HybrisModuleDescriptor> allModules, @NotNull final Project project ) { this.hybrisProjectDescriptor = hybrisProjectDescriptor; parseModules(allModules); if (platformDescriptor == null) { return; } final File platformDir = platformDescriptor.getRootDirectory(); createAntInstallation(platformDir); if (antInstallation == null) { return; } createAntClassPath(platformDir); AntConfigurationBase.getInstance(project).setFilterTargets(true); antConfiguration = AntConfigurationBase.getInstance(project); final AntBuildFileBase buildFile = registerAntInstallation(platformDir, platformDir, desirablePlatformTargets); customHybrisModuleDescriptorList.forEach( e -> registerAntInstallation(platformDir, e.getRootDirectory(), desirableCustomTargets) ); saveAntInstallation(antInstallation); removeMake(project); createMetaTargets(buildFile); final ToolWindowManager manager = ToolWindowManager.getInstance(project); final ToolWindow window = manager.getToolWindow("Ant Build"); window.show(null); }
private void createMetaTargets(final AntBuildFileBase buildFile) { Arrays.stream(metaTargets).forEach(meta -> { final ExecuteCompositeTargetEvent event = new ExecuteCompositeTargetEvent(meta); if (antConfiguration.getTargetForEvent(event) == null) { antConfiguration.setTargetForEvent(buildFile, event.getMetaTargetName(), event); } }); }
private List<TargetFilter> getFilteredTargets( final AntBuildFileBase antBuildFile, final List<String> desirableTargets ) { return Arrays.stream(antConfiguration.getModel(antBuildFile).getTargets()) .map(TargetFilter::fromTarget) .peek(e -> e.setVisible(desirableTargets.contains(e.getTargetName()))) .collect(Collectors.toList()); }
private void triggerCleanAll(final Project project) { final HybrisProjectSettings yProjectSettings = HybrisProjectSettingsComponent.getInstance(project).getState(); final File platformDir = new File(project.getBasePath() + "/" + yProjectSettings.getHybrisDirectory() + PLATFORM_MODULE_PREFIX); final VirtualFile vfPlatformDir = VfsUtil.findFileByIoFile(platformDir, true); final VirtualFile vfBuildFile = VfsUtil.findRelativeFile(vfPlatformDir, HybrisConstants.ANT_BUILD_XML); if (vfBuildFile == null) { return; } final PsiFile psiBuildFile = PsiManager.getInstance(project).findFile(vfBuildFile); if (psiBuildFile == null) { return; } final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project); final AntBuildFileBase antBuildFile = antConfiguration.getAntBuildFile(psiBuildFile); if (antBuildFile != null) { ExecutionHandler.runBuild( antBuildFile, antCleanAll, null, getDataContext(project), Collections.emptyList(), AntBuildListener.NULL ); } }
private void setExpandedState(TreeExpansionEvent event, boolean shouldExpand) { final TreePath path = event.getPath(); final AbstractTreeUi ui = getUi(); final Object lastPathComponent = path.getLastPathComponent(); if (lastPathComponent != null) { final Object element = ui.getElementFor(lastPathComponent); if (element instanceof AntBuildFileBase) { ((AntBuildFileBase)element).setShouldExpand(shouldExpand); } } }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
@Override public void actionPerformed(AnActionEvent e) { Pair<AntBuildFileBase, AntDomTarget> antTarget = findAntTarget(e); if (antTarget == null) return; ExecutionHandler.runBuild( antTarget.first, new String[] {antTarget.second.getName().getValue() }, null, e.getDataContext(), Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); }
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); Pair<AntBuildFileBase, AntDomTarget> antTarget = findAntTarget(e); if (antTarget == null) { presentation.setEnabled(false); presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", "")); } else { presentation.setEnabled(true); presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", "'" + antTarget.second.getName().getValue() + "'")); } }
/** * @param antBuildListener should not be null. Use {@link com.intellij.lang.ant.config.AntBuildListener#NULL} */ public static void runBuild(final AntBuildFileBase buildFile, String[] targets, @Nullable final AntBuildMessageView buildMessageViewToReuse, final DataContext dataContext, List<BuildFileProperty> additionalProperties, @NotNull final AntBuildListener antBuildListener) { runBuildImpl(buildFile, targets, buildMessageViewToReuse, dataContext, additionalProperties, antBuildListener, true); }
@Nullable private static ProcessHandler runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFileBase buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) { final Project project = buildFile.getProject(); final long startTime = System.currentTimeMillis(); LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName())); final JUnitProcessHandler handler; try { handler = JUnitProcessHandler.runCommandLine(commandLine); } catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.error.dialog.title"), project); } }); antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0); return null; } processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener); return handler; }
public void writeExternal(Element parentNode) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, parentNode); for (final AntBuildFile buildFile : AntConfiguration.getInstance(myProject).getBuildFiles()) { Element element = new Element(BUILD_FILE); element.setAttribute(URL, buildFile.getVirtualFile().getUrl()); ((AntBuildFileBase)buildFile).writeWorkspaceProperties(element); parentNode.addContent(element); } }
public void loadFileProperties() throws InvalidDataException { final Element properties = myProperties.getAndSet(null); if (properties == null) { return; } for (final AntBuildFile buildFile : AntConfiguration.getInstance(myProject).getBuildFiles()) { final Element fileElement = findChildByUrl(properties, buildFile.getVirtualFile().getUrl()); if (fileElement == null) { continue; } ((AntBuildFileBase)buildFile).readWorkspaceProperties(fileElement); } }
public void reset(final AntBuildFileBase buildFile) { myBinding.loadValues(buildFile.getAllOptions()); myBuildFileName.setText(buildFile.getPresentableUrl()); for (Tab tab : myTabs) { tab.reset(buildFile.getAllOptions()); } }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
public void setBuildFileProperties() { final AntBuildFileBase buildFile = getCurrentBuildFile(); if (buildFile != null && BuildFilePropertiesPanel.editBuildFile(buildFile, myProject)) { myConfig.updateBuildFile(buildFile); myBuilder.queueUpdate(); myTree.repaint(); } }
private void runSelection(final DataContext dataContext) { if (!canRunSelection()) { return; } final AntBuildFileBase buildFile = getCurrentBuildFile(); if (buildFile != null) { final TreePath[] paths = myTree.getSelectionPaths(); final String[] targets = getTargetNamesFromPaths(paths); ExecutionHandler.runBuild(buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); } }
public void setSelected(AnActionEvent event, boolean state) { final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject); if (state) { final AntBuildFileBase buildFile = (AntBuildFileBase)((myTarget instanceof MetaTarget) ? ((MetaTarget)myTarget).getBuildFile() : myTarget.getModel().getBuildFile()); antConfiguration.setTargetForEvent(buildFile, myTarget.getName(), myExecutionEvent); } else { antConfiguration.clearTargetForEvent(myExecutionEvent); } myBuilder.queueUpdate(); }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = e.getProject(); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
public void reset(final AntBuildFileBase buildFile) { myBinding.loadValues(buildFile.getAllOptions()); myBuildFileName.setText(buildFile.getPresentableUrl()); for(Tab tab : myTabs) { tab.reset(buildFile.getAllOptions()); } }
public void apply(AntBuildFileBase buildFile) { myBinding.apply(buildFile.getAllOptions()); for(Tab tab : myTabs) { tab.apply(buildFile.getAllOptions()); } }