Javafx: Add application version in JavaFX packaging (IDEA-125793)

This commit is contained in:
Pavel Dolgov
2016-04-14 17:44:58 +03:00
parent 0100d6fab5
commit f8d08a7e09
8 changed files with 122 additions and 19 deletions
@@ -59,6 +59,8 @@ public abstract class AbstractJavaFxPackager {
protected abstract String getDescription();
protected abstract String getVersion();
protected abstract String getWidth();
protected abstract String getHeight();
@@ -81,6 +81,10 @@ public class JavaFxAntGenerator {
if (preloaderFiles != null) {
applicationTag.addAttribute(Couple.of("preloaderClass", preloaderClass));
}
final String version = packager.getVersion();
if (!StringUtil.isEmptyOrSpaces(version)) {
applicationTag.addAttribute(Couple.of("version", version.trim().replaceAll("\\s", "-")));
}
appendValuesFromPropertiesFile(applicationTag, packager.getHtmlParamFile(), "fx:htmlParam", false);
//also loads fx:argument values
@@ -32,6 +32,7 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
private static final String PRELOADER_CLASS = "preloaderClass";
private static final String TITLE = "title";
private static final String VERSION = "version";
private static final String ICONS = "icons";
private static final String RELATIVE_PATH = "relativePath";
private static final String PRELOADER_JAR = "preloaderJar";
@@ -205,6 +206,35 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
.build());
}
public void testJarDeployVersion() throws Exception {
doTest("<fx:fileset id=\"all_but_jarDeployVersion\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"<exclude name=\"jarDeployVersion.jar\">\n" +
"</exclude>\n" +
"</fx:fileset>\n" +
"<fx:fileset id=\"all_jarDeployVersion\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"</fx:fileset>\n" +
"<fx:application id=\"jarDeployVersion_id\" name=\"jarDeployVersion\" mainClass=\"Main\" version=\"4.2\">\n" +
"</fx:application>\n" +
"<fx:jar destfile=\"temp/jarDeployVersion.jar\">\n" +
"<fx:application refid=\"jarDeployVersion_id\">\n" +
"</fx:application>\n" +
"<fileset dir=\"temp\" excludes=\"**/*.jar\">\n" +
"</fileset>\n" +
"<fx:resources>\n" +
"<fx:fileset refid=\"all_but_jarDeployVersion\">\n" +
"</fx:fileset>\n" +
"</fx:resources>\n" +
"</fx:jar>\n" +
"<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp/deploy\" outfile=\"jarDeployVersion\">\n" +
"<fx:application refid=\"jarDeployVersion_id\">\n" +
"</fx:application>\n" +
"<fx:resources>\n" +
"<fx:fileset refid=\"all_jarDeployVersion\">\n" +
"</fx:fileset>\n" +
"</fx:resources>\n" +
"</fx:deploy>\n", Collections.singletonMap(VERSION, "4.2"));
}
public void testJarDeploySigned() throws Exception {
doTest("<fx:fileset id=\"all_but_jarDeploySigned\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"<exclude name=\"jarDeploySigned.jar\">\n" +
@@ -288,6 +318,11 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
packager.setTitle(title);
}
final String version = options.get(VERSION);
if (version != null) {
packager.setVersion(version);
}
boolean isRelativeIconPath = Boolean.valueOf(options.get(RELATIVE_PATH));
final String icon = options.get(ICONS);
if (icon != null) {
@@ -333,6 +368,7 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
private String myTitle;
private String myVendor;
private String myDescription;
private String myVersion;
private String myHtmlParams;
private String myParams;
private String myPreloaderClass;
@@ -360,6 +396,10 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
myDescription = description;
}
private void setVersion(String version) {
myVersion = version;
}
private void setHtmlParams(String htmlParams) {
myHtmlParams = htmlParams;
}
@@ -423,6 +463,11 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
return myDescription;
}
@Override
public String getVersion() {
return myVersion;
}
@Override
protected String getWidth() {
return "800";
@@ -150,6 +150,11 @@ public class JpsJavaFxArtifactBuildTaskProvider extends ArtifactBuildTaskProvide
return myProperties.myState.getDescription();
}
@Override
protected String getVersion() {
return myProperties.myState.getVersion();
}
@Override
protected JavaFxApplicationIcons getIcons() {
return myProperties.myState.getIcons();
@@ -28,6 +28,7 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
myState.setTitle(state.myTitle);
myState.setVendor(state.myVendor);
myState.setDescription(state.myDescription);
myState.setVersion(state.myVersion);
myState.setWidth(state.myWidth);
myState.setHeight(state.myHeight);
myState.setHtmlParamFile(state.myHtmlParamFile);
@@ -61,6 +62,7 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
private String myVendor;
private String myDescription;
private String myAppClass;
private String myVersion;
private String myWidth = JavaFxPackagerConstants.DEFAULT_WEIGHT;
private String myHeight = JavaFxPackagerConstants.DEFAULT_HEIGHT;
private String myHtmlParamFile;
@@ -101,6 +103,14 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
myDescription = description;
}
public String getVersion() {
return myVersion;
}
public void setVersion(String version) {
myVersion = version;
}
public JavaFxApplicationIcons getIcons() {
return myIcons;
}
@@ -57,6 +57,7 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
private String myVendor;
private String myDescription;
private String myAppClass;
private String myVersion;
private String myWidth = JavaFxPackagerConstants.DEFAULT_WEIGHT;
private String myHeight = JavaFxPackagerConstants.DEFAULT_HEIGHT;
private String myHtmlParamFile;
@@ -166,6 +167,14 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
myAppClass = appClass;
}
public String getVersion() {
return myVersion;
}
public void setVersion(String version) {
myVersion = version;
}
public String getWidth() {
return myWidth;
}
@@ -369,6 +378,11 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
return myProperties.getDescription();
}
@Override
protected String getVersion() {
return myProperties.getVersion();
}
@Override
protected JavaFxApplicationIcons getIcons() {
return myProperties.getIcons();
@@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="ca833" layout-manager="GridLayoutManager" row-count="14" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="ca833" layout-manager="GridLayoutManager" row-count="15" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -91,7 +91,7 @@
</component>
<component id="5a049" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="fde94"/>
@@ -100,7 +100,7 @@
</component>
<component id="fde94" class="javax.swing.JTextField" binding="myWidthTF">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -108,7 +108,7 @@
</component>
<component id="fcef9" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="2a255"/>
@@ -117,7 +117,7 @@
</component>
<component id="2a255" class="javax.swing.JTextField" binding="myHeightTF">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -125,7 +125,7 @@
</component>
<component id="d5f8c" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="b2b7a"/>
@@ -134,13 +134,13 @@
</component>
<component id="b2b7a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myHtmlParams">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="db3d4" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="be63e"/>
@@ -149,13 +149,13 @@
</component>
<component id="be63e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myParams">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="4a8b2" class="javax.swing.JCheckBox" binding="myUpdateInBackgroundCB">
<constraints>
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Update in &amp;background"/>
@@ -163,7 +163,7 @@
</component>
<component id="b03bd" class="javax.swing.JCheckBox" binding="myEnableSigningCB">
<constraints>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable &amp;signing"/>
@@ -172,7 +172,7 @@
<grid id="506ce" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -194,7 +194,7 @@
</grid>
<component id="8bb5f" class="javax.swing.JCheckBox" binding="myConvertCssToBinCheckBox" default-binding="true">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Convert css to bin"/>
@@ -202,7 +202,7 @@
</component>
<component id="9164e" class="javax.swing.JLabel">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="2acc4"/>
@@ -211,13 +211,13 @@
</component>
<component id="2acc4" class="javax.swing.JComboBox" binding="myNativeBundleCB">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="7d6a7" class="javax.swing.JLabel">
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Custom manifest attributes"/>
@@ -226,7 +226,7 @@
<grid id="cd6c2" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -249,7 +249,7 @@
<grid id="9d065" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="14" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -271,12 +271,31 @@
</grid>
<component id="b08ee" class="javax.swing.JLabel">
<constraints>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Application icon"/>
</properties>
</component>
<component id="c9cb5" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="78c4b"/>
<text value="V&amp;ersion"/>
</properties>
</component>
<component id="78c4b" class="javax.swing.JTextField" binding="myVersionTF">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
</children>
</grid>
<vspacer id="1a12e">
@@ -52,6 +52,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private JTextField myVendorTF;
private JEditorPane myDescriptionEditorPane;
private TextFieldWithBrowseButton myAppClass;
private JTextField myVersionTF;
private JTextField myWidthTF;
private JTextField myHeightTF;
private TextFieldWithBrowseButton myHtmlParams;
@@ -128,6 +129,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
if (isModified(myProperties.getWidth(), myWidthTF)) return true;
if (isModified(myProperties.getHeight(), myHeightTF)) return true;
if (isModified(myProperties.getAppClass(), myAppClass)) return true;
if (isModified(myProperties.getVersion(), myVersionTF)) return true;
if (isModified(myProperties.getHtmlParamFile(), myHtmlParams)) return true;
if (isModified(myProperties.getParamFile(), myParams)) return true;
if (!Comparing.equal(myNativeBundleCB.getSelectedItem(), myProperties.getNativeBundle())) return true;
@@ -164,6 +166,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
myProperties.setVendor(myVendorTF.getText());
myProperties.setDescription(myDescriptionEditorPane.getText());
myProperties.setAppClass(myAppClass.getText());
myProperties.setVersion(myVersionTF.getText());
myProperties.setWidth(myWidthTF.getText());
myProperties.setHeight(myHeightTF.getText());
myProperties.setHtmlParamFile(myHtmlParams.getText());
@@ -201,6 +204,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
setText(myWidthTF, myProperties.getWidth());
setText(myHeightTF, myProperties.getHeight());
setText(myAppClass, myProperties.getAppClass());
setText(myVersionTF, myProperties.getVersion());
setText(myHtmlParams, myProperties.getHtmlParamFile());
setText(myParams, myProperties.getParamFile());
myNativeBundleCB.setSelectedItem(myProperties.getNativeBundle());