Search in sources :

Example 11 with DefaultSVNOptions

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);
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) File(java.io.File)

Aggregations

DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)11 SVNException (org.tmatesoft.svn.core.SVNException)9 File (java.io.File)6 SVNURL (org.tmatesoft.svn.core.SVNURL)4 Test (org.junit.Test)3 SVNWCContext (org.tmatesoft.svn.core.internal.wc17.SVNWCContext)3 ISVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.ISVNWCDb)3 SVNWCDb (org.tmatesoft.svn.core.internal.wc17.db.SVNWCDb)3 Nullable (org.jetbrains.annotations.Nullable)2 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)2 PathManager (com.intellij.openapi.application.PathManager)1 PluginPathManager (com.intellij.openapi.application.PluginPathManager)1 TimeoutUtil (com.intellij.util.TimeoutUtil)1 Semaphore (com.intellij.util.concurrency.Semaphore)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assert (junit.framework.Assert)1 TestCase (junit.framework.TestCase)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Before (org.junit.Before)1 ISVNDirEntryHandler (org.tmatesoft.svn.core.ISVNDirEntryHandler)1