4.3 Apache Maven Usage

The Maven plugin allows Bundlor to be run from inside any Maven project.

4.3.1 Maven Setup

The following procedure shows how to set up Bundlor inside of an existing Maven POM file.

  1. Add the Eclipse Virgo build and SpringSource Enterprise Bundle Repository to the pom.xml file.

    <pluginRepositories>
      <pluginRepository>
        <id>eclipse.virgo.build.bundles.release</id>
        <name>Eclipse Virgo Build</name>
        <url>http://build.eclipse.org/rt/virgo/maven/bundles/release</url>
      </pluginRepository>
      <pluginRepository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
      </pluginRepository>
      ...
    </pluginRepositories>
  2. Use the bundlor plugin, as shown in the following example. See Section 4.3.2, “Maven Plugin Reference” for details about the parameters of the plugin.

    <build>
      <plugins>
        <plugin>
          <groupId>org.eclipse.virgo.bundlor</groupId>
          <artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
          <version>1.1.2.RELEASE</version>
          <executions>
            <execution>
              <id>bundlor</id>
              <goals>
                <goal>bundlor</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <archive>
              <manifestFile>
                target/classes/META-INF/MANIFEST.MF
              </manifestFile>
            </archive>
          </configuration>
        </plugin>
        ...
      </plugins>
      ...
    </build>

4.3.2 Maven Plugin Reference

4.3.2.1 Plugin Configuration

The following table lists all the elements that you can specify for the bundlor Maven plugin.

Table 4.3. Elements

AttributeDescriptionRequired
bundleSymbolicNameThe OSGi Bundle-SymbolicName for the resulting manifestNo - defaults to ${project.artifactId}
bundleVersionThe OSGi Bundle-Version for the resulting manifestNo - defaults to ${project.version}
enabledWhether Bundlor should create a manifestNo - defaults to true
failOnWarnings Whether Bundlor should cause a build failure when there are warnings about the resulting manifest No - defaults to false
inputPath The path to the input to create a manifest for. This can either be a directory or a JAR file. No - defaults to ${project.build.outputDirectory}
manifestTemplate An inline manifest template. See Section 4.3.2.2, “Inline Manifest Template” for details. No
manifestTemplatePath The path to the manifest template. See Chapter 5, Manifest Templates for details. No - defaults to ${basedir}/template.mf
OSGiProfilePath The path to the OSGi profile. See Chapter 6, OSGi Profiles and Bundlor for details. No
outputPath

The path to write the manifest to. This can either be a directory, a JAR file, or not specified.

If a directory is specified, the manifest will be written to ${directory}/META-INF/MANIFEST.MF.

If a JAR file is specified, the manifest will be written as the manifest for that JAR file.

No - defaults to ${project.build.outputDirectory}
propertiesPath The path to a properties file used for substitution. See Section 5.3, “Specifying property placeholders” for details. No

4.3.2.2 Inline Manifest Template

Manifest templates can be optionally specified inline instead of as an external file using the <manifestTemplate/> element. For example:

<execution>
  <id>bundlor</id>
  <goals>
    <goal>bundlor</goal>
  </goals>
  <configuration>
    <manifestTemplate>
Bundle-ManifestVersion: 2
Bundle-Name: Bundlor Core
Bundle-SymbolicName: org.eclipse.virgo.bundlor
Bundle-Version: 0
    </manifestTemplate>
  </configuration>
</execution>

See Chapter 5, Manifest Templates for details.

If a <manifestTemplate/> element is specified, any <manifestTemplatePath/> element is ignored.

4.3.2.3 Inline OSGi Profile

OSGi profiles can be optionally specified inline instead of as an external file using the <OSGiProfile/> element.

<execution>
  <id>bundlor</id>
  <goals>
    <goal>bundlor</goal>
  </goals>
  <configuration>
    <OSGiProfile>
org.OSGi.framework.system.packages = \
 org.eclipse.virgo.osgi.extensions.equinox.hooks,\
 javax.accessibility,\
 javax.activation,\
 javax.activation;version="1.1.1",\
 javax.activity,\
 javax.annotation,\
...

org.OSGi.framework.bootdelegation = \
 org.eclipse.virgo.kernel.authentication,\
 com.sun.*,\
 javax.xml.*,\
...
    </OSGiProfile>
  </configuration>
</execution>

See Chapter 6, OSGi Profiles and Bundlor for details.

4.3.2.4 Inline Property Values

Property substitution values can be optionally specified inline instead of as an external file using the <properties/> element.

<project>
  ...
  <properties>
    <bundle.name>${project.name}</bundle.name>
    <bundle.version>2.0.0.RELEASE</bundle.version>
  </properties>
  ...
</project>

See Section 5.3, “Specifying property placeholders” for details.

4.3.3 Maven Plugin Examples

4.3.3.1 Creating a manifest

<project>
...
  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.virgo.bundlor</groupId>
        <artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
        <executions>
          <execution>
            <id>bundlor</id>
            <goals>
              <goal>bundlor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
...
</project>

4.3.3.2 Creating a manifest with placeholder replacement

<project>
...
  <properties>
    <bundle.name>${project.name}</bundle.name>
    <bundle.version>2.0.0.RELEASE</bundle.version>
  </properties>
...
  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.virgo.bundlor</groupId>
        <artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
        <executions>
          <execution>
            <id>bundlor</id>
            <goals>
              <goal>bundlor</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
...
</project>