How does izpack.selected work

瀏覽次數:112 次
跳到第一則未讀訊息

Stefan Murawski

未讀,
2015年7月16日 清晨5:34:012015/7/16
收件者:izpac...@googlegroups.com
Hi,

I am trying to make a Panel only appear when a condition is met (i.e. a specific pack is selected)

According to the Documentation (https://izpack.atlassian.net/wiki/display/IZPACK/Predefined+Conditions the following should work:

        <panel classname="org.ninjoworkstation.izpack.panels.NinJoDataTargetPanel" condition="izpack.selected.NinJo_ArchiveClient"/>

With 

<pack name="NinJo_AutomationClient" required="no" id="automationclient.pack">

But when building with Maven I get the following exception:

Invalid condition expression 'izpack.selected.NinJo_ArchiveClient' 


Kind regards,
Stefan Murawski

Stefan Murawski

未讀,
2015年7月16日 清晨7:47:282015/7/16
收件者:izpac...@googlegroups.com
The second part of the above was a copy&paste error.
There is a 
<pack name="NinJo_ArchiveClient" required="no" id="archiveclient.pack">

present of course.

René Krell

未讀,
2015年7月23日 凌晨4:34:552015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
This error comes up if the condition cannot be found, but from the code the "izpack.selected.<packname>" conditions are initialized 
Can you please provide the whole log with a stacktrace, maybe running using mvn -X ?
Thanks,
René

Dne čtvrtek 16. července 2015 11:34:01 UTC+2 Stefan Murawski napsal(a):

René Krell

未讀,
2015年7月23日 清晨5:06:462015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
I tried to reproduce this:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<izpack:installation version="5.0"
                     xmlns:izpack="http://izpack.org/schema/installation"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  <info>
    <appname>@{info.appName}</appname>
    <appsubpath>@{info.appsubpath}</appsubpath>
    <appversion>@{info.appversion}</appversion>
    <authors>
      <author name="@{info.company.name}" email="@{info.company.email}"/>
    </authors>
    <url>@{info.url}</url>
    <javaversion>1.6</javaversion>
    <uninstaller write="false"/>
    <writeinstallationinformation>false</writeinstallationinformation>
    <rebootaction>ignore</rebootaction>
  </info>

  <guiprefs width="800" height="600" resizable="no">
    <modifier key="labelGap" value="2" />
    <modifier key="useHeadingPanel" value="yes" />
    <modifier key="useHeadingForSummary" value="yes" />
    <modifier key="headingLineCount" value="1" />
    <modifier key="headingFontSize" value="1.5" />
    <modifier key="headingBackgroundColor" value="0x00ffffff" />
  </guiprefs>

  <locale>
    <langpack iso3="eng"/>
  </locale>

  <resources>
    <res id="userInputLang.xml_eng" src="@{izpack.build.directory}/i18n/userInputLang.xml_eng" />
    <res id="userInputSpec.xml" src="@{izpack.build.directory}/userInputSpec.xml" />
  </resources>

  <panels>
    <panel classname="TargetPanel" id="panel.target"/>
    <panel classname="UserInputPanel" id="panel.test" condition="izpack.selected.Example Core"/>
    <panel classname="SummaryPanel"/>
    <!--<panel classname="InstallPanel"/>-->
    <panel classname="FinishPanel"/>
  </panels>

  <packs>
    <pack name="Example Core" required="yes" id="core.package">
      <description>The core files required for $APP_NAME</description>
    </pack>
  </packs>

</izpack:installation>

This example compiles normally.

René Krell

未讀,
2015年7月23日 清晨6:28:282015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
Got to revert what I wrote, this is a bug. I can finally reproduce this.
Can you file an issue in JIRA, please?
Thanks, René

René Krell

未讀,
2015年7月23日 清晨6:38:172015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
I added an issue: https://izpack.atlassian.net/browse/IZPACK-1266
No need to do anything else, just fix or wait.

Stefan Murawski

未讀,
2015年7月23日 清晨7:04:132015/7/23
收件者:izpack-user、renda...@gmail.com
Thanks for having a look at this!

Cheers,
Stefan

René Krell

未讀,
2015年7月23日 上午8:03:422015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
I sent a pull request with a fix: https://github.com/izpack/izpack/pull/376.
Conditions are now collected and evaluated at the end of the compilation process instead of validating them too early immediately after they have been parsed. In the meantime, the compiler adds all pack selection condition for the packs it parses.
Should go into 5.0.2. I can deploy a 5.0.2-SNAPSHOT if you want to try this directly from Maven.

Stefan Murawski

未讀,
2015年7月23日 上午8:41:162015/7/23
收件者:izpack-user、renda...@gmail.com
You don't need to deploy a Snapshot. I can wait for the  5.0.2 release (if it is not too far in the future ;) ).

Thanks again!
Stefan

René Krell

未讀,
2015年7月23日 下午5:42:092015/7/23
收件者:izpack-user、stm...@gmail.com、stm...@gmail.com
The fix is released in 5.0.2. Give it a try.

Stefan Murawski

未讀,
2015年11月23日 上午9:43:372015/11/23
收件者:izpack-user、stm...@gmail.com
I tried it today in Version 5.0.3

This 
<panel classname="UserInputPanel" id="panel.test" condition="izpack.selected.Example Core"/>
seems to work. 
But <panel classname="UserInputPanel" id="panel.test" condition="izpack.selected.Example Core || izpack.selected.Example Core2"/>

or 

But <panel classname="UserInputPanel" id="panel.test" condition="{{izpack.selected.Example Core || izpack.selected.Example Core2}}"/>

Did not.

I tried to write a "and" condition, but this didn't work either:

       <condition type="and" id="showDataPanel">
       <condition type="ref" refid="izpack.selected.Example Core"/>
       <condition type="ref" refid="izpack.selectedExample Core2">
    </condition>

René Krell

未讀,
2015年12月1日 清晨6:20:232015/12/1
收件者:izpack-user、stm...@gmail.com
Did you use the value of the attribute <pack name="..."> instead of <pack id="..."> as the suffix to izpack.select.suffix?
René

Stefan Murawski

未讀,
2015年12月1日 上午8:35:142015/12/1
收件者:izpack-user、stm...@gmail.com
Hi René,

thanks for the feedback.

for the inline condtions like: 

<panel classname="UserInputPanel" id="panel.test" condition="{{izpack.selected.Example Core || izpack.selected.Example Core2}}"/>

I used the name of the pack.

After reading the Documentation again I wrote a compound condition, which was accepted by the compiler:

        <condition type="or" id="showDataPanel">
       <condition type="packselection">
        <name>NinJo_AutomationClient</name>
       </condition>
       <condition type="packselection">
        <name>NinJo_ArchiveClient</name>
       </condition>
    </condition>

<panel classname="org.ninjoworkstation.izpack.panels.NinJoDataTargetPanel" condition="showDataPanel"/>

<pack name="NinJo_AutomationClient" required="no" id="automationclient.pack">....
<pack name="NinJo_ArchiveClient" required="no" id="archiveclient.pack">.....


But threw the following Exception:

Exception in thread "AWT-EventQueue-0" com.izforge.izpack.api.exception.IzPackException: java.lang.NullPointerException
        at com.izforge.izpack.installer.bootstrap.InstallerGui$1.run(InstallerGui.java:68)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
        at java.awt.EventQueue.access$300(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:706)
        at java.awt.EventQueue$3.run(EventQueue.java:704)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.NullPointerException
        at com.izforge.izpack.core.rules.process.PackSelectionCondition.isTrue(PackSelectionCondition.java:83)
        at com.izforge.izpack.core.rules.logic.OrCondition.isTrue(OrCondition.java:68)
        at com.izforge.izpack.core.rules.RulesEngineImpl.isConditionTrue(RulesEngineImpl.java:352)
        at com.izforge.izpack.installer.debugger.Debugger.init(Debugger.java:104)
        at com.izforge.izpack.installer.debugger.Debugger.<init>(Debugger.java:87)
        at com.izforge.izpack.installer.gui.InstallerFrame.buildGUI(InstallerFrame.java:366)
        at com.izforge.izpack.installer.gui.InstallerController$1.run(InstallerController.java:35)
        at com.izforge.izpack.installer.gui.InstallerController.run(InstallerController.java:64)
        at com.izforge.izpack.installer.gui.InstallerController.buildInstallation(InstallerController.java:30)
        at com.izforge.izpack.installer.bootstrap.InstallerGui$1.run(InstallerGui.java:64)
        ... 14 more


Kind regards,
Stefan

René Krell

未讀,
2015年12月1日 上午8:51:552015/12/1
收件者:izpack-user、stm...@gmail.com
Wow, good catch.
NullPointerExceptions are always a good reason for creating a new issue, regardless of the reason for it. This should be fixed as soon as possible.
This is an implementation error in PackSelectionCondition.
Thanks for figuring this out.
René

Stefan Murawski

未讀,
2015年12月2日 上午8:02:172015/12/2
收件者:izpack-user、stm...@gmail.com
Should I file a bug accordingly, or did you file one?

René Krell

未讀,
2015年12月2日 上午8:15:332015/12/2
收件者:izpack-user、stm...@gmail.com
I haven't done anything with this to this time, it would be nice if you'd file one.


Dne středa 2. prosince 2015 14:02:17 UTC+1 Stefan Murawski napsal(a):
回覆所有人
回覆作者
轉寄
0 則新訊息