Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean Heroku dependency cache (unmanaged maven dependencies)

Tags:

heroku


I have to use an unmanaged SNAPSHOT dependency in my java/maven heroku app. I do this using a project-local maven repository as desribed in this article.

Heroku caches the dependencies between builds. Unfortunatly Heroku does not notice if the SNAPSHOT Version changes and keeps on using the cached dependency. This leads to compilation errors as I depend on changes in the SNAPSHOT version.

Is there a way to manually or automatically clean this dependency cache?

I found this maven plugin (it does a local build and pushes the resulting artefacts to heroku) but its not really the way I want to do it.

One could argue its a bad practice to use this snapshot dependency in the first place but I think there are other more or less valid reasons for cleaning the cash e.g. leaking storage as the unmanaged dependencies are not even removed if they are deleted from the project local repository.

I appreciate your answer

like image 497
mulrich Avatar asked Mar 16 '13 13:03

mulrich


People also ask

Does Maven clean remove dependencies?

It only cleans the project. Show activity on this post. Show activity on this post. With the help of Purging local repository dependencies you need to do that.

Can I clean m2 repository?

All you could do, is to delete the . m2 folder and re-build all of your projects and then the folder would automatically build with all the required library.

How do I clean up Maven?

The Clean Plugin can be called to execute in the command-line without any additional configurations. Like the other plugins, to run the Clean Plugin, you use: mvn clean:clean.

How do I delete a dependency in Maven?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.


2 Answers

There's a branch of the java buildpack that clears maven cache. To use it, configure your app to use the cache_clear branch:

heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-java.git#cache_clear

===Update===

There's a plugin that clears cache on any app. Install it and run the purge-cache command.

$ heroku plugins:install https://github.com/heroku/heroku-repo.git

$ heroku repo:purge_cache -a appname

like image 135
Naaman Newbold Avatar answered Oct 25 '22 22:10

Naaman Newbold


Login to heroko by console, go to the git repository directory of your app, run the following commands and try to push to the heroku git repository again

$ heroku config:set MAVEN_CUSTOM_GOALS="clean package"
$ heroku config:set MAVEN_CUSTOM_OPTS="--update-snapshots -DskipTests=true"

Now, it will download the latest SNAPSHOT from the repository before build. Refer this heroku build pack for java for more details.

You can also configure a custom settings.xml for your maven, refer this heroku documentation.

like image 27
Visruth Avatar answered Oct 25 '22 23:10

Visruth