2014-09-24 7 views

답변

1

커맨드 라인에서 실행할 때 다양한 JAX-RS JAR 파일을 제공해야합니다. 이것은 Gradle의 configurations.runtime.asPath 속성을 사용하여 매우 간단했습니다.이 속성은 프로젝트를 빌드 할 때 이미 해결하고 있던 모든 RESTEasy 객체를 통과했습니다.

import org.apache.tools.ant.taskdefs.condition.Os 

task enunciate(type:Exec) { 
    if (Os.isFamily(Os.FAMILY_WINDOWS)) { 
     //on windows: 
     commandLine 'cmd', '/c', 
     'enunciate-1.29\\bin\\enunciate.bat -Edocs docs -f enunciate.xml -cp "' + configurations.runtime.asPath + 
     '" src/com/company/rest/RestApi.java' 
    } else { 
     //on linux 
     commandLine './enunciate-1.29/bin/enunciate -Edocs docs -f enunciate.xml -cp "' + configurations.runtime.asPath + 
     " src/com/company/rest/RestApi.java' 
    } 

    //store the output instead of printing to the console: 
    standardOutput = new ByteArrayOutputStream() 

    //extension method stopTomcat.output() can be used to obtain the output: 
    ext.output = { 
    return standardOutput.toString() 
    } 
}