如何包含本地存储库中的Maven插件? [英] How do I include a Maven plugin from a local repository?

查看:91
本文介绍了如何包含本地存储库中的Maven插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义插件,可以压缩需要包含在我的maven构建中的文件.因此,我已将此插件包含在我的pom.xml中:

I have a custom plugin that compresses files that I need to include in my maven build. So I have included this plugin in my pom.xml:

   <build>
        // Other tags
       <plugin>
            <groupId>someGroupId</groupId>
            <artifactId>somePlugin</artifactId>
            <version>1.0.0</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
      </plugins>
 </build>

由于它是一个自定义插件,因此在任何公共Maven存储库中均不可用.因此,每当我尝试构建时,我都会收到一条错误消息:

Since it is a custom plugin, it is not available in any public Maven repository. So whenever I try to build, I get an error message saying:

Failed to read artifact .....

即使我已将其添加到本地存储库中.如何引用本地存储库中的此插件?

even though I have added it to my local repository. How can I refer to this plugin that is in my local repository?

推荐答案

如果是在

If you mean local repository in the classic sense, make sure that you installed your plugin jar correctly. Install it to your local repository again with the following command:

mvn install:install-file -Dfile=/some/path/somePlugin.jar -DgroupId=someGroupId -DartifactId=somePlugin -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

然后您应该可以在Maven构建中使用您的插件.

You should then be able to use your plugin in your Maven build.

如果您是指本地托管的某个存储库,则需要将包含工件的存储库指定为pluginRepository.将以下内容添加到pom.xml的顶层:

If you mean local in the sense of some locally hosted repository, you need to specify the repository containing your artifact as a pluginRepository. Add the following to the top level of your pom.xml:

<pluginRepositories>
    <pluginRepository>
        <id>some-repo</id>
        <name>Some Repository</name>
        <url>http://some.host/some/path</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

这篇关于如何包含本地存储库中的Maven插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