mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 09:03:31 +07:00
javafx packaging: simple ant createJar/deploy tasks
(cherry picked from commit ded289e9fe3c48e5a888d06fccb38350f3fb1bca)
This commit is contained in:
+84
-2
@@ -15,8 +15,17 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.packaging;
|
||||
|
||||
import com.intellij.compiler.ant.BuildProperties;
|
||||
import com.intellij.compiler.ant.Generator;
|
||||
import com.intellij.compiler.ant.Tag;
|
||||
import com.intellij.compiler.ant.artifacts.DirectoryAntCopyInstructionCreator;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.impl.elements.CompositeElementWithManifest;
|
||||
@@ -26,7 +35,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -56,7 +65,80 @@ public class JavaFxRootPackagingElement extends CompositeElementWithManifest<Jav
|
||||
@NotNull AntCopyInstructionCreator creator,
|
||||
@NotNull ArtifactAntGenerationContext generationContext,
|
||||
@NotNull ArtifactType artifactType) {
|
||||
return Collections.emptyList();
|
||||
final String artifactName = FileUtil.getNameWithoutExtension(myArtifactFile);
|
||||
String tempPathToFileSet = BuildProperties.propertyRef("artifact.temp.output." + artifactName);
|
||||
for (Generator generator : computeChildrenGenerators(resolvingContext, new DirectoryAntCopyInstructionCreator(tempPathToFileSet),
|
||||
generationContext, artifactType)) {
|
||||
generationContext.runBeforeCurrentArtifact(generator);
|
||||
}
|
||||
final Sdk[] jdks = BuildProperties.getUsedJdks(resolvingContext.getProject());
|
||||
Sdk javaSdk = null;
|
||||
for (Sdk jdk : jdks) {
|
||||
if (jdk.getSdkType() instanceof JavaSdkType) {
|
||||
javaSdk = jdk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (javaSdk != null) {
|
||||
final Tag taskdef = new Tag("taskdef",
|
||||
new Pair<String, String>("resource", "com/sun/javafx/tools/ant/antlib.xml"),
|
||||
new Pair<String, String>("uri", "javafx:com.sun.javafx.tools.ant"),
|
||||
new Pair<String, String>("classpath", BuildProperties.propertyRef(
|
||||
BuildProperties.getJdkHomeProperty(javaSdk.getName())) + "/lib/ant-javafx.jar"));
|
||||
generationContext.runBeforeCurrentArtifact(taskdef);
|
||||
|
||||
final Artifact artifact = ArtifactManager.getInstance(resolvingContext.getProject()).findArtifact(artifactName);
|
||||
if (artifact != null) {
|
||||
final JavaFxArtifactProperties properties =
|
||||
(JavaFxArtifactProperties)artifact.getProperties(JavaFxArtifactPropertiesProvider.getInstance());
|
||||
|
||||
final Pair<String, String> namespacePair = new Pair<String, String>("xmlns:fx", "javafx:com.sun.javafx.tools.ant");
|
||||
|
||||
//register application
|
||||
final String appId = artifactName + "_id";
|
||||
final Tag applicationTag = new Tag("fx:application",
|
||||
new Pair<String, String>("id", appId),
|
||||
new Pair<String, String>("name", artifactName),
|
||||
new Pair<String, String>("mainClass", properties.getAppClass()),
|
||||
namespacePair);
|
||||
generationContext.runBeforeCurrentArtifact(applicationTag);
|
||||
|
||||
//create jar task
|
||||
final Tag createJarTag = new Tag("fx:jar",
|
||||
new Pair<String, String>("destfile", tempPathToFileSet + "/" + myArtifactFile),
|
||||
namespacePair);
|
||||
createJarTag.add(new Tag("fx:application", new Pair<String, String>("refid", appId)));
|
||||
createJarTag.add(new Tag("fileset", new Pair<String, String>("dir", tempPathToFileSet)));
|
||||
generationContext.runBeforeCurrentArtifact(createJarTag);
|
||||
|
||||
//deploy task
|
||||
final Tag deployTag = new Tag("fx:deploy",
|
||||
new Pair<String, String>("width", properties.getWidth()),
|
||||
new Pair<String, String>("height", properties.getHeight()),
|
||||
new Pair<String, String>("updatemode", properties.getUpdateMode()),
|
||||
new Pair<String, String>("outdir", tempPathToFileSet + "/deploy"),
|
||||
new Pair<String, String>("outfile", artifactName),
|
||||
namespacePair);
|
||||
deployTag.add(new Tag("fx:application", new Pair<String, String>("refid", appId)));
|
||||
|
||||
deployTag.add(new Tag("fx:info",
|
||||
new Pair<String, String>("title", properties.getTitle()),
|
||||
new Pair<String, String>("vendor", properties.getVendor()),
|
||||
new Pair<String, String>("description", properties.getDescription())));
|
||||
final Tag deployResourcesTag = new Tag("fx:resources");
|
||||
deployResourcesTag.add(new Tag("fx:fileset", new Pair<String, String>("dir", tempPathToFileSet), new Pair<String, String>("includes", myArtifactFile)));
|
||||
deployTag.add(deployResourcesTag);
|
||||
|
||||
generationContext.runBeforeCurrentArtifact(deployTag);
|
||||
}
|
||||
}
|
||||
final Tag deleteTag = new Tag("delete", new Pair<String, String>("includeemptydirs", "true"));
|
||||
final Tag deleteFileSetTag = new Tag("fileset", new Pair<String, String>("dir", "${artifact.temp.output.unnamed}"));
|
||||
deleteFileSetTag.add(new Tag("exclude", new Pair<String, String>("name", artifactName + ".jar")));
|
||||
deleteFileSetTag.add(new Tag("exclude", new Pair<String, String>("name", artifactName + ".jnlp")));
|
||||
deleteFileSetTag.add(new Tag("exclude", new Pair<String, String>("name", artifactName + ".html")));
|
||||
deleteTag.add(deleteFileSetTag);
|
||||
return Arrays.asList(creator.createDirectoryContentCopyInstruction(tempPathToFileSet + "/deploy"), deleteTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user