我目前正在使用:
mvn install:install-file -Dfile={path/to/my/legacy.jar} -DgroupId=horrible -DartifactId=legacy.jar -Dversion=1.2.3 -Dpackaging=jar
Run Code Online (Sandbox Code Playgroud)
将一些旧的传统罐子导入我的仓库.这很好,是推荐的方法.好像这可以用POM而不是我现在使用的命令行+脚本来完成.我认为有更清洁:
mvn install:install-file
Run Code Online (Sandbox Code Playgroud)
让我的repo存储版本细节,而不是将这些信息存储在非maven脚本中(对于maven来说这是奇怪的).我尝试通过设置标记公开这些-D设置,但这不起作用.有没有其他人试过这个并让它工作?
我有一个maven项目。
在该项目中,我有一个带有jar 的.zip依赖项,我需要从zip依赖项中提取该jar并让 Maven 使用该jar作为依赖项。我目前可以下载并解压 zip,但是无法找到在构建过程中将解压的jar添加为项目依赖项的方法。
这是我目前正在做的拆包工作:
<dependency>
<groupId>com.bar</groupId>
<artifactId>foo</artifactId>
<version>${foo.version}</version>
<type>zip</type>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>validate</phase>
<configuration>
<includeGroupIds>com.bar</includeGroupIds>
<includeArtifactIds>foo</includeArtifactIds>
<outputDirectory>${basedir}/target</outputDirectory>
<type>jar</type>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我阅读了其他一些帖子,您可以尝试使用它将 jar 添加到类路径中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
即使这样做,我仍然无法在我的项目中引用foo.jar中的包。
有人能帮我吗?
我有一个使用 Maven 的 Java 项目。在我的项目中,我有一个名为的文件夹libs,其中包含我无法从 Internet/外部存储库加载的所有 JAR。
我的问题是如何指定 Maven 在打包、构建等过程中包含这些 JAR?
Maven 新手,抱歉,如果这是一个愚蠢的问题。
编辑:我有一个自动工具,可以pom.xml在我的 Git 上查找我的项目,以在不同的环境中构建和部署我的项目。因此,按照此处的建议将其添加到本地 Maven 存储库中将无济于事,因为它只能在我的 PC 上运行。如果我添加一个libs带有 JAR的文件夹,无论我在哪里,它都可以使用。
如果不清楚或者我弄错了,请在评论中问我。