简体   繁体   English

使用Java自动提交到SVN

[英]Auto-commit to SVN with Java

I run a lot of my projects for work using 我运行了很多工作项目

java name.java

I was wondering if there was a way to add a hook to it where it would commit to SVN once that command is ran? 我想知道是否有一种方法可以添加一个钩子,一旦该命令运行它将提交到SVN?

Thanks! 谢谢!

There is no way to hook the 'java' executable itself. 没有办法挂钩'java'可执行文件本身。

What you want is a build system like Ant or Maven (you may or may not be familiar with the very old school make ) - They allow innumerable actions before and after compilation, including building distribution binary, source control commits, documentation generation, testing... They will change your life. 你想要的是像AntMaven这样的构建系统(你可能熟悉或者可能不熟悉旧的学校制作 ) - 它们允许在编译之前和之后进行无数的操作,包括构建分发二进制文件,源代码控制提交,文档生成,测试。 ..他们会改变你的生活。

Yes, Ant and Maven are preferred, but if you insist on doing it manually: 是的,Ant和Maven是首选,但如果您坚持要手动执行:

Linux: java Some.java && svn commit -m "baz" [..other args] Linux: java Some.java && svn commit -m "baz" [..other args]

Windows: java Some.java & svn commit [..args] Windows: java Some.java & svn commit [..args]

You can add a shutdownHook to Java Code which you like to run 您可以将shutdownHook添加到要运行的Java代码中

Runtime.getRuntime().addShutdownHook(new Thread() {
  ....do something...
}

But i wouldn't recommend that...and i think you don't need it... 但我不建议......而且我认为你不需要它......

What i don't understand is what you like to reach with that automatic commit ? 我不明白你想通过自动提交达到什么目的? Which reason do you have for such a thing? 你有什么理由这样的事情?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM