我在 Ant 脚本中使用 javascript 将运行时网络远程文件夹值作为输入传递。 传递该值后,我发现输入文件夹路径是否存在。 但我无法做到这一点。我的代码如下。
<script language="javascript">
<![CDATA[
importPackage(javax.io);
importPackage(javax.swing);
importPackage(java.lang);
var deployment_machine = project.getProperty("var2");
var deployment_machine = deployment_machine.substring(2,deployment_machine.indexOf("$")-2);
var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ' + deployment_machine + '?', null );
var path = require('optionPane');
if (path.existsSync("/the/path")) {
// ...
}
if(!fso.FolderExists(optionPane))
{
var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ?', deployment_machine );
}
else
{
project.setProperty('deploy_loc',optionPane);
}
]]>
</script>
</then>
<else>
<echo message="File need to check:- ${patch.path}/${patch.name}/GatewayFW_patch.zip is not exist"/>
</else>
'
谁能帮我解决请?
<script language="javascript">
<![CDATA[
importPackage(java.io);
importPackage(javax.swing);
importPackage(java.lang);
var deployment_machine = project.getProperty("var2");
var deployment_machine = deployment_machine.substring(2,deployment_machine.indexOf("$")-2);
在这里,我们必须将 File("文件夹路径")分配给一个 JavaScript 变量,如上所示 var=dir =new File("文件夹路径");然后我们可以在路径上执行任何操作。
do
{
var optionPane = JOptionPane.showInputDialog( 'Deployment location for GatewayFW in ' + deployment_machine + '?', null );
var dir = new File(optionPane);
}
while(!dir.exists());
project.setProperty('deploy_loc',optionPane);
]]>
</script>