Skip to content

Instantly share code, notes, and snippets.

@minazou67
Last active August 18, 2016 06:16
Show Gist options
  • Save minazou67/602cb32adb8ffe30c9e5 to your computer and use it in GitHub Desktop.
Save minazou67/602cb32adb8ffe30c9e5 to your computer and use it in GitHub Desktop.
How to remove the POM file from artifacts that have been built with Maven

How to remove the POM file from artifacts that have been built with Maven

Maven のビルド成果物から pom.xmlpom.properties を除外する方法です。

Environment

  • Apache Maven 3.2.2
  • maven-jar-plugin 2.6
  • maven-war-plugin 2.6

Remove reason

  • maven-jar-pluginmaven-war-plugin を使用してビルドすると、成果物に pom.xmlpom.properties が同梱されてしまう。
  • POM ファイルに記述されている情報を露出したくない。
  • 成果物のバージョ番号を取得したい場合は、MANIFEST.MF から取得可能。
  • jar(war) ファイル内の POM ファイルを利用するシチュエーションは非常に限定的である。

How to remove

addMavenDescriptor エレメントのデフォルト値が true なので false に変更する。 maven-war-plugin の場合も同様の設定で変更可能。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <archive>
            <addMavenDescriptor>false</addMavenDescriptor>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment