🔗Packaging Plugins

To package, present, and deploy your plugin, see these instructions:

If you are installing a third-party JAR (such as a JDBC driver) to make it accessible to other plugins or applications, see these instructions.

🔗Plugin Packaging

A Plugin is packaged as a JAR file, which contains inside the plugin classes and their dependencies. CDAP uses the "Export-Package" attribute in the JAR file manifest to determine which classes are visible. A visible class is one that can be used by another class that is not from the plugin JAR itself. This means the Java package which the plugin class is in must be listed in "Export-Package", otherwise the plugin class will not be visible, and hence no one will be able to use it. This can be done in Maven by editing your pom.xml. For example, if your plugins are in the com.example.runnable and com.example.callable packages, you would edit the bundler plugin in your pom.xml:

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <version>2.3.7</version>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <Embed-Dependency>*;inline=false;scope=compile</Embed-Dependency>
      <Embed-Transitive>true</Embed-Transitive>
      <Embed-Directory>lib</Embed-Directory>
      <Export-Package>com.example.runnable;com.example.callable</Export-Package>
    </instructions>
  </configuration>
  ...
</plugin>

By using one of the available Maven archetypes, your project will be set up to generate the required JAR manifest. If you move the plugin class to a different Java package after the project is created, you will need to modify the configuration of the maven-bundle-plugin in the pom.xml file to reflect the package name changes.

If you are developing plugins for the cdap-data-pipeline artifact, be aware that for classes inside the plugin JAR that you have added to the Hadoop Job configuration directly (for example, your custom InputFormat class), you will need to add the Java packages of those classes to the "Export-Package" as well. This is to ensure those classes are visible to the Hadoop MapReduce framework during the plugin execution. Otherwise, the execution will typically fail with a ClassNotFoundException.