제 의견에 '자식 묘사'의 결과를 보여 드리고자합니다. 값을 업데이트하고 응용 프로그램 전체에 설정하는 플러그인을 작성해야합니까? 아니면 이것을 할 수있는 더 쉬운 방법이 있습니까?재생 프레임 워크를 사용하여 'git describe'의 출력을 템플릿에 넣으시겠습니까?
4
A
답변
3
난 그냥 플레이 모듈에 대해 읽고 나는 내 문제를 해결할 수 있는지 확인하기 위해 하나 (https://github.com/killdashnine/play-git-plugin)을 쓰기로 결정했습니다 : 내 컨트롤러에서
12:14:46,508 INFO ~ GIT plugin: executing 'git describe'
12:14:46,513 INFO ~ GIT plugin: revision is V0-beta-7-gac9af80
: 결과
import java.io.BufferedReader;
import java.io.InputStreamReader;
import play.Logger;
import play.Play;
import play.PlayPlugin;
public class GitPlugin extends PlayPlugin {
private static String GIT_PLUGIN_PREFIX = "GIT plugin: ";
@Override
public void onApplicationStart() {
Logger.info(GIT_PLUGIN_PREFIX + "executing 'git describe'");
final StringBuffer gitVersion = new StringBuffer();
try {
final Process p = Runtime.getRuntime().exec("git describe");
final BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
// wait for process to complete
p.waitFor();
// read the output
String line = reader.readLine();
while(line != null) {
gitVersion.append(line);
line = reader.readLine();
}
}
catch(Exception e) {
Logger.error(GIT_PLUGIN_PREFIX + "unable to execute 'git describe'");
}
// set a property for this value
Play.configuration.setProperty("git.revision", gitVersion.toString());
Logger.info(GIT_PLUGIN_PREFIX + "revision is " + gitVersion.toString());
}
}
을 :
@Before
static void addDefaults() {
renderArgs.put("version", Play.configuration.getProperty("git.revision"));
}
물론 이식성이 뛰어나고 개선 될 수 있습니다. 가능한 개선은 구성 파일의 설정을 통해 사용자 정의 명령을 실행할 수있게하는 것입니다.
cat > {apppath}/conf/application_version.properties << EOF
application.version=`git describe`
application.buildtime=`date`
EOF
...
과에서를 : 당신이 나처럼 할 수있는 자식의 repo에서 코드를 실행하지 않으면
1
, 난 전쟁 파일을 생성하고이 스크립트에 내가 할거야 빌드 스크립트가 @OnApplicationStart 클래스는 내가 속성
private def readApplicationVersion() {
Logger.info("Bootstrap.readApplicationVersion file")
Play.id match {
case "" | "test" => Play.configuration.put("application.version", "TEST-MODE"); Play.configuration.put("application.buildtime", "YEAH BABY YEAH REALTIME")
case _ => addFileProp(VirtualFile.open(Play.applicationPath).child("conf/application_version.properties").inputstream())
}
}
private def addFileProp(input: InputStream) {
input match {
case null => Logger.error("can't find config file, Play id: " + Play.id + ". Will exit now.")
case _ => val extendCconfiguration = IO.readUtf8Properties(input);
for (key <- extendCconfiguration.keys) {
Play.configuration.put(key, extendCconfiguration.get(key))
}
}
}
그리고 컨트롤러에서
를 추가object ApplicationVersion extends Controller {
def version = {
Json("{iamVersion: '"+configuration.getProperty("application.version")+"', buildTime: '"+configuration.getProperty("application.buildtime")+"'}")
}
}
관련 문제
- 1. cURL - 출력을 변수에 넣으시겠습니까?
- 2. 엔터티 프레임 워크를 사용하여 파일로드
- 3. 엔터티 프레임 워크를 사용하여 GetUTCDate
- 4. ActiveJDBC로 프레임 워크 재생
- 5. 엔티티 프레임 워크를 사용하여 엔티티와 데이터베이스 매핑
- 6. WebKit 프레임 워크를 사용하여 swf 파일 열기
- 7. TWAnalyzerClient 프레임 워크를 사용하여 중복 된 ASIHTTPRequest.h
- 8. NSMutableArray를 JSON- 프레임 워크를 사용하여 JSON으로 보냄
- 9. ado.net 엔터티 프레임 워크를 사용하여 gridview 정렬
- 10. 누구나 줄무늬 프레임 워크를 사용하여 스칼라를 시도했습니다.
- 11. symfony 프레임 워크를 사용하여 PDF 파일 생성
- 12. ADO.Net 엔터티 프레임 워크를 사용하여 삭제하는 방법
- 13. DI 프레임 워크를 사용하여 현지화 - 좋은 생각이십니까?
- 14. qt 프레임 워크를 사용하여 아카이브 조작
- 15. 엔티티 프레임 워크를 사용하여 테이블을 탐색하려면 어떻게해야합니까?
- 16. 젠드 프레임 워크를 사용하여 트리 dijit 표시
- 17. 젠드 프레임 워크를 사용하여 특정 뷰를로드하려면 어떻게해야합니까?
- 18. 엔티티 프레임 워크를 사용하여 "Col1, Col2로 주문"
- 19. 엔티티 프레임 워크를 사용하여 데이터베이스에 파일 저장
- 20. 그리드 CSS 프레임 워크를 사용하여 찬반 양론
- 21. XMPP 프레임 워크를 사용하여 메시지를 보내는 방법
- 22. 엔티티 프레임 워크를 사용하여 uniqueidentifier를 반환합니다.
- 23. 젠드 프레임 워크를 사용하여 이메일을 검색하려면 어떻게해야합니까?
- 24. 젠드 프레임 워크를 사용하여 세션을 저장하고 싶습니다
- 25. 엔티티 프레임 워크를 사용하여 데이터베이스를 채우는 방법
- 26. 왜 프레임 워크를 사용합니까? 내가 젠드 프레임 워크를 파악하고 그것을
- 27. CSS 프레임 워크를 사용합니까?
- 28. 리소스 프레임 워크를 빌드하려면
- 29. 스냅 프레임 워크를 사용하는 하스켈 코드 배포
- 30. Qt 프레임 워크를 사용하여 MAC에 Qt 응용 프로그램 배포