Publish JARs and WARs in a multi-project build

I have a somewhat large multi-project build (80+ projects) which produces mostly JARs and a few WARs. Obviously, the WARs contain many of the JARs from other projects. I want to publish all of them to a Nexus repository, but I only want the WAR projects to publish a WAR, not a WAR + JAR.

Originally, I had a ‘publishing’ block in my top-level build and all projects would inherit this, which would cause a JAR to be published. I then added another ‘publishing’ block to the WAR projects so that they would publish a WAR. However, they would create both a JAR and a WAR, which is not quite what I want. I see possible solutions as:

  1. Manually specify whether to publish a JAR or WAR in each project (kinda sucks, what I’m doing for now)
  2. Assume a project publishes a JAR unless a WAR is indicated
    a. Somehow remove the JAR publish info–how to do this???
    b. Disable the JAR publishing task–not sure how to do this exactly, either???
  3. Something clever I haven’t thought of???

Any ideas?

Would it help if you iterated across all projects over all tasks of type JAR and WAR (separately)? Inside the loop, you could then create the appropriate publish block.