////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////
:description: porting Kettle/PDI plugins to Hop is straightforward. This page describes a couple of points developers need to take into account to make the porting process as smooth as possible.
[[PortingKettlePlugins-PortingKettlePlugins]]
= Porting Kettle Plugins

== Change maven dependencies

You no longer need a Pentaho specific *$HOME/.m2/settings.xml*

- Change group *pentaho-kettle* to *org.apache.hop*
- Change dependency *kettle-core* to *hop-core*
- Change dependency *kettle-engine* to *hop-engine*
- Change dependency *kettle-ui-swt* to *hop-ui-swt*

Hop doesn't publish artifacts to Maven Central (yet). You need to include the Apache repository in your `pom.xml`.

[source, xml]
----
  <repositories>
    <repository>
      <id>Apache</id>
      <url>https://repository.apache.org/snapshots/</url>
      <name>Apache Repository</name>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>
----

== Jandex

To speed up searching for plugin annotations Apache Hop uses a Java Annotations Index: Jandex.  Unless you have such an index in your plugin JAR file Hop will not pick it up.
To add the index you simply need to add the plugin to your maven pom.xml:

[source, xml]
----
...
<properties>
  <jandex.version>3.1.6</jandex.version>
</properties>
...
<build>
  ...
  <pluginManagement>
    <plugins>
      ...
      <plugin>
        <groupId>io.smallrye</groupId>
        <artifactId>jandex-maven-plugin</artifactId>
        <version>${jandex.version}</version>
      </plugin>
    </plugins>
  </pluginManagement>

  <plugins>
    ...
    <groupId>io.smallrye</groupId>
    <artifactId>jandex-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>make-index</id>
        <goals>
          <goal>jandex</goal>
        </goals>
      </execution>
    </executions>
  </plugins>
</build>
----

For more information about Jandex, please see: https://github.com/wildfly/jandex-maven-plugin/
After the build and the Java annotations index was made you should see a file called `META-INF/jandex.idx` in your plugin JAR file.

== API changes

=== Interface naming

All interface classes have changed from <Name>Interface to I<Name>.
For example: *RowMetaInterface -> IRowMeta*

=== Transformations

Transformations are now called Pipelines.
This means that the corresponding classes have changed.

For example:
- TransMeta is now called *PipelineMeta* - Trans is now called *Pipeline*

=== Steps

Steps are now called Transforms.
For example:

- StepMeta is now called *TransformMeta*
- StepMetaInterface is now called *ITransformMeta*
- BaseStep is now called *BaseTransform*
- StepDataInterface is now called *ITransformData*

...and so on
=== Transform Generics

ITransform no longer expects you to pass ITransformMeta and ITransformData classes in the following methods:

- processRow()
- init()
- dispose()
- stopRunning()

This greatly simplifies the code.
Your need to let Hop know what the relationship is between your implementation of ITransform, ITransformMeta, ITransformData, for example:

[source]
----
public class Sample extends BaseTransform<SampleMeta, SampleData> implements ITransform<SampleMeta, SampleData> {

 ...

}
----

The same is true for your implementation of ITransformMeta:

[source]
----
public class SampleMeta extends BaseTransformMeta implements ITransformMeta<Sample, SampleData> {

 ...

}
----

== Repository

Any references to Repository, including parameters and the saveRep() and loadRep() methods in Transforms and Actions can be safely removed

== VariableSpace

VariableSpace was renamed to IVariables The API has also been cleaned up and simplified.
For example, ```environmentSubstitute()``` is now called ```resolve()``` Please note that metadata objects (TransMeta, JobMeta, DatabaseMeta, ...) no longer implement ```VariableSpace``` (or ```IVariables```).
Only runtime objects like Pipeline, Workflow, ITransform and so on have a state in Hop.

== Extension point plugins

If you're porting classes implementing an Extension Point plugin by implementing ExtensionPointInterface please note that you'll receive an extra parameter which is IVariables.
It aims to contain the variables of the parent object in the XP context.
Obviously the interface name changed to IExtensionPoint.
You can also use generics to specify the expected class of the receiving subject.

== Slave Servers and Database Connections

These objects are no longer stored in a Pipeline or a Workflow, they are now fully shared objects so any references of those in the interface methods of Transforms and Actions can be safely removed:

- List<DatabaseMeta> databases
- List<SlaveServer> slaveServers

== MetaStore -> HopMetadata

The MetaStore code is unfortunately LGPL licensed and for that reason removed from the project.
It was replaced by the general ```IHopMetadataProvider``` instead of the ```IMetaStore``` references.
At any given time you can ask the current ```*IHopMetadataProvider*``` to give you a serializer for a metadata class.
This ```*IHopMetadataSerializer*``` can then be used to CRUD objects as well as list and so on.

For more information on how to implement Hop Metadata plugins, see: Metadata Plugins.

MetaStore elements can now be managed in a standard way.
In your transform dialogs you can use the widget:

*MetaSelectionLine<T extends IHopMetadata>*

This will take care of adding label, tooltip, combo box and a few buttons to manage the metastore elements.
