diff --git a/plugins/javaFX/javaFX.iml b/plugins/javaFX/javaFX.iml
index 2a8f125eb754..41dbc10d0161 100644
--- a/plugins/javaFX/javaFX.iml
+++ b/plugins/javaFX/javaFX.iml
@@ -18,6 +18,8 @@
+
+
diff --git a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
index 60435bbaffbd..d238b6004dd4 100644
--- a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
+++ b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml
@@ -32,6 +32,8 @@
+
+
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationArtifactType.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationArtifactType.java
new file mode 100644
index 000000000000..31c19e6f897c
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxApplicationArtifactType.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.packaging;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.packaging.artifacts.ArtifactType;
+import com.intellij.packaging.elements.CompositePackagingElement;
+import com.intellij.packaging.elements.PackagingElementFactory;
+import com.intellij.packaging.elements.PackagingElementOutputKind;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * User: anna
+ * Date: 3/12/13
+ */
+public class JavaFxApplicationArtifactType extends ArtifactType {
+ protected JavaFxApplicationArtifactType() {
+ super("javafx", "JavaFx Application");
+ }
+
+ @NotNull
+ @Override
+ public Icon getIcon() {
+ return AllIcons.Nodes.Artifact;
+ }
+
+ @Nullable
+ @Override
+ public String getDefaultPathFor(@NotNull PackagingElementOutputKind kind) {
+ return "/";
+ }
+
+ @NotNull
+ @Override
+ public CompositePackagingElement> createRootElement(@NotNull String artifactName) {
+ return PackagingElementFactory.getInstance().createArchive(artifactName + ".jar");
+ }
+}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java
new file mode 100644
index 000000000000..cde3aa85d46a
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.packaging;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.compiler.CompileContext;
+import com.intellij.openapi.compiler.CompilerMessageCategory;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.projectRoots.JavaSdk;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactProperties;
+import com.intellij.packaging.impl.artifacts.ArtifactUtil;
+import com.intellij.packaging.ui.ArtifactEditorContext;
+import com.intellij.packaging.ui.ArtifactPropertiesEditor;
+import com.intellij.util.xmlb.XmlSerializerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * User: anna
+ * Date: 3/12/13
+ */
+public class JavaFxArtifactProperties extends ArtifactProperties {
+
+ private String myTitle;
+ private String myVendor;
+ private String myDescription;
+ private String myAppClass;
+
+ @Override
+ public void onBuildFinished(@NotNull final Artifact artifact, @NotNull CompileContext compileContext) {
+ if (!(artifact.getArtifactType() instanceof JavaFxApplicationArtifactType)) {
+ return;
+ }
+ final Project project = compileContext.getProject();
+ final Set modules = ApplicationManager.getApplication().runReadAction(new Computable>() {
+ @Override
+ public Set compute() {
+ return ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(artifact), project);
+ }
+ });
+ if (modules.isEmpty()) {
+ return;
+ }
+
+ Sdk fxCompatibleSdk = null;
+ for (Module module : modules) {
+ final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
+ if (sdk != null && sdk.getSdkType() instanceof JavaSdk) {
+ if (((JavaSdk)sdk.getSdkType()).isOfVersionOrHigher(sdk, JavaSdkVersion.JDK_1_7)) {
+ fxCompatibleSdk = sdk;
+ break;
+ }
+ }
+ }
+
+ if (fxCompatibleSdk == null) {
+ compileContext.addMessage(CompilerMessageCategory.ERROR, "Java version 7 or higher is required to build JavaFX package", null, -1, -1);
+ return;
+ }
+
+ final String binPath = ((JavaSdk)fxCompatibleSdk.getSdkType()).getBinPath(fxCompatibleSdk);
+
+ final JavaFxArtifactProperties properties =
+ (JavaFxArtifactProperties)artifact.getProperties(JavaFxArtifactPropertiesProvider.getInstance());
+
+ if (StringUtil.isEmptyOrSpaces(properties.getAppClass())) {
+ compileContext.addMessage(CompilerMessageCategory.ERROR, "No application class specified for JavaFX package", null, -1, -1);
+ return;
+ }
+
+ JavaFxPackagerUtil.createJarAndDeploy(artifact, compileContext, binPath, properties);
+ }
+
+
+ @Nullable
+ public String getManifestString() {
+ final StringBuilder buf = new StringBuilder();
+ if (!StringUtil.isEmptyOrSpaces(myTitle)) {
+ buf.append("Implementation-Title=").append(myTitle).append(";");
+ }
+ if (!StringUtil.isEmptyOrSpaces(myVendor)) {
+ buf.append("Implementation-Vendor=").append(myVendor).append(";");
+ }
+ final int lastIdx = buf.length() - 1;
+ if (lastIdx > 0 && buf.charAt(lastIdx) == ';') {
+ buf.deleteCharAt(lastIdx);
+ }
+ return buf.length() == 0 ? null : buf.toString();
+ }
+
+ @Override
+ public ArtifactPropertiesEditor createEditor(@NotNull ArtifactEditorContext context) {
+ return new JavaFxArtifactPropertiesEditor(this, context.getProject(), context.getArtifact());
+ }
+
+ @Nullable
+ @Override
+ public JavaFxArtifactProperties getState() {
+ return this;
+ }
+
+ @Override
+ public void loadState(JavaFxArtifactProperties state) {
+ XmlSerializerUtil.copyBean(state, this);
+ }
+
+ public String getTitle() {
+ return myTitle;
+ }
+
+ public void setTitle(String title) {
+ myTitle = title;
+ }
+
+ public String getVendor() {
+ return myVendor;
+ }
+
+ public void setVendor(String vendor) {
+ myVendor = vendor;
+ }
+
+ public String getDescription() {
+ return myDescription;
+ }
+
+ public void setDescription(String description) {
+ myDescription = description;
+ }
+
+ public String getAppClass() {
+ return myAppClass;
+ }
+
+ public void setAppClass(String appClass) {
+ myAppClass = appClass;
+ }
+}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form
new file mode 100644
index 000000000000..ce1a07f03bdd
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form
@@ -0,0 +1,106 @@
+
+
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java
new file mode 100644
index 000000000000..e194808a7c42
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.packaging;
+
+import com.intellij.execution.JavaExecutionUtil;
+import com.intellij.execution.ui.ClassBrowser;
+import com.intellij.ide.util.ClassFilter;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Computable;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.impl.artifacts.ArtifactUtil;
+import com.intellij.packaging.ui.ArtifactPropertiesEditor;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.InheritanceUtil;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.text.JTextComponent;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * User: anna
+ * Date: 3/12/13
+ */
+public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
+ private final JavaFxArtifactProperties myProperties;
+
+ private JPanel myWholePanel;
+ private JTextField myTitleTF;
+ private JTextField myVendorTF;
+ private JEditorPane myDescriptionEditorPane;
+ private TextFieldWithBrowseButton myAppClass;
+
+ public JavaFxArtifactPropertiesEditor(JavaFxArtifactProperties properties, Project project, Artifact artifact) {
+ super();
+ myProperties = properties;
+ new JavaFxApplicationClassBrowser(project, artifact).setField(myAppClass);
+ }
+
+ @Override
+ public String getTabName() {
+ return "Java FX";
+ }
+
+ @Nullable
+ @Override
+ public JComponent createComponent() {
+ return myWholePanel;
+ }
+
+ @Override
+ public boolean isModified() {
+ if (isModified(myProperties.getTitle(), myTitleTF)) return true;
+ if (isModified(myProperties.getVendor(), myVendorTF)) return true;
+ if (isModified(myProperties.getDescription(), myDescriptionEditorPane)) return true;
+ if (!Comparing.strEqual(myProperties.getAppClass(), myAppClass.getText().trim())) return true;
+ return false;
+ }
+
+ private static boolean isModified(final String title, JTextComponent tf) {
+ return !Comparing.strEqual(title, tf.getText().trim());
+ }
+
+ @Override
+ public void apply() {
+ myProperties.setTitle(myTitleTF.getText());
+ myProperties.setVendor(myVendorTF.getText());
+ myProperties.setDescription(myDescriptionEditorPane.getText());
+ myProperties.setAppClass(myAppClass.getText());
+ }
+
+ @Override
+ public void reset() {
+ setText(myTitleTF, myProperties.getTitle());
+ setText(myVendorTF, myProperties.getVendor());
+ setText(myDescriptionEditorPane, myProperties.getDescription());
+ final String appClass = myProperties.getAppClass();
+ if (appClass != null) {
+ myAppClass.setText(appClass.trim());
+ }
+ }
+
+ private static void setText(JTextComponent tf, final String title) {
+ if (title != null) {
+ tf.setText(title.trim());
+ }
+ }
+
+ @Override
+ public void disposeUIResources() {}
+
+ private static class JavaFxApplicationClassBrowser extends ClassBrowser {
+
+ private final Artifact myArtifact;
+
+ public JavaFxApplicationClassBrowser(Project project, Artifact artifact) {
+ super(project, "Choose Application Class");
+ myArtifact = artifact;
+ }
+
+ @Override
+ protected ClassFilter.ClassFilterWithScope getFilter() throws NoFilterException {
+ return new ClassFilter.ClassFilterWithScope() {
+ @Override
+ public GlobalSearchScope getScope() {
+ return GlobalSearchScope.projectScope(getProject());
+ }
+
+ @Override
+ public boolean isAccepted(PsiClass aClass) {
+ return InheritanceUtil.isInheritor(aClass, "javafx.application.Application");
+ }
+ };
+ }
+
+ @Override
+ protected PsiClass findClass(String className) {
+ final Set modules = ApplicationManager.getApplication().runReadAction(new Computable>() {
+ @Override
+ public Set compute() {
+ return ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(myArtifact), getProject());
+ }
+ });
+ for (Module module : modules) {
+ final PsiClass aClass = JavaExecutionUtil.findMainClass(getProject(), className, GlobalSearchScope.moduleScope(module));
+ if (aClass != null) {
+ return aClass;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesProvider.java
new file mode 100644
index 000000000000..5a9f5d681720
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesProvider.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.packaging;
+
+import com.intellij.packaging.artifacts.ArtifactProperties;
+import com.intellij.packaging.artifacts.ArtifactPropertiesProvider;
+import com.intellij.packaging.artifacts.ArtifactType;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * User: anna
+ * Date: 3/12/13
+ */
+public class JavaFxArtifactPropertiesProvider extends ArtifactPropertiesProvider {
+ protected JavaFxArtifactPropertiesProvider() {
+ super("javafx-properties");
+ }
+
+ @Override
+ public boolean isAvailableFor(@NotNull ArtifactType type) {
+ return type instanceof JavaFxApplicationArtifactType;
+ }
+
+ @NotNull
+ @Override
+ public ArtifactProperties> createProperties(@NotNull ArtifactType artifactType) {
+ return new JavaFxArtifactProperties();
+ }
+
+ public static JavaFxArtifactPropertiesProvider getInstance() {
+ return EP_NAME.findExtension(JavaFxArtifactPropertiesProvider.class);
+ }
+}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxPackagerUtil.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxPackagerUtil.java
new file mode 100644
index 000000000000..eace4f3ff7a7
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxPackagerUtil.java
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.packaging;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.configurations.GeneralCommandLine;
+import com.intellij.execution.process.OSProcessHandler;
+import com.intellij.execution.process.ProcessAdapter;
+import com.intellij.execution.process.ProcessEvent;
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.openapi.compiler.CompileContext;
+import com.intellij.openapi.compiler.CompilerMessageCategory;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.util.io.ZipUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * User: anna
+ * Date: 3/12/13
+ */
+public class JavaFxPackagerUtil {
+ private static final Logger LOG = Logger.getInstance("#" + JavaFxArtifactProperties.class.getName());
+
+ public static void createJarAndDeploy(final Artifact artifact,
+ final CompileContext compileContext,
+ final String binPath,
+ final JavaFxArtifactProperties properties) {
+ final String zipPath = artifact.getOutputFilePath();
+
+ final File tempUnzippedArtifactOutput;
+ try {
+ tempUnzippedArtifactOutput = FileUtil.createTempDirectory("artifact", "unzipped");
+ ZipUtil.extract(new File(zipPath), tempUnzippedArtifactOutput, null);
+ }
+ catch (IOException e) {
+ registerJavaFxPackagerError(compileContext, e);
+ return;
+ }
+
+ final GeneralCommandLine commandLine = new GeneralCommandLine();
+ try {
+ commandLine.setExePath(binPath + File.separator + "javafxpackager");
+
+ commandLine.addParameter("-createJar");
+ commandLine.addParameter("-appclass");
+ commandLine.addParameter(properties.getAppClass());
+
+ commandLine.addParameter("-srcdir");
+ commandLine.addParameter(tempUnzippedArtifactOutput.getPath());
+ commandLine.addParameter("-outdir");
+
+ final File tempDirWithJar;
+ try {
+ tempDirWithJar = FileUtil.createTempDirectory("javafxpackager", "out");
+ }
+ catch (IOException e) {
+ registerJavaFxPackagerError(compileContext, e);
+ return;
+ }
+ commandLine.addParameter(tempDirWithJar.getPath());
+ commandLine.addParameter("-outfile");
+
+ commandLine.addParameter(artifact.getName());
+ commandLine.addParameter("-v");
+
+ commandLine.addParameter("-nocss2bin");
+
+ appendManifestProperties(commandLine, properties);
+
+ final MyOnTerminatedProcessAdapter adapter = new MyOnTerminatedProcessAdapter(compileContext) {
+ @Override
+ protected void onTerminated() {
+ deploy(artifact, compileContext, binPath, properties, tempDirWithJar, tempUnzippedArtifactOutput);
+ }
+ };
+ startProcess(commandLine, adapter);
+ }
+ catch (ExecutionException ex) {
+ registerJavaFxPackagerError(compileContext, ex);
+ }
+ }
+
+ private static void registerJavaFxPackagerError(CompileContext compileContext, Exception ex) {
+ registerJavaFxPackagerError(compileContext, ex.getMessage());
+ }
+
+ private static void registerJavaFxPackagerError(CompileContext compileContext, final String message) {
+ compileContext.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1);
+ }
+
+ private static void deploy(final Artifact artifact,
+ final CompileContext compileContext,
+ String binPath,
+ JavaFxArtifactProperties properties,
+ final File tempDirWithCreatedJar,
+ final File tempUnzippedArtifactOutput) {
+ final GeneralCommandLine commandLine = new GeneralCommandLine();
+ try {
+ commandLine.setExePath(binPath + File.separator + "javafxpackager");
+
+ commandLine.addParameter("-deploy");
+
+ final String title = properties.getTitle();
+ if (!StringUtil.isEmptyOrSpaces(title)) {
+ commandLine.addParameter("-title");
+ commandLine.addParameter(title);
+ }
+ final String vendor = properties.getVendor();
+ if (!StringUtil.isEmptyOrSpaces(vendor)) {
+ commandLine.addParameter("-vendor");
+ commandLine.addParameter(vendor);
+ }
+ final String description = properties.getDescription();
+ if (!StringUtil.isEmptyOrSpaces(description)) {
+ commandLine.addParameter("-description");
+ commandLine.addParameter(description);
+ }
+
+ commandLine.addParameter("-appclass");
+ commandLine.addParameter(properties.getAppClass());
+
+ commandLine.addParameter("-width");
+ commandLine.addParameter("600");
+ commandLine.addParameter("-height");
+ commandLine.addParameter("400");
+
+ commandLine.addParameter("-name");
+ commandLine.addParameter(artifact.getName());
+
+
+ commandLine.addParameter("-outdir");
+
+ final File tempDirectory;
+ try {
+ tempDirectory = FileUtil.createTempDirectory("javafxpackager", "out");
+ }
+ catch (IOException e) {
+ registerJavaFxPackagerError(compileContext, e);
+ return;
+ }
+ commandLine.addParameter(tempDirectory.getPath());
+
+ commandLine.addParameter("-outfile");
+ commandLine.addParameter(artifact.getName());
+
+ commandLine.addParameter("-srcdir");
+ commandLine.addParameter(tempDirWithCreatedJar.getPath());
+
+ commandLine.addParameter("-v");
+
+ final MyOnTerminatedProcessAdapter adapter = new MyOnTerminatedProcessAdapter(compileContext) {
+ @Override
+ protected void onTerminated() {
+ FileUtil.delete(tempUnzippedArtifactOutput);
+ FileUtil.delete(new File(artifact.getOutputFilePath()));
+ copyResultsToArtifactsOutput(tempDirectory);
+ copyResultsToArtifactsOutput(tempDirWithCreatedJar);
+ }
+
+ private void copyResultsToArtifactsOutput(final File tempDirectory) {
+ try {
+ final File resultedJar = new File(artifact.getOutputPath());
+ FileUtil.copyDir(tempDirectory, resultedJar);
+ }
+ catch (IOException e) {
+ LOG.info(e);
+ }
+ FileUtil.delete(tempDirectory);
+ }
+ };
+ startProcess(commandLine, adapter);
+ }
+ catch (ExecutionException ex) {
+ registerJavaFxPackagerError(compileContext, ex);
+ }
+ }
+
+ private static void appendManifestProperties(GeneralCommandLine commandLine, final JavaFxArtifactProperties properties) {
+ final String manifestString = properties.getManifestString();
+ if (manifestString != null) {
+ commandLine.addParameter("-manifestAttrs");
+ commandLine.addParameter("\"" + manifestString + "\"");
+ }
+ }
+
+ private static void startProcess(GeneralCommandLine commandLine, MyOnTerminatedProcessAdapter adapter)
+ throws ExecutionException {
+ final OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
+ adapter.setHandler(handler);
+ handler.addProcessListener(adapter);
+ handler.startNotify();
+ }
+
+ private static abstract class MyOnTerminatedProcessAdapter extends ProcessAdapter {
+ private OSProcessHandler myHandler;
+ private final CompileContext myCompileContext;
+
+ public MyOnTerminatedProcessAdapter(CompileContext compileContext) {
+ myCompileContext = compileContext;
+ }
+
+ private void setHandler(OSProcessHandler handler) {
+ myHandler = handler;
+ }
+
+ @Override
+ public void processTerminated(ProcessEvent event) {
+ myHandler.removeProcessListener(this);
+ onTerminated();
+ }
+
+ protected abstract void onTerminated();
+
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ if (outputType == ProcessOutputTypes.STDERR) {
+ registerJavaFxPackagerError(myCompileContext, event.getText());
+ }
+ }
+ }
+}