use of org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions in project Corgi by kevinYin.
the class RepoUtil method getFinalNameForSvn.
/**
* 从 SVN 的 pom.xml 读取 finalName,读取失败抛出异常。
* 如果有返回,肯定不会为空。
*
* @param svnAddr SVN地址
* @param account SVN帐号
* @param password SVN密码
* @return
* @throws Exception
* @throws IllegalArgumentException 读取pom.xml失败抛出异常
*/
public static String getFinalNameForSvn(String svnAddr, String account, String password) throws Exception {
SVNURL url = SVNURL.parseURIEncoded(svnAddr);
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager clientManager = SVNClientManager.newInstance(options, account, password);
SVNUpdateClient updateClient = clientManager.getUpdateClient();
File tempDir = FileUtils.getTempDirectory();
String filePath = tempDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + "/";
File destPath = new File(filePath);
FileUtils.forceMkdir(destPath);
updateClient.doExport(url, destPath, null, SVNRevision.HEAD, null, true, SVNDepth.FILES);
String xml = FileUtils.readFileToString(new File(filePath + "pom.xml"), "utf-8");
FileUtils.forceDelete(destPath);
return readPomFinalName(xml);
}
Aggregations