gpt4 book ai didi

java - 自定义 Maven 插件托管和前缀解析

转载 作者:搜寻专家 更新时间:2023-11-01 02:47:06 24 4
gpt4 key购买 nike

我已经编写了自己的自定义 Maven 插件并将其上传到我的 Archiva 服务器。它适用于指定的全名:

mvn com.mjolnirr:maven-plugin:manifest

但是当我想通过前缀来做时,它失败了:

mvn mjolnirr:manifest

[ERROR] No plugin found for prefix 'mjolnirr' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/sk_/.m2/repository), mjolnirr (http://mjolnirr.dyndns.org/archiva/repository/plugins), central (http://repo.maven.apache.org/maven2)] -> [Help 1]

我的插件的pom:

<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>com.mjolnirr</groupId>
<artifactId>mjolnirr-maven-plugin</artifactId>
<version>0.2</version>
<packaging>maven-plugin</packaging>

<name>Mjolnirr Maven Plugin</name>

<url>http://mjolnirr.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>mjolnirr</id>
<name>Mjolnirr snapshot repository</name>
<url>http://mjolnirr.com/archiva/repository/snapshots</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>mjolnirr</id>
<name>Maven Plugin Repository</name>
<url>http://mjolnirr.com/archiva/repository/snapshots</url>
</pluginRepository>
</pluginRepositories>

<dependencies>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.3</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.3</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>

<!-- For superclass resolving -->
<dependency>
<groupId>com.mjolnirr</groupId>
<artifactId>core</artifactId>
<version>0.2</version>
</dependency>

<!-- For XML producing -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.5</version>
</dependency>

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>mjolnirr</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
<profiles>
<profile>
<id>run-its</id>
<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>1.7</version>
<configuration>
<debug>true</debug>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<postBuildHookScript>verify</postBuildHookScript>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<goals>
<goal>clean</goal>
<goal>test-compile</goal>
</goals>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</profile>
</profiles>
</project>

看来我必须将一些定义放入我的存储库中。你能帮帮我吗?

ADD 我发现 maven 试图从 org/apache/maven/plugins 下载 maven-metadata.xml。是否可以在不更改 maven 设置的情况下更改项目 POM 中的此路径?

最佳答案

默认情况下,只会搜索 groupId 为 org.apache.maven.plugins 的插件。

要让 Maven 为插件搜索额外的 groupIds,可以在每个用户的 settings.xml 文件中配置额外的插件组,例如:

<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
</pluginGroups>

有关这方面的更多信息,请参阅 Maven plugin guide .

关于java - 自定义 Maven 插件托管和前缀解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19660683/

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