Making sure maven is running from scratch with a clean repo - maven

I am pretty new to Maven and really not trying to fully learn it right now, just trying to install my java project.
I get some errors (it is from a Hadoop Crunch project) but the errors feel like they are referring to my older code that was doing a division and could be div by zero.
So anyway: Currrently I am dong mvn clean install but looks like there is something its cache still? is there a more powerful way of doing this such that I make sure nothing is coming from its cache, etc?

Look for your repo at C:\Users\youruser\.m2 or ~/.m2, you can delete that whenever you want but it will cause a "Download the Internet" the next time you do something.
That's obviously not the solution for daily use, the mvn clean install does compile and put the binaries of your project in your local repository from scratch, but if you have SNAPSHOT dependencies to separate projects (I'm not talking about submodules, I mean projects in some other directory) then you would need to go to those projects first and do mvn clean install there first so that your local repository has the latest binaries.

Related

Can you modify files in a repository right after issuing maven compile install?

For projects which take a long time to build, can you issue the maven compile or maven install commands and then continue making changes to the files in your repository, without these changes affecting the outcome of the maven install command?
Is a snapshot automatically taken when the command is issued? If not, is there a way to request that maven take a snapshot of the project when a command is issued, so that you could continue making changes after that snapshot?
If you build locally, you should not be changing files while you build because you might break the build.
If you build on a build server, it depends:
If you run a clean package or clean install, then there is just one checkout at the beginning. After that it should not be a problem to make further commits.
If you build a release with Maven release plugin, you should probably be more careful. I haven't actually seen any problems in nature yet, but since the Maven release plugin commits to git/svn itself, you might cause problems when committing during the build on the same branch.

How to package up a leiningen project for recompilation with all the libraries included? [for users without an internet connection]

I'm giving a Clojure workshop and I want people to be able to modify and recompile the Clojure project. The challenge is that they won't have internet connections - so I need to give them the project and the libraries all at once.
How can I package up a leiningen project for recompilation with all the libraries included?
Assumptions
They have leiningen installed on their machine prior to the workshop.
EDIT
This is almost the same question as How to package up a maven project for recompilation with all the libraries included? [without an internet connection]
Move your ~/.m2 directory aside. Run all the lein x leiningen commands you expect your users to have run, also build and test your project (test, install, jar, uberjar, etc.). This will have downloaded (a lot) of dependencies for Leiningen itself as well as for your project. $HOME/.m2 is where you'll find all the jar files that were pulled down by the Maven dependency resolver.
Once you've done this, add :offline? true to the project.clj, According to the documentation, this will Prevent Leiningen from checking the network for dependencies.
See Maven - alternative .m2 directory for an alternative to having to move your .m2 directory aside.
To make using it easy for your students, it may be best to create a self-contained zip archive with the entire .m2 directory, your project and Leiningen itself, along with a basic installer (bash script, or batch file) that moves or symlinks the .m2 directory into the proper place and adds the lein script to the path. This approach should satisfy the off-line needs - I think it covers all of the dependencies you would need.
I have assumed that your students will have java installed and have it on their PATH. Pre-running all of the lein commands you expect to use is important, as some of them have their own dependencies that are only resolved when they are first run.

Maven re-build and deploy

I'm new to compiled web development, and I'm just trying to figure out the build/deploy process.... I've done:
mvn clean install
on a project, which built and deployed the project and now I can see it. If I want to make changes to the codebase, do I really need to run mvn clean install again to re-build and deploy the changes or is there a way to do a quicker build without using a "proper" IDE?
I'm using vim/gvim
Thanks!
Maven already handles the dependencies and only re-builds the necessary files... unless you throw away all previous build artifacts with clean! You should only need to use clean when you run into problems, or when you have checked out a different version from version control. Usually, mvn install should suffice.
You can integrate that with Vim; the simplest is to
:set makeprg=mvn
and then trigger a build with :make install.
Plugins build on that simplistic setup, e.g. check out:
maven-plugin
maven-ide

Maven: How do I install mvnsh?

I suspect I'm going about this the wrong way entirely.
I heard about mvnsh, and wanted to give it a try, to decrease the lag when I build.
But I'm completely clueless about how one would do that. I'm still learning maven, and drawing false parallels between mvn and tools like gem, cabal, or cpan is still biting me, so I'm not sure what I need to do to install a command line tool like mvnsh.
It doesn't seem to make sense to stick it as a dependency in some arbitrary project's pom.xml.
I downloaded mvnsh-assembly-1.0.1.pom from the download page on the theory that that was involved so far, but so far, nothing I've tried has worked. mvn install -f mvnsh-assembly-1.0.1.pom downloaded a bunch of jars, then died. mvn artifact:install -f mvnsh-assembly-1.0.1.pom downloaded more jars, then died.
I really have no idea what I'm doing here. Should I even be using mvn to install mvnsh?
Just download the http://repo1.maven.org/maven2/org/sonatype/maven/shell/dist/mvnsh-assembly/1.0.1/mvnsh-assembly-1.0.1-bin.zip or the .tar.gz archive depends on you OS unpack it and put the bin folder of the distribution to you PATH after that you can start mvnsh .

Save changes resources before running maven install through m2eclipse

I am using m2eclipse and was wondering if there is a way to make it save all the sources when running maven install. I need to do it manually each time and sometimes forget to...
Thanks

Resources