我需要创建一个带有依赖项的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>
....
答案 0 :(得分:0)
<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>