Domanda

As part of my build process, I am generating a separate artifact (compressed file with static web files inside) in the which I would like to contain the same information that is in the manifest file generated by the war plugin. The manifest file is generated correctly into the war file, but I'd like access to it so I can copy it and put it in my compressed file as well.

In the documentation for the maven-war-plugin:manifest goal, it reads:

The manifest file is created in the warSourceDirectory.

Which defaults to the location: ${basedir}/src/main/webapp

However, the only manifest that is generated is within the war. It doesn't make sense to me either that the generated manifest file would be put into my source. I would think that it would be put in the target where the war is packaged from.

Am I missing something?

È stato utile?

Soluzione

If you look at the built-in lifecycle reference you will see that at no point in the <packaging>war</packaging> lifecycle is the war:manifest goal bound to any phase.

Thus by default this goal will not execute (unless you add an execution).

If there is a MANIFEST.MF file at ${basedir}/src/main/webapp/META-INF/MANIFEST.MF then when the war:war goal is executing it will use that file rather than generating the MANIFEST.MF on the fly and embedding it straight into the .war file without creating an intermediary file.

From what I can tell, the war:manifest goal is designed to be used to generate a template MANIFEST.MF which you can then customise and use going forward.

The war plugin has a number of goals which I would tend to advise keeping clear of:

  • war:inplace
  • war:manifest

The reason is because both of these goals modify the files in your src tree which goes against the standard Maven practice of only touching files in target (which makes for a very nice mvn clean as you need only remove the target)

With regards to your question, the key thing is that you are generating a separate artifact. Maven works best when you stick to one artifact per Maven module. Thus the separate artifact will have a separate module. You just add the .war as a dependency (remember <type>war</type>) and then use dependency:unpack-dependencies to unpack the .war file... you can have it only unpack the META-INF/MANIFEST.MF and if that ends up as target/${project.build.finalName/META-INF/MANIFEST.MF then when you are packing up this second artifact you will ensure it has the same manifest as your .war file.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top