현재 전역 도구가 많은 libs/commons.gradle 파일을 갖기 위해 gradle 빌드를 모듈화하고 있습니다. 나는 병렬로 개발 된 소프트웨어의 다양한 브랜치들 때문에 이것을 필요로하고 모든 브랜치들간에 모든 스크립트 파일 변경을 피하기를 원한다. commons.gradle 내부 'Gradle을/입심/commons.gradle'Gradle : 가져온 스크립트에서 'def'를 어떻게 호출 할 수 있습니까?
나는 svnrevision 함수를 정의 :
부터 적용
는 그래서 "에서 적용"사용 LIB 파일이로드 것을 만들어 :...
def svnRevision = {
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager clientManager = SVNClientManager.newInstance(options);
SVNStatusClient statusClient = clientManager.getStatusClient();
SVNStatus status = statusClient.doStatus(projectDir, false);
SVNRevision revision = status.getCommittedRevision();
return revision.getNumber().toString();
}
...
내가 전화 한거야 내 포함 build.gradle에서 g 기능 :
...
task writeVersionProperties {
File f = new File(project.webAppDirName+'/WEB-INF/version.properties');
if (f.exists()) { f.delete(); }
f = new File(project.webAppDirName+'/WEB-INF/version.properties');
FileOutputStream os = new FileOutputStream(f);
os.write(("version="+svnRevision()).getBytes());
os.flush();
os.close();
}
...
는하지만에 결국 :...
FAILURE: Build failed with an exception.
* Where:
Build $PATH_TO/build20.gradle
* What went wrong:
A problem occurred evaluating root project 'DEV_7.X.X_GRADLEZATION'.
> Could not find method svnRevision() for arguments [] on root project 'DEV_7.X.X_GRADLEZATION'.
...
내 queston은입니다. 포함 된 스크립트에 정의 된 gradle의 하위 함수를 호출하려면 어떻게해야합니까?
도움을 주셨습니다. http://www.gradle.org/docs/current/userguide/writing_build_scripts.html에서
이 작품은 나를 위해. 고마워요! – gorefest