简体   繁体   English

使用自定义版本的工件而不是repo中的版本来构建Maven项目

[英]Building maven project with custom version of artifact instead of the one from repo

I'm new to maven, sorry for nub question: need to build maven project using my version of artifact instead of the one from repo . 我是maven的新手,对nub问题感到抱歉: 需要使用我的工件版本而不是repo来构建maven项目

More detailed: I downloaded jboss sources from github and built them using maven 3. It was great! 更详细:我从github下载了jboss源码,并使用maven 3进行了构建。太好了! I need to do some changes in jboss dependancy called "picketbox". 我需要对jboss依赖性进行一些更改,称为“ picketbox”。 Now it is an artifact in jboss's "pom.xml". 现在,它是jboss的“ pom.xml”中的工件。

I built my own version of picketbox in my_picketbox.jar file. 我在my_picketbox.jar文件中构建了自己的picketbox版本。 How can I tell maven to use my .jar instead of the one from repo? 我如何告诉Maven使用我的.jar而不是repo中的那个?

Maybe I'm missing something but if you explicitly renamed the artifact then it will just be a matter of replacing picketbox with my_picketbox in the relevant JBoss POM-file(s). 也许我丢失了一些东西,但是如果您显式重命名了工件,那将只是在相关JBoss POM文件中用my_picketbox替换picketbox的问题。

<dependency>
    <groupId>...</groupId>
    <artifactId>my_picketbox</artifactId>
    <version>...</version>
</dependency>

And of course, you make sure your artifact is in your local repo by mvn install 'ing it. 当然,您可以通过mvn install来确保您的工件在本地仓库中。

Cheers, 干杯,

i would install the jar file using the maven-install plugin. 我会使用maven-install插件安装jar文件。

http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

First, install your version of Picketbox into your local Maven repository. 首先,将您的Picketbox版本安装到本地Maven存储库中。 If your custom version is a Maven project, you can do that by running 如果您的自定义版本是Maven项目,则可以通过运行

mvn install

If your custom Picketbox version is not a Maven project, install the Jar itself into your local Maven repository like this: 如果您的自定义Picketbox版本不是Maven项目,则将Jar本身安装到本地Maven存储库中,如下所示:

mvn install:install-file -Dfile=my_picketbox.jar -DgroupId=org.picketbox -DartifactId=my_picketbox -Dversion=2.3 -Dpackaging=jar

Then change the version of Picketbox that JBoss depends on by adding this snippet to the pom.xml file of the JBoss project you're building (replace the existing dependency on pocketbox with this one): 然后通过将以下代码片段添加到正在构建的JBoss项目的pom.xml文件中,来更改JBoss依赖的Picketbox的版本(用此代码替换PocketBox上的现有依赖项):

<dependency>
    <groupId>org.picketbox</groupId>
    <artifactId>my_picketbox</artifactId>
    <version>2.3</version>
</dependency>
<dependency>
    <groupId>xxx</groupId>
    <artifactId>xxx</artifactId>
    <version>x.x.x</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/xxxx.jar</systemPath>
</dependency>

This allows you to reference libaries that are not stored localy rather than maven central. 这使您可以引用不在本地存储的库,而不是Maven Central的库。

Maven takes what has been specified in POM files; Maven采用POM文件中指定的内容; mind you, that the POM including the dependency you wrote about can be buried very deeply, not even within the sources you downloaded. 请注意,包括您编写的依赖项在内的POM可能会被深深地埋没,甚至不被下载到的源中。

Search your project tree for the artifact in question and replace its version number to your version. 在项目树中搜索有问题的工件,然后将其版本号替换为您的版本。 If this does not help, do as Nils says in the other answer, but remember to install the artifact in the original version (you may have to find it first in your local repository and remove it). 如果这样做没有帮助,请按照Nils在另一个答案中所述进行操作,但请记住以原始版本安装工件(您可能必须先在本地存储库中找到它,然后将其删除)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Intellij从修改后的Maven项目构建工件 - Building an artifact from a modified maven project with Intellij 使用SBT将工件发布到本地Maven存储库并在Gradle项目中使用 - Publish artifact to local maven repo with SBT and use it in Gradle project Maven无法从/到repo1.maven.org传输工件 - Maven Could not transfer artifact from/to repo1.maven.org 从原型创建项目时如何固定Maven工件的最新版本 - How to pin latest version of a maven artifact while creating a project from archetype 在 Eclipse 中运行时从 pom 获取 maven 项目版本和工件 ID - Getting maven project version and artifact ID from pom while running in Eclipse 如何用“ Maven Dependencies”而不是“ Referenced Libraries”“ M2_REPO / ..”从Maven生成Eclipse项目。 - How to generate eclipse project from maven with “Maven Dependencies” instead of “Referenced Libraries” “M2_REPO/..” 将项目中的单个 package 发布为 maven 工件 - Publish a single package from a project as maven artifact 为什么在本地maven repo上安装时会从工件中删除分类器? - Why classifier is removed from artifact while installing on local maven repo? Maven配置文件和工件版本 - Maven profile and artifact version 使用Maven项目的依赖项进行构建? - Building with dependencies from a Maven project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM