简体   繁体   中英

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?

Thanks!

There is no way to hook the 'java' executable itself.

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.

Yes, Ant and Maven are preferred, but if you insist on doing it manually:

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

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

You can add a shutdownHook to Java Code which you like to run

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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