2013-11-20 2 views
0

grails clean, grails compile 및 grails run-app를 실행하기위한 그루비 스크립트를 만들고 싶었습니다. 그러나 grails 명령을 실행할 수없는 것으로 나타났습니다.grails 명령을 실행하는 Groovy 스크립트

def envs = System.getenv().collect{"$it.key=$it.value"} 
    //println envs 
    println "java -version".execute(envs, new File("c:\\")).err.text 
    println "grails -version".execute(envs, new File("c:\\")).text 

이 자체가 나에게 다음과 같은 출력을 제공합니다 :

groovy> def envs = System.getenv().collect{"$it.key=$it.value"} 
groovy> //println envs 
groovy> println "java -version".execute(envs, new File("c:\\")).err.text 
groovy> println "grails -version".execute(envs, new File("c:\\")).text 


    java version "1.7.0_06" 
    Java(TM) SE Runtime Environment (build 1.7.0_06-b24) 
    Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode) 

    Exception thrown 

    java.io.IOException: Cannot run program "grails" (in directory "c:\"): CreateProcess error=2, The system cannot find the file specified 

     at ConsoleScript26.run(ConsoleScript26:4) 

    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified 

     ... 1 more 

사람이 전에이 문제에 직면했습니다 사실 그때는 그루비 콘솔에서 다음 스크립트를 실행하려고?

답변

1

grails 명령은 .bat 파일이며, 직접 (어떤 "...".execute 궁극적 대표로있는) Runtime.exec 또는 ProcessBuilder를 사용하여 .bat 파일을 실행할 수 없습니다.

사용 cmd /c :

println ["cmd", "/c", "grails -version"].execute(envs, new File("c:\\")).text 

또는 가능

println ["cmd", "/c", "grails", "-version"].execute(envs, new File("c:\\")).text 

나는 "으로 Grails -version"는 하나 개의 인수해야하는지 여부를 모르겠어요 두 (그것은 두 가지 작동하는지 수 있습니다 , 나는 현재 이것을 시험 할 입장이 아니다.)

0

java - version이 실행되고 grails -version이 아닌 경우 사용자가 PATH 환경 변수를 업데이트하지 않았다는 의미입니다. 변수에 bin 폴더의 위치를 ​​추가하십시오.

Grails는 단지 우편이므로, 수동으로해야합니다.

Windows에서
관련 문제