Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.

pom_customization

jvshahid edited this page Feb 2, 2011 · 5 revisions

Pom Customization

Adding extra pom sections

Besides dependencies which is added to the pom by default. Extra sections can be added to the pom as shown below:

require 'buildr-dependency-extensions'

repositories.remote << "http://www.ibiblio.org/maven2/"

define 'foo-bar' do
  extend PomGenerator

  run.with artifact('foo:bar:jar:1.1')

  project.extra_pom_sections['plugins'] = 'plugin' => [{'artifactId' => 'foobar', 'groupId' => 'foo', 'version' => '1.0'}]}
end

Note: It's plugin that's mapped to an array, not plugins.

This buildfile will generate the following pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>foo.bar</groupId>
  <artifactId>TestProject</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>foo</groupId>
      <artifactId>bar</artifactId>
      <version>1.0</version>
      <scope>runtime</scope>
      <type>jar</type>
    </dependency>
  </dependencies>

  <plugins>
    <plugin>
      <groupId>foo</groupId>
      <artifactId>foobar</artifactId>
      <version>1.0</version>
    </plugin>
  </plugins>
</project>

The extra pom sections converts the given array, or hash to XML.

Clone this wiki locally