Snekse
Snekse

Reputation: 15799

Can you share manifestEntries in Maven?

In my master POM, I have <pluginManagement> where I define configurations for the maven-jar-plugin, maven-war-plugin and maven-ear-plugin. Each of these has

<configuration>
  <archive>
    <manifestEntries>
      <Build-Time>${maven.build.timestamp}</Build-Time>
      <SCM-Revision>${scmRevision}</SCM-Revision>
      <SCM-Branch>${scmBranch}</SCM-Branch>
      <Built-By>${user.name}</Built-By>
    </manifestEntries>
  </archive>
</configuration>

Is there a way to share a group of manifest entries so I don't have to add new items to 3 separate places?

Upvotes: 2

Views: 587

Answers (1)

Andrew Logvinov
Andrew Logvinov

Reputation: 21831

I would do the following:

  1. Create single manifest file with necessary content and property placeholders, and place it into src/main/resources.
  2. Have maven-resources-plugin process this file and generate manifest with actual property values.
  3. Provide jar, war and ear plugins with link to this file.

Here's a sample configuration:

<configuration>
  <archive>
    <manifestFile>${project.build.outputDirectory}/manifest.file</manifestFile>
  </archive>
</configuration>

Upvotes: 3

Related Questions