use of com.intellij.lang.ant.config.AntBuildTarget in project intellij-community by JetBrains.
the class AntBeforeRunTaskProvider method configureTask.
public boolean configureTask(RunConfiguration runConfiguration, AntBeforeRunTask task) {
AntBuildTarget buildTarget = findTargetToExecute(task);
final TargetChooserDialog dlg = new TargetChooserDialog(myProject, buildTarget);
if (dlg.showAndGet()) {
task.setTargetName(null);
task.setAntFileUrl(null);
buildTarget = dlg.getSelectedTarget();
if (buildTarget != null) {
final VirtualFile vFile = buildTarget.getModel().getBuildFile().getVirtualFile();
if (vFile != null) {
task.setAntFileUrl(vFile.getUrl());
task.setTargetName(buildTarget.getName());
}
}
return true;
}
return false;
}
use of com.intellij.lang.ant.config.AntBuildTarget in project intellij-community by JetBrains.
the class ExecutionHandler method executeRunConfiguration.
@Nullable
public static ProcessHandler executeRunConfiguration(AntRunConfiguration antRunConfiguration, final DataContext dataContext, List<BuildFileProperty> additionalProperties, @NotNull final AntBuildListener antBuildListener) {
AntBuildTarget target = antRunConfiguration.getTarget();
if (target == null)
return null;
FutureResult<ProcessHandler> result = runBuildImpl((AntBuildFileBase) target.getModel().getBuildFile(), new String[] { target.getName() }, null, dataContext, additionalProperties, antBuildListener, false);
if (result != null) {
try {
return result.get();
} catch (InterruptedException | java.util.concurrent.ExecutionException e) {
LOG.warn(e);
}
}
return null;
}
use of com.intellij.lang.ant.config.AntBuildTarget in project intellij-community by JetBrains.
the class TargetChooserDialog method processFileTargets.
private DefaultMutableTreeNode processFileTargets(final AntBuildTarget[] targets, final AntBuildFile buildFile, final DefaultMutableTreeNode buildFileNode) {
DefaultMutableTreeNode result = null;
for (AntBuildTarget target : targets) {
if (target.getName() == null)
continue;
final AntTargetNodeDescriptor descriptor = new AntTargetNodeDescriptor(target, buildFile);
final DefaultMutableTreeNode node = new DefaultMutableTreeNode(descriptor);
if (isSelected(descriptor)) {
result = node;
}
buildFileNode.add(node);
}
return result;
}
use of com.intellij.lang.ant.config.AntBuildTarget in project intellij-community by JetBrains.
the class TargetChooserDialog method initTree.
private Tree initTree() {
@NonNls final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
final Tree tree = new Tree(root);
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath != null) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof AntTargetNodeDescriptor) {
final AntTargetNodeDescriptor antBuildTarget = (AntTargetNodeDescriptor) userObject;
mySelectedTarget = antBuildTarget.getAntTarget();
} else {
mySelectedTarget = null;
}
}
}
});
tree.setCellRenderer(new MyTreeCellRenderer());
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.setLineStyleAngled();
TreeUtil.installActions(tree);
new TreeSpeedSearch(tree, new Convertor<TreePath, String>() {
public String convert(final TreePath path) {
final Object userObject = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
if (userObject instanceof AntTargetNodeDescriptor) {
final AntBuildTarget target = ((AntTargetNodeDescriptor) userObject).getAntTarget();
return target.getDisplayName();
}
return null;
}
});
DefaultMutableTreeNode selectedNode = null;
final AntConfiguration antConfiguration = AntConfigurationImpl.getInstance(myProject);
for (AntBuildFile buildFile : antConfiguration.getBuildFileList()) {
final DefaultMutableTreeNode buildFileNode = new DefaultMutableTreeNode(buildFile);
DefaultMutableTreeNode selection = processFileTargets(antConfiguration.getMetaTargets(buildFile), buildFile, buildFileNode);
if (selection != null) {
selectedNode = selection;
}
selection = processFileTargets(antConfiguration.getModel(buildFile).getTargets(), buildFile, buildFileNode);
if (selection != null) {
selectedNode = selection;
}
root.add(buildFileNode);
}
TreeUtil.expandAll(tree);
TreeUtil.selectInTree(selectedNode, true, tree);
return tree;
}
use of com.intellij.lang.ant.config.AntBuildTarget in project intellij-community by JetBrains.
the class AntArtifactProperties method runAntTarget.
private void runAntTarget(CompileContext compileContext, final Artifact artifact) {
if (myExtensionProperties.myEnabled) {
final Project project = compileContext.getProject();
final AntBuildTarget target = findTarget(AntConfiguration.getInstance(project));
if (target != null) {
final DataContext dataContext = SimpleDataContext.getProjectContext(project);
List<BuildFileProperty> properties = getAllProperties(artifact);
final boolean success = AntConfigurationImpl.executeTargetSynchronously(dataContext, target, properties);
if (!success) {
compileContext.addMessage(CompilerMessageCategory.ERROR, "Cannot build artifact '" + artifact.getName() + "': ant target '" + target.getDisplayName() + "' failed with error", null, -1, -1);
}
}
}
}
Aggregations