繁体   English   中英

如何在子POM中继承Maven插件条目

[英]How to inherit Maven plugin entry in child POM

我在子POM中添加了以下插件,它可以正常工作。 如果我在父POM中添加相同的插件,则无法正常工作,我希望将此插件添加到父POM中并在子POM中继承该插件。

你能帮忙怎么做吗?

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
              <compilerArguments>                   <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
              </compilerArguments>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                  <silent>true</silent>
                  <artifactItems>
                    <artifactItem>
                      <groupId>javax.xml.bind</groupId>
                      <artifactId>jaxb-api</artifactId>
                      <version>2.2.4</version>
                      <type>jar</type>
                    </artifactItem>
                    <artifactItem>
                      <groupId>javax.xml.ws</groupId>
                      <artifactId>jaxws-api</artifactId>
                      <version>2.2.8</version>
                      <type>jar</type>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>

据我所知,您将需要在<build><plugins><plugin>级别为需要它的每个pom配置依赖项。

我所知道的最让您从父pom继承信息的方法是使用变量或使用<dependencyManagement> 但是我认为这两种方法都不适合您的要求。

请注意, <dependencyManagement>仅管理整个项目中的依赖项信息,例如版本。 除非稍后在<dependencies>部分中再次明确定义,否则它实际上不会创建依赖<dependencies> 您可以参考Maven文档以获取更多信息。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM