Table of Contents
Just a second...

Building a publisher with mvndar

Use the Maven™ plugin mvndar to build and deploy your publisher DAR file. This plugin is available from the Push Public Maven Repository.

This task describes how to build existing publisher code into a DAR file for deployment on the Diffusion™ server. Develop your publisher code before beginning this task. For more information, see Writing a publisher.

You must have an installation of the Diffusion server on the system you use to build the DAR file.

  1. Create a Maven project.
    mvn archetype:generate -DgroupId=group_id -DartifactId=publisher_id  -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
    Replace group_id with the group identifier for your publisher, for example, com.example. Replace publisher_id with the artifact name for your publisher, for example, my-first-publisher.
    This command creates a publisher_id directory that contains a pom.xml and sample files.
  2. Replace the sample code in the new publisher_id Maven project with your publisher code.
    Put your Java™ code in the publisher_id/src/main/java/ directory.
  3. Add a Publishers.xml file to your Maven project.
    Create the file at publisher_id/src/main/diffusion/etc/Publishers.xml:
    <publishers>
      <publisher name="publisher_name">
        <class>fq_publisher_name</class>
        <start>true</start>
      </publisher>
    </publishers>
    Replace publisher_name with the name of the class that extends the Publisher class, for example, MyFirstPublisher. Replace fq_publisher_name with the fully qualified name of the class that extends the Publisher class, for example, com.example.publish.MyFirstPublisher.
  4. Edit the pom.xml file in the publisher_id directory:
    1. Remove the boilerplate code and ensure that the group and artifact IDs are set to the correct values.
      <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                            http://maven.apache.org/maven-v4_0_0.xsd">
      
        <modelVersion>4.0.0</modelVersion>
        <groupId>group_id</groupId>
        <artifactId>publisher_id</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>publisher_id</name>
      
      </project>
    2. Create a system-scoped dependency on the Diffusion JAR.
        <dependencies>
          <dependency>
            <groupId>com.pushtechnology</groupId>
            <artifactId>diffusion</artifactId>
            <version>5.9.4</version>
            <scope>system</scope>
            <systemPath>diffusion_installation_directory/lib/diffusion.jar</systemPath>
            <optional>true</optional>
          </dependency>
        </dependencies>
    3. Add the Push Public Maven Repository as a repository that plugins can be fetched from
      <pluginRepositories>
        <pluginRepository>
          <id>push-repository</id>
          <url>http://download.pushtechnology.com/maven/</url>
        </pluginRepository>
      </pluginRepositories>
    4. Add mvndar as configured plugin
      <build>
        <plugins>
          <plugin>
            <groupId>com.pushtechnology.tools</groupId>
            <artifactId>dar-maven-plugin</artifactId>
            <version>1.2</version>
            <extensions>true</extensions>
          </plugin>
        </plugins>
      </build>
    5. Set the packaging method to dar instead of jar:
        <packaging>dar</packaging>
  5. Build your DAR file.
    Run the mvn clean package command in the publisher_id directory.
A DAR file is created in the publisher_id/target directory. This DAR file is ready to deploy to the Diffusion server. For more information, see Deploying publishers on your Diffusion server