bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
528 stars 306 forks source link

P2Repository cache not updated after change of url. #1974

Closed jwausle closed 7 years ago

jwausle commented 7 years ago

If I change my P2Repositry.url to a new one with same bundles with another version inside Than the 'cnf/cache' and 'downloaded-runbundles' contains always the previous(old) bundles after gradle runbundles execution.

howto reproduce

P2 repos

http://p2repo/unzipped/1.0/plugins
- bundle-1.0.jar

http://p2repo/unzipped/2.0/plugins
- bundle-2.0.jar

cnf/build.bnd

-plugin.p2-repo: aQute.bnd.repository.p2.provider.P2Repository; \
       name = "p2-repo"; \
       url = "http://p2repo/unzipped/1.0"

project/bnd.bndrun

-runbundles: bundle

# gradle clean runbundles

Update 'cnf/build.bnd'

-plugin.p2-repo: aQute.bnd.repository.p2.provider.P2Repository; \
       name = "p2-repo"; \
       url = "http://p2repo/unzipped/2.0"

# gradle clean runbundles again

quickfix

# rm -rf cnf/cache/p2-repo # gradle clean runbundles :)

bjhargrave commented 7 years ago

You need to make a clean task for your cnf project. See https://github.com/bndtools/bnd/blob/master/cnf/build.gradle

jwausle commented 7 years ago

Thanks @bjhargrave. That`s a quickfix right?

In general:

bjhargrave commented 7 years ago

It is the fix. You ran clean to reset to the original state, that should include any caches, no? git clean -dfx would also clean the cache.

If you change the URL of the repo and don't also change the name of the repo, name = "p2-repo", then you have two repos (old URL and new URL; they are distinct repos) sharing the same cache (based on repo name). So you should clean the cache upon changing repos (URLs) or use a different cache (repo name).

bjhargrave commented 7 years ago

1975 adds a :cnf:cleanCache task. The :cnf:clean task will dependOn the :cnf:cleanCache task unless gradle is --offline. You can also avoid the :cnf:cleanCache task by -x cleanCache in the command line:

./gradlew -x cleanCache clean build
fhuberts commented 7 years ago

That is extremely inconvenient since I use "gradle clean build" to force a clean build before I commit. Doing that offline will blow away my cache and break my build. Please make clean NOT depend on cleanCache.

bjhargrave commented 7 years ago

I discussed this with @rotty3000 and we thought this was OK. But feedback from others would be good.

gradle --rerun-tasks is probably a saner choice or git clean to get a really clean build. I never really trust gradle clean.

fhuberts commented 7 years ago

Well on jenkins I do a git clean, but offline I do not...

bjhargrave commented 7 years ago

Besides, if you really want a clean build, you should start with an empty cache like your CI system probably does.