@Nullable @Override public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException { RunProfile profile = myEnvironment.getRunProfile(); if (profile instanceof AntRunConfiguration) { AntRunConfiguration antRunConfiguration = (AntRunConfiguration)profile; AntBuildTarget target = antRunConfiguration.getTarget(); if (target == null) return null; ProcessHandler processHandler = ExecutionHandler .executeRunConfiguration(antRunConfiguration, myEnvironment.getDataContext(), new ArrayList<BuildFileProperty>(), new AntBuildListener() { @Override public void buildFinished(int state, int errorCount) { } }); if (processHandler == null) return null; return new DefaultExecutionResult(null, processHandler); } return null; }
@Override public List<BuildFileProperty> getAntProperties() { final List<BuildFileProperty> properties = new ArrayList<BuildFileProperty>(); properties.add(new BuildFileProperty(ARTIFACT_OUTPUT_PATH_PROPERTY, getArtifact().getOutputPath())); properties.addAll(myProperties.myUserProperties); return properties; }
public void testLoadArtifactProperties() { loadProject(PROJECT_PATH); List<JpsArtifact> artifacts = JpsArtifactService.getInstance().getSortedArtifacts(myProject); assertEquals(2, artifacts.size()); JpsArtifact dir = artifacts.get(0); assertEquals("dir", dir.getName()); JpsAntArtifactExtension preprocessing = JpsAntExtensionService.getPreprocessingExtension(dir); assertNotNull(preprocessing); assertTrue(preprocessing.isEnabled()); assertEquals(getUrl("build.xml"), preprocessing.getFileUrl()); assertEquals("show-message", preprocessing.getTargetName()); assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, assertOneElement(preprocessing.getAntProperties()).getPropertyName()); JpsAntArtifactExtension postprocessing = JpsAntExtensionService.getPostprocessingExtension(dir); assertNotNull(postprocessing); assertEquals(getUrl("build.xml"), postprocessing.getFileUrl()); assertEquals("create-file", postprocessing.getTargetName()); List<BuildFileProperty> properties = postprocessing.getAntProperties(); assertEquals(2, properties.size()); assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, properties.get(0).getPropertyName()); assertEquals(dir.getOutputPath(), properties.get(0).getPropertyValue()); assertEquals("message.text", properties.get(1).getPropertyName()); assertEquals("post", properties.get(1).getPropertyValue()); JpsArtifact jar = artifacts.get(1); assertEquals("jar", jar.getName()); assertNull(JpsAntExtensionService.getPostprocessingExtension(jar)); assertNull(JpsAntExtensionService.getPreprocessingExtension(jar)); }
public void testLoadAntConfiguration() { loadProject(PROJECT_PATH); loadGlobalSettings(OPTIONS_PATH); String buildXmlUrl = getUrl("build.xml"); JpsAntBuildFileOptions options = JpsAntExtensionService.getOptions(myProject, buildXmlUrl); assertEquals(128, options.getMaxHeapSize()); assertEquals("-J-Dmy.ant.prop=123", options.getAntCommandLineParameters()); assertContainsElements(toFiles(options.getAdditionalClasspath()), new File(getAbsolutePath("lib/jdom.jar")), new File(getAbsolutePath("ant-lib/a.jar"))); BuildFileProperty property = assertOneElement(options.getProperties()); assertEquals("my.property", property.getPropertyName()); assertEquals("its value", property.getPropertyValue()); String emptyFileUrl = getUrl("empty.xml"); JpsAntBuildFileOptions options2 = JpsAntExtensionService.getOptions(myProject, emptyFileUrl); assertEquals(256, options2.getMaxHeapSize()); assertEquals(10, options2.getMaxStackSize()); assertEquals("1.6", options2.getCustomJdkName()); JpsAntInstallation bundled = JpsAntExtensionService.getAntInstallationForBuildFile(myModel, buildXmlUrl); assertNotNull(bundled); assertEquals("Bundled Ant", bundled.getName()); JpsAntInstallation installation = JpsAntExtensionService.getAntInstallationForBuildFile(myModel, emptyFileUrl); assertNotNull(installation); assertEquals("Apache Ant version 1.8.2", installation.getName()); }
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; } } }
public void actionPerformed(AnActionEvent e) { ExecutionHandler.runBuild( myAntBuildMessageView.getBuildFile(), myAntBuildMessageView.getTargets(), myAntBuildMessageView, e.getDataContext(), Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); }
@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); }
/** * @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); }
@Override public void generateTasksForArtifact(Artifact artifact, boolean preprocessing, ArtifactAntGenerationContext context, CompositeGenerator generator) { final ArtifactPropertiesProvider provider; if (preprocessing) { provider = AntArtifactPreProcessingPropertiesProvider.getInstance(); } else { provider = AntArtifactPostprocessingPropertiesProvider.getInstance(); } final AntArtifactProperties properties = (AntArtifactProperties)artifact.getProperties(provider); if (properties != null && properties.isEnabled()) { final String path = VfsUtil.urlToPath(properties.getFileUrl()); String fileName = PathUtil.getFileName(path); String dirPath = PathUtil.getParentPath(path); final String relativePath = GenerationUtils.toRelativePath(dirPath, BuildProperties.getProjectBaseDir(context.getProject()), BuildProperties.getProjectBaseDirProperty(), context.getGenerationOptions()); final Tag ant = new Tag("ant", Pair.create("antfile", fileName), Pair.create("target", properties.getTargetName()), Pair.create("dir", relativePath)); final String outputPath = BuildProperties.propertyRef(context.getArtifactOutputProperty(artifact)); ant.add(new Property(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, outputPath)); for (BuildFileProperty property : properties.getUserProperties()) { ant.add(new Property(property.getPropertyName(), property.getPropertyValue())); } generator.add(ant); } }
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); } } } }
public void apply() { myProperties.setEnabled(myRunTargetCheckBox.isSelected()); if (myTarget != null) { final VirtualFile file = myTarget.getModel().getBuildFile().getVirtualFile(); if (file != null) { myProperties.setFileUrl(file.getUrl()); myProperties.setTargetName(myTarget.getName()); final List<BuildFileProperty> properties = getUserProperties(); myProperties.setUserProperties(properties); return; } } myProperties.setFileUrl(null); myProperties.setTargetName(null); }
public void reset() { myRunTargetCheckBox.setSelected(myProperties.isEnabled()); myTarget = myProperties.findTarget(AntConfiguration.getInstance(myContext.getProject())); final List<BuildFileProperty> properties = new ArrayList<BuildFileProperty>(); for (BuildFileProperty property : myProperties.getAllProperties(myContext.getArtifact())) { properties.add(new BuildFileProperty(property.getPropertyName(), property.getPropertyValue())); } myContainer = new SinglePropertyContainer<ListProperty>(ANT_PROPERTIES, properties); myBinding.loadValues(myContainer); updatePanel(); }
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; } } }
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 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; } } }
private void expandProperty(DataContext dataContext, BuildFileProperty property) throws Macro.ExecutionCancelledException { String value = property.getPropertyValue(); final MacroManager macroManager = GlobalAntConfiguration.getMacroManager(); value = macroManager.expandMacrosInString(value, true, dataContext); value = macroManager.expandMacrosInString(value, false, dataContext); myExpandedProperties.add("-D" + property.getPropertyName() + "=" + value); }
private void setAntProperties( final EditPropertyContainer editPropertyContainer, final File platformDir, final List<TargetFilter> filterList ) { AntBuildFileImpl.ADDITIONAL_CLASSPATH.set(editPropertyContainer, classPaths); AntBuildFileImpl.TREE_VIEW.set(editPropertyContainer, true); AntBuildFileImpl.TREE_VIEW_ANSI_COLOR.set(editPropertyContainer, true); AntBuildFileImpl.TREE_VIEW_COLLAPSE_TARGETS.set(editPropertyContainer, false); AntBuildFileImpl.ANT_INSTALLATION.set(editPropertyContainer, antInstallation); AntBuildFileImpl.ANT_REFERENCE.set(editPropertyContainer, antInstallation.getReference()); AntBuildFileImpl.RUN_WITH_ANT.set(editPropertyContainer, antInstallation); AntBuildFileImpl.MAX_HEAP_SIZE.set(editPropertyContainer, HybrisConstants.ANT_HEAP_SIZE_MB); AntBuildFileImpl.MAX_STACK_SIZE.set(editPropertyContainer, HybrisConstants.ANT_STACK_SIZE_MB); AntBuildFileImpl.RUN_IN_BACKGROUND.set(editPropertyContainer, false); AntBuildFileImpl.VERBOSE.set(editPropertyContainer, false); final ListProperty<BuildFileProperty> properties = AntBuildFileImpl.ANT_PROPERTIES; properties.clearList(editPropertyContainer); final BuildFileProperty platformHomeProperty = new BuildFileProperty(); platformHomeProperty.setPropertyName(HybrisConstants.ANT_PLATFORM_HOME); platformHomeProperty.setPropertyValue(platformDir.getAbsolutePath()); final BuildFileProperty antHomeProperty = new BuildFileProperty(); antHomeProperty.setPropertyName(HybrisConstants.ANT_HOME); antHomeProperty.setPropertyValue(antInstallation.getHomeDir()); final BuildFileProperty antOptsProperty = new BuildFileProperty(); antOptsProperty.setPropertyName(HybrisConstants.ANT_OPTS); antOptsProperty.setPropertyValue(HybrisConstants.ANT_XMX + HybrisConstants.ANT_HEAP_SIZE_MB + " " + HybrisConstants.ANT_ENCODING); final List<BuildFileProperty> buildFileProperties = new ArrayList<>(); buildFileProperties.add(platformHomeProperty); buildFileProperties.add(antHomeProperty); buildFileProperties.add(antOptsProperty); AntBuildFileImpl.ANT_PROPERTIES.set(editPropertyContainer, buildFileProperties); if (hybrisProjectDescriptor.getExternalConfigDirectory() != null) { AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.set(editPropertyContainer, HybrisConstants.ANT_HYBRIS_CONFIG_DIR + hybrisProjectDescriptor.getExternalConfigDirectory().getAbsolutePath()); } AntBuildFileImpl.TARGET_FILTERS.set(editPropertyContainer, filterList); }
@Override public void addProperty(@NotNull String name, @NotNull String value) { myProperties.add(new BuildFileProperty(name, value)); }
@Override @NotNull public List<BuildFileProperty> getProperties() { return myProperties; }
@NotNull List<BuildFileProperty> getProperties();
public List<BuildFileProperty> getUserProperties() { return myExtensionProperties.myUserProperties; }
public void setUserProperties(List<BuildFileProperty> userProperties) { myExtensionProperties.myUserProperties = userProperties; }
public List<BuildFileProperty> getAllProperties(@NotNull Artifact artifact) { final List<BuildFileProperty> properties = new ArrayList<BuildFileProperty>(); properties.add(new BuildFileProperty(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, artifact.getOutputPath())); properties.addAll(myExtensionProperties.myUserProperties); return properties; }
public String valueOf(BuildFileProperty buildFileProperty) { return buildFileProperty.getPropertyName(); }
public boolean isCellEditable(BuildFileProperty buildFileProperty) { return USER_PROPERTY_CONDITION.value(buildFileProperty); }
public void setValue(BuildFileProperty buildFileProperty, String name) { buildFileProperty.setPropertyName(name); }