简体   繁体   English

Maven依赖插件不执行父级和子级(目标)执行

[英]maven-dependency-plugin not executing parent and child (goal)execution

I have two maven-dependency-plugin configs, one in my parent module and one in my child module. 我有两个maven-dependency-plugin配置,一个在我的父模块中,一个在我的子模块中。 The parent execution does not run only the child one. 父执行不只运行子执行。 If i manually copy(not move)the parent execution into the child plugin execution it works, but i do not want to do this as i need the parent config for other projects/children/modules also. 如果我手动将父执行复制(不移动)到子插件执行中,则可以,但是我不想这样做,因为我还需要其他项目/子/模块的父配置。 If i comment out the child plugin execution it runs the parent execution. 如果我注释掉子插件执行,它将运行父插件执行。

My child plugin execution is based on the answer here 我的子插件执行基于此处的答案

Child pom config(which always runs regardless): 子pom config(始终运行)

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    <executions>
           <execution>
            <id>copy-model</id>
            <phase>package</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>my.test.pkg</groupId>
                        <artifactId>my-model</artifactId>
                        <classifier>server</classifier>
                        <version>1.0.3</version>
                        <type>jar</type>
                    </artifactItem>
                </artifactItems>
               <outputDirectory>${project.build.directory}/lib</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

Parent config(which only runs when duplicated in child pom): 父配置(仅在子pom中复制时才运行):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
<executions>
       <execution>
        <id>build-classpath</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>build-classpath</goal>
        </goals>
        <configuration>
             <outputFilterFile>true</outputFileterFile>
             <includeScope/>
             <fileSeparator/>
            <outputDirectory>${project.build.directory}/lib</outputDirectory>
        </configuration>
    </execution>
</executions>
</plugin>

PluginManagement had both plug-in version and plug-in configuration in the parent pom.xml , this prohibits execution in the parent when you then inherit in the child pom. PluginManagement在父pom.xml中同时具有插件版本和插件配置,当您在子pom中继承时,这将禁止在父中执行。

Removed the configuration/execution from pluginManagement and this fixed it. 从pluginManagement中删除了配置/执行,并对其进行了修复。

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

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