Modifying compileJava dependencies to ignore manifest in jars of project dependencies?

In my large multiproject build, I’m including the buildnumber in my jar manifests, and this causes the jar task to be executed every time.

That’s okay, but the problem is, that the compileJava task of every project that depends on another project is executed every time as well, since the jars are never up to date because of the new manifest. This causes my build execution to be much slower than it could be.

Is there a way to modify the compileJava dependencies, so that they don’t check the actual jar files, but instead the sourcefiles from which those jars are built - excluding the manifest?

I can’t think of a way to do this. Instead I’d try not to include the build number for dev builds, but only, say, for release or CI builds.