Is there a way to pause a maven multi-module build and resume later? - maven

So this humungous package is trying to get installed on my VM for the past 5 hours. Its still going strong and looks like it has downloaded the entire Internet already. I need to shut my laptop down. Is there a command line tool to tell Maven to take a break, chill for some time, and resume from where it left later?
Edit: I see a very subtle difference between this and the existing question that has been pointed out. I have been using the -rf flag to recover from a failed build for some time now. But I am not aware of the intricacies of the workings of Maven so I wasn't sure if it would be able to recover if I killed the mvn process from the command line (or if my laptop ran out of battery and was forced to shut down), even if the build process was going on smooth. Here's an analogy - I like to think of Maven as someone managing a complex set of tasks. If some task fails, the manager keeps note of that, halts all the operations and reports to the seniors and waits till his issue is fixed. I believe that as soon as maven finds out something has broken, it saves the state of the build process to be able to resume later. But what happens if someone comes and kills the manager. Or in the case of what I did, if I kill -9 the maven process. Would maven be able to save a copy of the build state? I wasn't so sure. That's what I wanted to check

You can use -rf command line switch to restart the build from given package.
For example if your project consists of parent, child1, child2 builds, you can stop the build e.g. at child2 and restart it using (assuming you were doing clean install):
mvn clean install -rf :child2

Related

Is there a way to get notified (email, desktop notifications etc.) after my maven clean install is completed in IntelliJ?

I have a maven build that if successful takes couple of hours. However if it fails abruptly, i have no clue until i get back to IntelliJ and see what happened. Is there a way to get notifications regarding my run/build status from Intellij so i get to follow up right away?
First of all, it would be good to analyse why this build takes so long. Then one could find possible speed-ups.
Secondly, making such a build is a job for a build tool like Jenkins, not for IntelliJ. Jenkins can inform you about failed or succeeded builds.
Since the IDE is a desktop app it notifies about build status on build completion in status bar:
As for other means of notification I think Fabian's answer is right.

How can I run clean-up offline in Team City?

Our Team City server got to a state when nothing works including the `Start clean-up now' button, because the internal database size is >900MB. Yes, we are still trying to get a proper external database... In the meantime is there a way to shut down Team City and run the clean-up manually from the command line? How can we recover from this state otherwise?
We are running version 8.1.5.
It depends a lot on what do you want to clean up : artefacts, directory etc.
I ran into the same issues when I setup teamcity initially. I used to go into the agent work directories , figure out the directories taking the max space and run rm -rf on the agent work directories (the ones with the alphanumeric sha id) .
One good thing about our setup is that we named all our checkout directories , so it was very easy to identify multiple runs for the same build, so I used to delete every checkout build except the latest one.
In case you have artefact dependencies, I would advise you not to do this process

The process cannot access the file because it is being used by another process when running a multithreaded maven build

I am having an issue when running a multithreaded maven build. The issue is simple, two threads are trying to access the same file to copy it, transfer it, etc. The issue is that I cannot find a way to tell maven to tell the threads to either wait till the file is accessible again or simply solve the problem.
Multithreaded builds are necessary for us so was wondering if this is possible to solve. Thanks in advance!
Drop the target folder manually as Windows might was not able to delete them on its own. Then try mvn clean install
Restart your system it will close all the processes and will resolve the issue.

Pause TeamCity projects while others are executing

I’d like to be able to specify that one build project should pause while another specified project is running.
In my case, there is a project #1 that builds and deploys compiled code to our servers, and a project #2 that performs Selenium tests on that deployed code. The tests can take several minutes, and I’d like to make sure that the build-and-deploy doesn’t happen in the middle of testing.
So, I’d like to pause #1 (build) while #2 (test) is running.
Dependencies or Triggers do not offer this option, as far as I can tell. Can this be configured?
There is a request on TeamCity issue tracker TW-3798. You are welcome to vote and watch.
This functionality is currently being developed. For now you can use one of the features provided by GroovyPlugin called StartBuildPrecondition. To ensure that only one build is executed add the same write lock to both of the builds
The way we do this is by restricting them to one build agent. They you are insured that only one runs at a time.

Pre-build task - deleting the working copy in CruiseControl.NET

I'm currently in the process of setting up a continuous integration environment at work. We are using VisualSVN Server and CrusieControl.NET. Occasionally a build will fail and a symptom is that there are conflicts in the CruiseControl.NET working copy. I believe this is due to the way I've setup the Visual Studio solutions. Hopefully the more projects we run in this environment the better our understanding of how to set them up will be so I'm not questioning why the conflicts happen at this stage. To fix the builds I delete the working copy and force a new build - this works every time (currently). So my questions are: is deleting the working copy a valid part of a continuous integration build process, and how do I go about it?
I've tried solutions including MSTask and calling delete from the command line but I'm not having any luck.
Sorry for being so wordy - good job this is a beta :)
Doing a full delete before or after your build is good practice. This means that there is no chance of your build environment picking up an out of date file. Your building exactly against what is in the repository.
Deleting the working copy is possible as I have done it with Nant.
In Nant I would have a clean script in its own folder outwith the one I want to delete and would then invoke it from CC.net.
I assume this should also be possible with a batch file. Take a look at the rmdir command http://www.computerhope.com/rmdirhlp.htm
#pauldoo
I prefer my CI server to do a full delete as I don't want any surprise when I go to do a release build, which should always be done from a clean state. But it should be able to handle both, no reason why not
#jamie: There is one reason why you may not be able to do a clean build every time when using a continuous integration server -- build time. On some projects I've worked on, clean builds take 80+ minutes (an embedded project consisting of thousands of C++ files to checkout and then compile against multiple targets). In this case, you have to weigh the benefit of fast feedback against the likelihood that a clean build will catch something that an incremental build won't. In our case, we worked on improving and parallelizing the build process while at the same time allowing incremental builds on our CI machine. We did have a few problems because we weren't doing clean builds, but by doing a clean build nightly or weekly you could remove the risk without losing the fast feedback of your CI machine.
If you check out CC.NET's jira there is a patch checked in to implement CleanCopy for Subversion which does exactly what you want and just set CleanCopy equal to true inside your source control block just like with the TFS one.
It is very common and generally a good practice for any build process to do a 'clean' before doing any significant build. This prevents any 'artifacts' from previous builds to taint the output.
A clean is essentially what you are doing by deleting the working copy.
#Brad Barker
Clean means to just wipe out build products.
Deleting the working copy deletes everything else too (source and project files etc).
In general it's nice if you're build machine can operate without doing a full delete, as this replicates what a normal developer does. Any conflicts it finds during update are an early warning to what your developers can expect.
#jamie
For formal releases yes it's better to do a completely clean checkout. So I guess it depends on the purpose of the build.

Resources