Search code examples
mavenapache-nifi

Multiple NAR dependency for referencing controller services


I'm developing a custom processor, which uses both the DBCPService and RecordReader .

For the maven project, I cannot add the NAR dependencies of both the services, as this results in an error.

For my processor module, pom.xml,


    <dependencies>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-utils</artifactId>
            <version>1.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-mock</artifactId>
            <version>1.12.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-dbcp-service-api</artifactId>
            <version>1.12.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-record-serialization-service-api</artifactId>
            <version>1.12.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-record</artifactId>
            <version>1.12.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

For my processor-nar, submodule,

 <dependencies>
        <dependency>
            <groupId>com.suntecgroup.xelerate</groupId>
            <artifactId>nifi-record-processors</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-record-serialization-services-nar</artifactId>
            <version>1.12.0</version>
            <type>nar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-dbcp-service-nar</artifactId>
            <version>1.12.0</version>
            <type>nar</type>
        </dependency>
    </dependencies>

How would one go about adding the dependencies of the two controller services to the processor ?


Solution

  • The NAR dependency should be on the NAR that contains the service API, not the NAR containing implementations of those APIs. So for your example, nifi-dbcp-service-api and nifi-record-serialization-service-api are both part of nifi-standard-services-api-nar, so you just need this:

    <dependency>
      <groupId>org.apache.nifi</groupId>
      <artifactId>nifi-standard-services-api-nar</artifactId>
      <version>1.12.0</version>
      <type>nar</type>
    </dependency>