MDEP-187 从根因到修复
温馨提示
此内容版本在 ttr-2.2.1
已经修复,低于该版本需要手动处理。有任何问题可以联系作者,或者访问 TTBigdata知识库 (opens new window) 获取其他技术支持。
# 一、问题背景
在编译 Ambari Views 模块时,常会遇到以下错误:

典型报错信息如下:
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@518cf84a
[DEBUG] (s) silent = false
[DEBUG] (s) skip = false
[DEBUG] (f) stripClassifier = false
[DEBUG] (s) stripVersion = false
[DEBUG] (f) useBaseVersion = true
[DEBUG] (s) useRepositoryLayout = false
[DEBUG] (s) useSubDirectoryPerArtifact = false
[DEBUG] (s) useSubDirectoryPerScope = false
[DEBUG] (s) useSubDirectoryPerType = false
[DEBUG] -- end configuration --
[INFO] Copying classes to /opt/modules/ambari3/contrib/views/files/target/lib/ambari-views-utils-3.0.0.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Ambari Contrib Views 3.0.0.0.0:
[INFO]
[INFO] Ambari Contrib Views ............................... SUCCESS [ 4.940 s]
[INFO] Ambari View Utils .................................. SUCCESS [ 29.083 s]
[INFO] Ambari View Commons ................................ SUCCESS [ 18.491 s]
[INFO] Files .............................................. FAILURE [ 48.178 s]
[INFO] Capacity Scheduler ................................. SKIPPED
[INFO] Ambari Views Package ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:40 min
[INFO] Finished at: 2025-10-24T06:44:06Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies (default) on project files: Artifact has not been packaged yet. When used on reactor artifact, copy shou
ld be executed after packaging: see MDEP-187. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies (default) on project files: Artifact has not been packag
ed yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Artifact has not been packaged yet. When used on reactor artifact, copy should be executed after packaging: see MDEP-187.
at org.apache.maven.plugins.dependency.AbstractDependencyMojo.copyFile (AbstractDependencyMojo.java:180)
at org.apache.maven.plugins.dependency.fromDependencies.CopyDependenciesMojo.copyArtifact (CopyDependenciesMojo.java:249)
at org.apache.maven.plugins.dependency.fromDependencies.CopyDependenciesMojo.doExecute (CopyDependenciesMojo.java:124)
at org.apache.maven.plugins.dependency.AbstractDependencyMojo.execute (AbstractDependencyMojo.java:143)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :files
(base) [root@rocky8 views]#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
问题说明
报错关键字 MDEP-187 表示在多模块构建时,maven-dependency-plugin 试图复制尚未打包的依赖,
导致当前模块找不到目标 artifact 文件(即 jar 未生成),从而触发构建失败。
其根因是 copy-dependencies 阶段执行得过早,还没到 artifact 打包完毕的生命周期阶段。
# 二、问题根因分析
# 1、执行阶段错误
在原始配置中,copy-dependencies 位于 generate-resources 阶段:
<execution>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
而 Maven 的生命周期顺序中:
validate → compile → test → package → verify → install → deploy
1
在 generate-resources 阶段执行 copy-dependencies,意味着此时依赖 jar 尚未打包生成,因此出现:
Artifact has not been packaged yet
即:maven-dependency-plugin 在尝试复制目标 jar 时发现文件不存在。
# 三、修复点一:修改 capacity-scheduler 模块
contrib/views/capacity-scheduler/pom.xml
1

# 1、原始配置(错误示例)
<execution>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 2、修改方案
将执行阶段调整为 prepare-package,同时指定输出目录到 classes/WEB-INF/lib:
<!-- 复制运行时依赖到 classes/WEB-INF/lib;放到 prepare-package,避免 MDEP-187 -->
<execution>
<id>copy-lib-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- 直接写进 target/classes/WEB-INF/lib -->
<outputDirectory>${project.build.outputDirectory}/WEB-INF/lib</outputDirectory>
<includeScope>runtime</includeScope>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 3、注释掉原 lib 拷贝资源段
<!-- 注释掉旧资源拷贝段 -->
<!--
<resource>
<targetPath>WEB-INF/lib</targetPath>
<filtering>false</filtering>
<directory>target/lib</directory>
</resource>
-->
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 四、修复点二:修改 files 模块
contrib/views/files/pom.xml
1

# 1、原始配置
<execution>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 2、替换后的正确写法
<!-- 在 prepare-package 再复制依赖,避免 MDEP-187,并直接进 classes/WEB-INF/lib -->
<execution>
<id>copy-lib-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}/WEB-INF/lib</outputDirectory>
<includeScope>runtime</includeScope>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 五、验证与重新编译
两处修改完成后,重新执行编译命令:
# 使用 JDK 17
export JAVA_HOME=/opt/modules/jdk-17.0.2
export PATH=$JAVA_HOME/bin:$PATH
java -version
# 编译 Views 子模块
cd /opt/modules/ambari3/contrib/views
mvn clean install -DskipTests
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9

编译结果
当日志显示 所有 Views 模块 SUCCESS,即代表 MDEP-187 已修复。
# 六、补丁方式自动修复(推荐)
如果你使用的是 ambari-env 环境,可以直接使用补丁脚本修复:
https://github.com/TtBigdata/ambari-env/blob/dev/scripts/build/ambari3/common/patch2_2_1/patch2-VIEWS-COMPILE-FIXED.diff
1

该补丁会自动调整两个 POM 文件中的执行阶段与路径,确保后续构建稳定。
- 01
- Ambari开启Kerberos认证加密类型错误 Kylin V1011-05
- 02
- KERBEROS SERVICE CHECK 报错11-04