gpt4 book ai didi

maven - 如何通过 Maven 仅复制操作系统特定的依赖项 jar?

转载 作者:行者123 更新时间:2023-12-03 08:48:36 24 4
gpt4 key购买 nike

我目前正在开发一个使用(以及其他)nd4j、deeplearning4j 依赖项的项目。这些依赖项包括不同操作系统的版本,例如“nd4j-native-1.0.0-beta6-android-arm.jar”或“nd4j-native-1.0.0-beta6-linux-armhf.jar”等。

由于该项目只能在 linux-x64 上运行,我想知道是否有办法告诉 Maven 复制不需要的 JAR。我希望减少不必要的库所需的磁盘空间。

pom.xml 目前看起来像这样,能够生成可部署的输出:

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

<groupId>MyGroup</groupId>
<artifactId>MyApp</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza.ext</groupId>
<artifactId>org.json.simple</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-core</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-server</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-beta6</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>1.0.0-beta6</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-parallel-wrapper</artifactId>
<version>1.0.0-beta6</version>
</dependency>
</dependencies>

<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
<useRepositoryLayout>true</useRepositoryLayout>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathLayoutType>repository</classpathLayoutType>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>MyMainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>

最佳答案

通常,如果您想为 dl4j 或基于 javacpp 的任何内容捆绑平台特定的二进制文件,您可以执行以下操作: https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies

具体来说,您只需为所有 javacpp 依赖项指定 -Djavacpp.platform=linux-x86_64 即可。

关于maven - 如何通过 Maven 仅复制操作系统特定的依赖项 jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60336169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com