如何解决带有依赖项或 uberjar 程序集的 ImageJ 插件在 FiJi 插件中不可用
我正在编写 ImageJ/Fiji 插件。当我使用以下 pom.xml
和 uberjar.xml
构建我的项目时,我得到以下 jar 文件;
MyFirstPlg-0.1.0.jar
MyFirstPlg-0.1.0-sources.jar
MyFirstPlg-0.1.0-uberjar.jar
MyFirstPlg-0.1.0-jar-with-dependencies.jar
如果我一次将每个 jar 文件复制/粘贴到斐济的插件中,并在重新启动斐济后检查是否可以在插件中看到我的插件;
MyFirstPlg-0.1.0.jar 和 MyFirstPlg-0.1.0-uberjar.jar:我可以看到我的插件但缺少依赖项,所以它会引发错误对于依赖,例如java.lang.NoClassDefFoundError: org/tensorflow/ndarray/ndarray
。虽然,根据大小 MyFirstPlg-0.1.0-uberjar.jar 是最大的,我认为它具有所有依赖项。
MyFirstPlg-0.1.0-sources.jar 和 MyFirstPlg-0.1.0-jar-with-dependencies.jar:我在插件中没有看到我的插件.
我想知道在我的 pom.xml 和 uberjar.xml 文件中缺少什么导致了这个问题。我已在 Maven 网页中检查了程序集 here,但找不到我遗漏的内容。
顺便说一句;如果我在 Eclipse 中将我的插件作为 Java 应用程序运行,它不会引发任何错误并按预期工作。
以下是 pom.xml
文件的主要部分。我策划了默认所需的部分;例如,邮件、scm、许可证、贡献者等
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- scijava is required and put in parent,I donot kNow why! -->
<!-- but is required for; org.scijava.* -->
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>26.0.0</version>
<relativePath />
</parent>
<!-- this is my project information -->
<groupId>org.mic.imageseg</groupId>
<artifactId>MyFirstPlg</artifactId>
<version>0.1.0</version>
<!-- here mailing list,contributers,license,scm,etc,defaults required -->
<repositories>
<repository>
<id>scijava.public</id>
<url>https://maven.scijava.org/content/groups/public</url>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/models</directory> <!-- I have some tensorflow model to be included in the jar file -->
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<descriptors>
<descriptor>src/assembly/uberjar.xml</descriptor> <!-- this where my uberjar.xml file located.-->
</descriptors>
<includes>
<include>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</include>
<include>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>0.3.1</version>
</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<!-- here goes dependencies -->
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>0.3.1</version>
</dependency>
</dependencies>
</project>
这是我的 uberjar.xml
,它位于 src/assembly
文件夹中。
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>uberjar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<useProjectArtifact>true</useProjectArtifact>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>\</outputDirectory>
</fileSet>
</fileSets>
</assembly>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。