2

Developing in NetBeans with Maven I often keep reverting back to local history and svn code as things no longer work (TDD?). Other than committing to a 'testing new idea X' branch after each successful build/test is there how I could configure Maven to do that at each build automatically?

Is anyone else running into the same issue, and approaching it differently?

EDIT: so the question is: how can I have an automatic commit each time a maven build is successful such that I may revert to it? Preferably with mercurial.

simpatico
  • 10,709
  • 20
  • 81
  • 126

5 Answers5

1

(...) is there how I could configure Maven to revert to the code that last built/tested successfully?

Maven doesn't keep track of changes, that's not what it is intended for. Using your VCS and committing small working changes in a development branch is IMO the way to go.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • don't you think it would be useful if a commit is made to 'code-that-builds' branch (under the branch/trunk) one is working in everytime it happens? This is better than manually doing it because it takes less time, is less error-prone (forgetting, and committing when actually the tests didn't work). Since actions can be customized to interact with svn (like mvn deploy) I thought this could be achieved (and someone thought it useful already). – simpatico Sep 19 '10 at 05:42
  • @simpatico I'm just saying it's not what Maven was intended for. Personally, I wouldn't want Maven to revert changes because the build didn't pass. I prefer the other way around: running a build before to commit **or** running a build upon commit and rejecting the commit if the build fails if you are using a CI engine supporting that. [Team City does](http://stackoverflow.com/questions/500944/build-on-commit-with-subversion/501065#501065). – Pascal Thivent Sep 19 '10 at 21:02
  • can I have maven commit at/after every successful build? That would it for me if it committed to an 'auto-commit' branch, or with comment 'auto-commit'. BTW I use mercurial – simpatico Aug 21 '11 at 05:10
0

Better than doing a commit on success is to move forward a tag. In Mercurial you'd just do:

hg tag --local --force last_successful_build

Just make that the last line of your build script and you're good to do. The --local makes it a tag that never enters history and/or gets pushed and the --force moves it forward if it already exists. The same thing would work in git with slightly different command lines.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
0

It sounds like you're doing it correctly with SVN. That's what source control is for, after all.

You may want to look at git as an alternative (or bridge) to subversion as this may speed you up and allow you to keep your SVN history nice and clean.

If you can drive Vim, you may want to look at its undo tree. Here is some help on Vim-NetBeans integration.

Community
  • 1
  • 1
johnsyweb
  • 136,902
  • 23
  • 188
  • 247
0

Git has a local history you can use for point-in-time backup/recovery so you can localy undoo without cluttering the source control with experiments. Something like this is somewhere on the roadmap for svn too.

Christoph Strasen
  • 2,682
  • 1
  • 18
  • 16
0

It sounds like you are doing it the best way already; using SVN and your IDE to rollback changes if your builds fail. I fully support what Pascal recomended when he said you should be doing local builds before committing and then using a CI tool to make sure your VCS codebase always passes building/testing.

The only alteration I would proposed is using .patch files when you need a rollback point if you want to experiment. So if I have local mods already and I am not sure what to do next in order to be commit-able (I still have breaking tests); I will create a .patch file as a snapshot of where I am at. I am then free to experiment as needed and when everything goes wrong, I simply revert everything and then re-apply my patch. This is an alternative to setting up git as a local VCS repo.

This may help you out but there is no substitute for small, incremental work. Commit as often as possible to avoid getting yourself in these situations in the first place.

Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
  • is there how I can automate commits at every successful build? – simpatico May 28 '12 at 13:52
  • We use IntelliJ IDEA with TeamCity as our CI server. There is an IDEA TeamCity plugin which allows you to run a 'local' build which uses a TeamCity build configuration to run a CI job locally on your machine. There is an option to automatically commit upon success with this approach. As for other IDEs/CI servers, you might have to come up with your own automated solution. Possibly with a custom script? – Jesse Webb May 28 '12 at 14:15