Build Number Maven Pluginの使い方


Build Number Maven Pluginの使い方
1.Build Number Maven Pluginはsvnのバージョンとブランチディレクトリを取得するために使用されています.アプリケーションで使用できます.
2.まず、Mavenのsetting.xmlにこのプラグインをダウンロードするための倉庫を追加します.
				<pluginRepository>
					<id>codehaus</id>
					<name>codehaus</name>
					<url>http://repository.codehaus.org</url>
				</pluginRepository>
3.pomファイルにプラグインを使用して、svnのバージョンと分岐をMETA-INFO/MANIFEST.MFに書き込みます.
4.確認効果:工事の下でmvn cleaninstall-DskyipTests=trueを実行し、包装後、カバンの中のMETA-INFO/MANIFEST.MFファイルを確認する:
5.プログラムで引用する方法:
System.out.println("Get source branch and version from META-INF/MANIFEST.MF...");
		String appServerHome = arg0.getServletContext().getRealPath("/");
		File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
		Manifest mf = new Manifest();
		try {
			mf.read(new FileInputStream(manifestFile));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		Attributes atts = mf.getMainAttributes();
		System.out.println("Source Branch: "
				+ atts.getValue("Implementation-Branch"));
		System.out.println("Source Version: "
				+ atts.getValue("Implementation-Version"));
コンソールを通して、私達はすでに私達の欲しいバージョンと分岐を得たことを見ました.
6.参考:
http://mojo.codehaus.org/buildnumber-maven-plugin/http://apollo.ucalgary.ca/tlcprojectswiki/index.php/Public/Project_Verssioning_-uベスト.Practices