kev*_*vin 5 maven-plugin pom.xml maven
在我的 pom.xml 中,如果我给出以下内容,它似乎可以工作。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
插件不需要groupId吗?如果没有给出groupId,maven如何下载插件?
谢谢
khm*_*ise 11
在 pom.xml 中,您可以通过 groupId、artifactId 和 version 定义插件。但对于 groupId,Maven 4.0.0 XSD 文件中定义了一个默认值。如果你看一下插件的定义(这里是 XSD 文件的摘录):
<xs:complexType name="Plugin">
<xs:annotation>
<xs:documentation source="version">4.0.0+</xs:documentation>
<xs:documentation source="description"> The <code><plugin></code> element contains informations required for a plugin. </xs:documentation>
</xs:annotation>
<xs:all>
<xs:element minOccurs="0" name="groupId" type="xs:string" default="org.apache.maven.plugins">
<xs:annotation>
<xs:documentation source="version">4.0.0+</xs:documentation>
<xs:documentation source="description">The group ID of the plugin in the repository.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="artifactId" type="xs:string">
<xs:annotation>
<xs:documentation source="version">4.0.0+</xs:documentation>
<xs:documentation source="description">The artifact ID of the plugin in the repository.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="version" type="xs:string">
<xs:annotation>
<xs:documentation source="version">4.0.0+</xs:documentation>
<xs:documentation source="description">The version (or valid range of versions) of the plugin to be used.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="extensions" type="xs:string
Run Code Online (Sandbox Code Playgroud)
您可以在其中看到为 groupIdorg.apache.maven.pugins定义了默认值。这意味着每次您不在区域中定义 groupId 时plugin,ReportPlugin它都会自动使用 groupId。org.apache.maven.plugins为了这。
提到的插件搜索是不同的。这是从命令链接调用插件目标的情况,如下所示:
mvn versions:set ...
mvn help:help ...
Run Code Online (Sandbox Code Playgroud)
默认情况下,给定的名称将在两个 groupId 中搜索:org.apache.maven.plugins和org.codehaus.mojo。插件本身的名称是基于两种命名模式进行搜索的,maven-${prefix}-plugin这是在 Apache Software Foundation 中开发的所有 Maven 插件的情况(包括与该名称空间相关的 ASF 商标,其中还包括 groupId)和第二个命名模式命名模式${prefix}-maven-plugin。
| 归档时间: |
|
| 查看次数: |
1926 次 |
| 最近记录: |