【发布时间】:2014-01-03 23:32:32
【问题描述】:
我的 gradle 任务应该在 Windows 操作系统上创建 Websphere 配置文件
task createProfile(type:Exec) {
def commandToExecute = new StringBuffer()
def profile = 'AppSrv02'
def wasHome = 'C:/IBM new/WebSphere/AppServer'
def str = new LinkedList <String> ();
str.add('cmd')
str.add('/c')
str.add(wasHome + '/bin/manageprofiles.bat')
str.add('-create')
str.add('-profileName')
str.add(profile)
//str.add('-templatePath')
//str.add(wasHome + '/profileTemplates/default')
println (str)
commandLine str.toArray()
}
如果我在任务失败后取消注释注释行并告诉我:“C:/IBM”不是有效的批处理文件,则会出现问题。如果我将 profileTemplates 不在包含空格的文件夹中,则一切正常。但是模板应该位于 int wasHome( 有时 wasHome 有空格(
我现在知道为什么添加带有空格的值的模板键会影响 Gradle 尝试启动“C:/IBM”而不是指定“C:/IBM new/WebSphere/AppServer/bin/manageprofiles.bat” .似乎 java.lang.ProcessBuilder 内部可能存在问题。
我尝试通过添加 "/"" 来引用路径,但没有任何效果((((这并不奇怪,因为 ProcessBuilder 暗示在需要时自行引用。
所以,我想问是否有人有类似的问题,可以推荐如何解决这个问题?提前致谢。
【问题讨论】:
标签: batch-file gradle exec spaces processbuilder