0
头像

自定义插件依赖

我编写了一个自定义插件,该插件在从 Intellij 启动时按预期运行,并且使用 Ant 成功构建。当我尝试将插件导入 Geneious 时,出现以下错误:

这是 build.xml 文件:

<?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
一个扩展名为 gplugin 的 zip 文件。请参阅下面的评论示例。
删除上面的行并取消注释这些以使用-->
<!--
<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.删除上面
行并取消注释这些以使用-->
<!--
<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>

我正在使用 Geneious-2019.1.1-devkit 中的 GeneiousPublicAPI.jar 并运行 Geneious Prime 2019.2.1。运行 Geneious Primer 2019.1.1 时,我也遇到同样的错误。







桑德拉·彼得斯

2 条评论

0
头像

由于您有 jar 依赖项,看起来您需要切换“文件夹类型”插件构建。因此,您的构建目标应该类似于以下内容,除非您需要替换“ExtraFiles”路径来复制必要的 jar(例如,在您的情况下进行改造)。

<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.删除上面
行并取消注释这些以使用-->

<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>
理查德·摩尔 0 票
评论动作 永久链接
0
头像

这是我解决这个问题的方法 - 我在我的项目中创建了一个名为 ExtraFiles 的文件夹:

我将所有外部依赖项(例如,retrofit-2.5.0.jar)复制到 ExtraFiles 目录并按如下方式更改了我的构建脚本:

<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>

运行“ant build”生成了这个文件夹结构:

 

然后我能够将 plugin.jar 文件成功加载到 Geneious 中。

 

 

 

桑德拉·彼得斯 0 票
评论动作 永久链接