java编写SVN统计代码数量

首先下载statsvn.jar,下载链接如下 

https://github.com/AusHick/StatSVN/releases/tag/v0.7.1

java编写SVN统计代码数量,生成分析报告如下: 

public class SVNTongji {

    //项目路径
    private static final String projectPath = "F:\\MyWork\\SVN\\baogaotongji";

    //statsvn.jar路径
    private static final String statsvnPath = "F:\\statsvn";

    //分析报告输出路径
    private static final String outputPath = "F:\\svnLog";

    public static void main(String[] args) {
        try {
            String svn = "svn log -v --xml > logfile.log";
            System.out.println("======生成logfile.log开始=====");
            StringBuffer svncommand = new StringBuffer();
            //切换到项目路径,项目在F盘
            svncommand.append("cmd /c f:");
            svncommand.append(String.format(" && cd %s", projectPath));
            svncommand.append(String.format(" && " + svn));
            Runtime.getRuntime().exec(svncommand.toString());
            System.out.println("======生成logfile.log结束=====");

            System.out.println("======生成代码统计,生成分析报告开始=====");
            StringBuffer command = new StringBuffer();
            //切换到statsvn.jar所在路径,statsvn.jar项目在F盘
            command.append("cmd /c f:");
            //这里的&&在多条语句的情况下使用,表示等上一条语句执行成功后在执行下一条命令,
            //也可以使用&表示执行上一条后台就立刻执行下一条语句
            command.append(String.format(" && cd %s", statsvnPath));
            command.append(" && java -jar statsvn.jar " + projectPath + "\\logfile.log " + projectPath);
            command.append(" -output-dir " + outputPath);
            System.out.println(command.toString());
            Runtime.getRuntime().exec(command.toString());
            System.out.println("======生成代码统计,生成分析报告结束=====");
            System.out.println("======分析报告输出路径:" + outputPath);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Java中,可以使用SVNKit库来实现创建SVN目录。SVNKit是一个开源的Java库,提供了与Subversion版本控制系统进行交互的API。 以下是使用SVNKit库创建SVN目录的示例代码: ```java import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.*; public class SVNCreateDirectoryExample { public static void main(String[] args) { // 初始化SVN库 DAVRepositoryFactory.setup(); // 定义SVN仓库的URL String url = "http://svn.example.com/svn/repository"; // 定义SVN仓库的认证信息 String username = "your_username"; String password = "your_password"; // 创建SVN目录的路径 String directoryPath = "/path/to/new_directory"; try { // 创建SVN仓库的连接 SVNURL svnUrl = SVNURL.parseURIEncoded(url); SVNRepository repository = SVNRepositoryFactory.create(svnUrl); // 设置SVN仓库的认证信息 ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password); repository.setAuthenticationManager(authManager); // 创建SVN目录 SVNClientManager clientManager = SVNClientManager.newInstance(); SVNWCClient wcClient = clientManager.getWCClient(); SVNCommitInfo commitInfo = wcClient.doMkDir(new SVNURL[]{svnUrl.appendPath(directoryPath, false)}, "Create new directory"); // 输出创建目录的结果 System.out.println("Directory created: " + commitInfo.getNewRevision()); } catch (SVNException e) { e.printStackTrace(); } } } ``` 请注意,上述示例代码中的`url`、`username`、`password`和`directoryPath`需要根据实际情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_37773018

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值