Post

2 followers Follow
0
Avatar

Custom plugin dependencies

I've written a custom plugin that runs as expectedwhen started from Intellij and it builds successfully with Ant. When I try and import the plugin into Geneious, I get the following error:

Here's the build.xml file:

<?xml version="1.0" ?>

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="ProteinTargetDbExport" default="distribute" basedir="." >

<property file="plugin.properties"/>
<property name="build" location="build"/>
<property name="classes" location="classes"/>
<property name="src" location="src"/>

<path id="classpath">
<fileset dir="../GeneiousFiles/lib">
<include name="GeneiousPublicAPI.jar"/>
<include name="jdom.jar"/>
<include name="jebl.jar"/>
</fileset>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>

<target name="distribute" depends="build">
<copy file="${build}/${short-plugin-name}.jar" tofile="${build}/${short-plugin-name}.gplugin"/>
<echo message="Created ${build}/${short-plugin-name}.gplugin"/>

<!--If your plugin consists of a folder you should build it into
a zip file with extension gplugin. See commented example below.
Remove above line and uncomment these to use-->
<!--
<zip zipfile="${build}/${short-plugin-name}.gplugin">
<fileset dir="${build}" includes="${plugin-name}/**" />
</zip>
-->
</target>

<!-- =================================
target: resolve
================================= -->
<target name="resolve" description="--> retrieve dependencies with Ivy">
<ivy:retrieve/>
</target>
<target name="build" depends="compile">
<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
<fileset dir="">
<include name="plugin.properties"/>
</fileset>
</jar>

<!--build example for folder type plugin. Remove above
lines and uncomment these to use-->
<!--
<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
</jar>
<mkdir dir="${build}/${plugin-name}"/>
<copy todir="${build}/${plugin-name}">
<fileset dir="${build}">
<include name="ExtraFiles"/>
<include name="ExtraFiles/*"/>
<include name="${short-plugin-name}.jar"/>
</fileset>
<fileset dir="docs">
<include name="readme.txt"/>
</fileset>
</copy>
-->
</target>
<!-- =================================
target: report
================================= -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build}"/>
</target>


<target name="compile" depends="prepare">
<javac target="1.8" source="1.8" destdir="${classes}" debug="true">
<classpath refid="classpath"/>
<src path="${src}"/>
</javac>
</target>

<target name="prepare" depends="resolve">
<mkdir dir="${build}"/>
<mkdir dir="${classes}"/>
</target>

<target name="clean">
<delete dir="${build}"/>
<delete dir="${classes}"/>
</target>

<target name="copyPluginAndRename">
<!-- This task renames this plugin, including source code files and build scripts.
To use it, enter the appropriate values for the first 3 properties and then run it.
The 3rd property value must be identical to the second except with "." replaced with "/" -->
<property name="newPluginName" value="ProteinTargetDbExportPlugin"/>
<property name="newPluginPackageName" value="com.absci.geneious.proteindbexport"/>
<property name="newPluginPackagePath" value="com/absci/geneious/proteindbexport"/>

<property name="oldPluginName" value="ProteinTargetDbExportPlugin"/>
<property name="oldPluginPackageName" value="com.absci.geneious.proteindbexport"/>
<property name="oldPluginPackagePath" value="com/absci/geneious/proteindbexport"/>
<!--It doesn't appear we can automatically replace "." with "/" in a property in basic ant without relying on the ant-contrib package being installed-->

<property name="destDir" value="../${newPluginName}"/>

<fail message="You must set the newPluginName property in the ant task XML before running this">
<condition>
<equals arg1="${oldPluginName}" arg2="${newPluginName}"/>
</condition>
</fail>
<fail message="You must set the newPluginPackageName property in the ant task XML before running this">
<condition>
<equals arg1="${oldPluginPackageName}" arg2="${newPluginPackageName}"/>
</condition>
</fail>
<fail message="You must set the newPluginPackagePath property in the ant task XML before running this">
<condition>
<equals arg1="${oldPluginPackagePath}" arg2="${newPluginPackagePath}"/>
</condition>
</fail>

<copy todir="${destDir}">
<fileset dir="."/>
</copy>

<replace dir="${destDir}" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
<replace dir="${destDir}" token="${oldPluginPackagePath}" value="${newPluginPackagePath}"/>
<replace dir="${destDir}" token="${oldPluginName}" value="${newPluginName}"/>

