使用 Maven 程序集插件将 rxtx 库打包到 jar 中

发布于 2024-12-18 00:57:30 字数 1522 浏览 2 评论 0原文

我需要创建一个具有依赖项的 jar 文件,并且需要添加 rxtx 库作为依赖项。但是当我创建 jar 时,我在 jar 文件中看不到 rxtx 。请向我发布执行此操作的正确方法。

这是我的 pom 文件的相关部分

....
    <dependency>
        <groupId>org.rxtx</groupId>
        <artifactId>rxtxcomm</artifactId>
        <version>2.0-7pre1</version>
        <scope>run</scope>
    </dependency>
....

....
<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>uom.elect.smeter.Output</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <!-- this is used for inheritance merges -->
                    <phase>package</phase>
                    <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>

        </plugin>
....

i need to create a jar file with dependencies and i need to add rxtx library as a dependency. but when i create the jar i cannot see rxtx in the jar file. please post me the correct way to do this.

this is my relevant part of the pom file

....
    <dependency>
        <groupId>org.rxtx</groupId>
        <artifactId>rxtxcomm</artifactId>
        <version>2.0-7pre1</version>
        <scope>run</scope>
    </dependency>
....

....
<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>uom.elect.smeter.Output</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <!-- this is used for inheritance merges -->
                    <phase>package</phase>
                    <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>

        </plugin>
....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后彩虹 2024-12-25 00:57:30
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>RXTXcommJar</artifactId>
                                <version>1.0.0</version>
                                <type>jar</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}
                                </outputDirectory>
                                <destFileName>RXTXcomm.jar</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>rxtxParalleldll</artifactId>
                                <version>1.0.0</version>
                                <type>dll</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}/apps/plugin/
                                </outputDirectory>
                                <destFileName>rxtxParallel.dll</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>rxtxSerialdll</artifactId>
                                <version>1.0.0</version>
                                <type>dll</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}/apps/plugin/
                                </outputDirectory>
                                <destFileName>rxtxSerial.dll</destFileName>
                            </artifactItem>                
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin> 
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>RXTXcommJar</artifactId>
                                <version>1.0.0</version>
                                <type>jar</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}
                                </outputDirectory>
                                <destFileName>RXTXcomm.jar</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>rxtxParalleldll</artifactId>
                                <version>1.0.0</version>
                                <type>dll</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}/apps/plugin/
                                </outputDirectory>
                                <destFileName>rxtxParallel.dll</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>org.company.project</groupId>
                                <artifactId>rxtxSerialdll</artifactId>
                                <version>1.0.0</version>
                                <type>dll</type>
                                <outputDirectory>
                                    ${project.build.outputDirectory}/apps/plugin/
                                </outputDirectory>
                                <destFileName>rxtxSerial.dll</destFileName>
                            </artifactItem>                
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文