微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

带有依赖项或 uberjar 程序集的 ImageJ 插件在 FiJi 插件中不可用

如何解决带有依赖项或 uberjar 程序集的 ImageJ 插件在 FiJi 插件中不可用

我正在编写 ImageJ/Fiji 插件。当我使用以下 pom.xmluberjar.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.jarMyFirstPlg-0.1.0-uberjar.jar:我可以看到我的插件但缺少依赖项,所以它会引发错误对于依赖,例如java.lang.NoClassDefFoundError: org/tensorflow/ndarray/ndarray。虽然,根据大小 MyFirstPlg-0.1.0-uberjar.jar 是最大的,我认为它具有所有依赖项。

MyFirstPlg-0.1.0-sources.jarMyFirstPlg-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 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?