<move todir="${destDir}/src/${newPluginPackagePath}">
<fileset dir="${destDir}/src/${oldPluginPackagePath}"/>
</move>

<move todir="${destDir}/src/${newPluginPackagePath}">
<fileset dir="${destDir}/src/${newPluginPackagePath}"/>
<mapper type="glob" from="${oldPluginName}*.java" to="${newPluginName}*.java"/>
</move>

<move todir="${destDir}">
<fileset dir="${destDir}"/>
<mapper type="glob" from="${oldPluginName}.*" to="${newPluginName}.*"/>
</move>

<!-- edit intellij project files -->

<copy todir="../.ideaBackup" overwrite="true">
<fileset dir="../.idea"/>
</copy>

<copy file="../.idea/modules.xml" tofile="../.idea/modules.xml.new" overwrite="true">
<filterchain>
<tokenfilter>
<replaceregex byline="true" flags="s"
pattern="(.*)${oldPluginName}/${oldPluginName}(.*)${oldPluginName}/${oldPluginName}(.*)$"
replace="\0&#10;\1${newPluginName}/${newPluginName}\2${newPluginName}/${newPluginName}\3"/>
</tokenfilter>
</filterchain>
</copy>
<fixcrlf file="../.idea/modules.xml.new"/>
<move file="../.idea/modules.xml.new" tofile="../.idea/modules.xml" overwrite="true"/>

<copy file="../.idea/runConfigurations/${oldPluginName}__64_bit_.xml"
tofile="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" overwrite="true"/>
<replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginPackageName}"
value="${newPluginPackageName}"/>
<replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginName}"
value="${newPluginName}"/>

<copy file="../.idea/runConfigurations/${oldPluginName}__32_bit_.xml"
tofile="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" overwrite="true"/>
<replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginPackageName}"
value="${newPluginPackageName}"/>
<replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginName}"
value="${newPluginName}"/>


</target>

</project>

and the associated ivy.xml file for defining dependencies:

<ivy-module version="2.0">
<info organisation="com.absci" module="ProteinTargetDbExportPlugin"/>
<dependencies>
<dependency org="com.squareup.okhttp3" name="okhttp" rev="3.4.1"/>
<dependency org="com.squareup.okhttp3" name="logging-interceptor" rev="3.4.1"/>
<dependency org="com.squareup.retrofit2" name="retrofit" rev="2.5.0"/>
<dependency org="com.squareup.retrofit2" name="converter-gson" rev="2.5.0"/>
</dependencies>
</ivy-module>

I'm using the GeneiousPublicAPI.jar from the geneious-2019.1.1-devkit and running Geneious Prime 2019.2.1. I also get the same error when running Geneious Primer 2019.1.1.







Sandra Peters

Please sign in to leave a comment.

2 comments

0
Avatar

Since you have jar dependencies, it looks like you need to switch over the "folder type" plugin build. So your build target should look something like the follwing, except you need to substitute the "ExtraFiles" paths to copy the necessary jars (e.g. retrofit in your case).

<target name="build" depends="compile">
<!--<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
<fileset dir="">
<include name="plugin.properties"/>
</fileset>
</jar>-->

<!--build example for folder type plugin. Remove above
lines and uncomment these to use-->

<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
</jar>
<mkdir dir="${build}/${plugin-name}"/>
<copy todir="${build}/${plugin-name}">
<fileset dir="${build}">
<include name="ExtraFiles"/>
<include name="ExtraFiles/*"/>
<include name="${short-plugin-name}.jar"/>
</fileset>
<fileset dir="docs">
<include name="readme.txt"/>
</fileset>
</copy>
</target>
Richard Moir 0 votes
Comment actions Permalink
0
Avatar

Here's how I fixed this problem - I created a folder called ExtraFiles in my project:

I copied all of my external dependencies (e.g. retrofit-2.5.0.jar) to the ExtraFiles directory and changed my build script as follows:

<target name="build" depends="compile">
<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
</jar>
<mkdir dir="${build}/${plugin-name}"/>
<copy todir="${build}/${plugin-name}">
<fileset dir="${ExtraFiles}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${build}">
<include name="${short-plugin-name}.jar"/>
</fileset>
</copy>

</target>

Running "ant build" generated this folder structure:

 

I was then able to load the plugin.jar file successfully into Geneious.

 

 

 

Sandra Peters 0 votes
Comment actions Permalink