2013-10-25 77 views
0

我使用ant来打包基于JavaFX的应用程序。做实际的JavaFX的东西没有问题,但fx:jar不支持ifcondition标签。我想动态地包含一些特定于平台的库,具体取决于我设置的变量。目前我有这个:Ant JavaFX包含If

<fx:fileset dir="/my/classes/folder"> 
    <include name="**/*lib1.dylib" if="??"/> 
    <include name="**/*lib2.dll" if="??" /> 
    <include name="**/*lib3.dll" if="??" /> 
</fx:fileset> 

我想运行这个目标多次,不同的变量值取决于平台。看来你不能这样做:

<include name="**/*lib3.dll" if="platform=mac" /> 

所以我卡住了。请帮忙!

回答

0

下面是你一个链接:How to make a conditional decision in an Ant build script based on operating system

而且包含在页面一块Ant脚本:

<condition property="isMac"> 
    <os family="mac" /> 
</condition> 

<condition property="isWindows"> 
    <os family="windows" /> 
</condition> 

<condition property="isUnix"> 
    <os family="unix" /> 
</condition> 

... 

<fx:fileset dir="/my/classes/folder"> 
    <include name="**/*lib1.dylib" if="isMac"/> 
    <include name="**/*lib2.dll" if="isWindows" /> 
    <include name="**/*lib3.dll" if="isUnix" /> 
</fx:fileset> 
0

我建议你复制你想要有条件地包含在另一个文件中,建当前目录,然后在该目录的<fx:jar>中包含<fx:fileset>

0

我最终使用下列内容:

<target name="all" depends="getDependencies"> 

     <!-- Built x86 jars --> 
     <antcall target="-buildModes"> 
      <param name="platform" value = "Win86"/> 
      <param name="platform.x86" value="true"/> 
     </antcall> 

     <!-- Built x64 jars --> 
     <antcall target="-buildModes"> 
       <param name="platform" value = "Win64"/> 
      <param name="platform.x64" value="true"/> 
     </antcall> 

     <!-- Built mac jars --> 
     <antcall target="-buildModes"> 
       <param name="platform" value = "Mac"/> 
      <param name="platform.mac" value="true"/> 
     </antcall> 
    </target> 

它通过平台参数,使得目标具有每一次新版本。全局参数是不可变的。