Skip to content

Create a new plugin

descl edited this page Dec 18, 2012 · 6 revisions

Table of Contents

Create the project source.

You need to create a new maven project under the ZONE-extractor folder. The organisation of the project should be like:

  pom.xml
  src
    main
      java
      resources
    test
      java
      resources

(more informations)

NetBeans can create this for you: File -> New Project -> Maven -> Java Application

  • name: ZONE-plugin-YourPluginName
  • Project Location: [repoPath]/ZONE-extractor
  • Group Id: org.zoneproject.extractor
  • Version: 1.0-SNAPSHOT
  • Package: org.zoneproject.extractor.plugin.YourPluginName

Standard POM file:

            <id>install</id>
            <phase>install</phase>
            <goals>  
              <goal>java</goal>  
            </goals>
            <configuration>
              <mainClass>org.zoneproject.extractor.plugin.categorization_svm.Install</mainclass>
            </configuration>
          </execution>
          
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <mainClass>org.zoneproject.extractor.plugin.categorization_svm.App</mainclass>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <mainClass>org.zoneproject.extractor.plugin.categorization_svm.App</mainclass>
        </configuration>
      </plugin>
    </plugins>
    <testResources>
      <testResource>
        <directory>src/test/resources/</directory>
      </testresource>
    </testresources>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.zoneproject.extractor</groupid>
      <artifactId>ZONE-utils</artifactid>
      <version>1.0-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  </project>

You also need to edit the parent pomfile in ZONE-extractor project in order to add your module to modules list

Compile and run

You can specify a java file to run after the installation task (useful if you have to load datas to virtuoso data store of making algorithm initialization (useful for Supervised learning). The convention is calling them Install.java and App.java. You also need to add in you App.java the following constructor in order to use it in the annotation process:

    public App(){
        String [] tmp = {};
        App.main(tmp);
    }

You can start installation process using:

  mvn install -pl :[MyPluginName]

Start annotation process:

  mvn exe:java -pl :[MyPluginName]

They are charged automatically from the automatic annotation process (in ZONE-extractor-start project)

Write the App code

You should take a look at other plugins in order to how to write this file (take a look at ZONE-plugin-ExtractArticlesContent and ZONE-plugin-OpenCalais). In fact code will use some class of the ZONE-utils project in order to retrieve items from the database.

Add dependencies

From mvnrepository

From local jar files

Run the following command:

  mvn deploy:deploy-file -Durl=file:./local-repo -Dfile=MyJarFileName.jar -DgroupId=MyJarFileName -DartifactId=MyJarFileName -Dpackaging=jar -Dversion=1.0

Add the local-repo in you pom file:

  <repositories>
    <repository>
      <id>local-repo</id>
      <url>file://${basedir}/local-repo</url>
    </repository>
  </repositories>

And the dependency in dependencies list:

    <dependency>
      <groupId>MyJarFileName</groupid>
      <artifactId>MyJarFileName</artifactid>
      <version>1.0</version>
    </dependency>