2016-07-08 2 views
0

내가 Gradle을/그루비의에서 간단한 인쇄 문을 실행하려고하지만 오류 얻을왜 gradle이 속성 파일을 인쇄하지 않습니까?

extProgram = new Properties() 
extProgram.load(new FileInputStream("src/main/resources/version.txt")) 

ext.appVersion=extProgram['version'] 

println ext.appVersion 

이 오류가 나는 extProgram가의 속성으로 간주되기 때문이다

Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties. 
Deprecated dynamic property: "extProgram" on "root project 'appController'", value: "{}". 
2.0.193 
[buildinfo] Not using buildInfo properties file for this build. 

FAILURE: Build failed with an exception. 

* Where: 
Build file '/Users/Documents/codebase/app-controller/build.gradle' line: 54 

* What went wrong: 
A problem occurred evaluating root project 'appConroller'. 
> Could not find method $() for arguments [bui[email protected]411109d] on root project 'appController'. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 9.972 secs 

답변

2

를 얻을 수있다 프로젝트. 대신을 시도

def extProgram = new Properties() 
... 

이 로컬 변수로 extProgram을 정의합니다.

+0

다른 프로젝트에서 사용할 수 있도록 프로젝트의 속성이되고 싶습니다. –

+0

그 경우에는 다음을 사용하십시오 :'ext.extProgram = ...' – Henry

관련 문제