错误信息见 附录。
如何定位:
1、开启 -X模式,打印详细日志。进入到子的module,执行mvn eclipse:eclipse-DskipTests -X
2、从-X的日志中看到如下信息,从调用堆栈的函数,如下是三个参数,对第二个参数做getCanonicalPath的时候报错。中间有个G:无法解析!
[DEBUG] Making relative and fixing separator: { G:\project\apache-lens-2.6.1\lens-dist, G:\project\apache-lens-2.6.1\lens-dist\target\classes\G:\project\apache-lens-2.6.1\lens-dist\target\debian\control, false }
3、如何修改,在父工程中做如下修改:
<build>
<sourceDirectory>${src.dir}</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/deb/control</directory>
<!-- G:\project\apache-lens-2.6.1\lens-dist\target\classes\G:\project\apache-lens-2.6.1\lens-dist\target\debian\control -->
<!-- <targetPath>${mvn.deb.build.dir}/control</targetPath>-->
<targetPath>../debian/control</targetPath>
<filtering>true</filtering>
</resource>
和原来的实现效果一直。targetPath一般不建议用绝对路径,这里也提到了(https://issues.apache.org/jira/browse/MECLIPSE-269)。
测试通过。另外说明下 File类的getCanonicalPath()方法,“返回的是规范化的绝对路径,相当于将getAbsolutePath()中的“.”和“..”解析成对应的正确的路径”。所以修改 ../debian/control是可以返回正确的绝对路径的。
附录,错误信息:
Mycommond:G:\project\apache-lens-2.6.1>mvn eclipse:eclipse-DskipTests -X
INFO] Lens Examples...................................... SUCCESS [ 1.452 s]
[INFO] Lens Ship Jars to Distributed Cache................ SUCCESS [ 1.213 s]
[INFO] Lens Distribution.................................. FAILURE [ 2.668 s]
[INFO] Lens ML Lib........................................ SKIPPED
[INFO] Lens ML Ext Distribution........................... SKIPPED
[INFO] Lens Regression ....................................SKIPPED
[INFO] Lens UI............................................ SKIPPED
[INFO] Lens Contrib....................................... SKIPPED
[INFO] Lens Contributed Clients........................... SKIPPED
[INFO] Lens Python Client................................. SKIPPED
[INFO]------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]------------------------------------------------------------------------
[INFO] Total time: 02:04 min
[INFO] Finished at: 2016-12-12T22:53:09+08:00
[INFO] Final Memory: 133M/710M
[INFO]------------------------------------------------------------------------
[ERROR] Failed to execute goalorg.apache.maven.plugins:maven-eclipse-plugin:2.10:eclipse (default-cli) onproject lens-dist: Cant canonicalize system path: {0}: 文件名、目录名或卷标语法不正确。 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:Failed to execute goalorg.apache.maven.plugins:maven-eclipse-plugin:2.10:eclipse (default-cli) onproject lens-dist: Cant canonicalize system path: {0}
atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
atorg.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
atorg.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
atorg.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
atorg.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
atorg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
atorg.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
atorg.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
atorg.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
atorg.apache.maven.cli.MavenCli.main(MavenCli.java:197)
atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:497)
atorg.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
atorg.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
atorg.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
atorg.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by:org.apache.maven.plugin.MojoExecutionException: Cant canonicalize system path:{0}
atorg.apache.maven.plugin.ide.IdeUtils.getCanonicalPath(IdeUtils.java:146)
atorg.apache.maven.plugin.ide.IdeUtils.toRelativeAndFixSeparator(IdeUtils.java:582)
atorg.apache.maven.plugin.eclipse.EclipsePlugin.extractResourceDirs(EclipsePlugin.java:1745)
atorg.apache.maven.plugin.eclipse.EclipsePlugin.buildDirectoryList(EclipsePlugin.java:1635)
atorg.apache.maven.plugin.eclipse.EclipsePlugin.createEclipseWriterConfig(EclipsePlugin.java:1341)
atorg.apache.maven.plugin.eclipse.EclipsePlugin.writeConfiguration(EclipsePlugin.java:1165)
atorg.apache.maven.plugin.ide.AbstractIdeSupportMojo.execute(AbstractIdeSupportMojo.java:481)
atorg.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
atorg.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20more
Caused by: java.io.IOException: 文件名、目录名或卷标语法不正确。
atjava.io.WinNTFileSystem.canonicalize0(Native Method)
atjava.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
atjava.io.File.getCanonicalPath(File.java:618)
atorg.apache.maven.plugin.ide.IdeUtils.getCanonicalPath(IdeUtils.java:142)
... 28more
[ERROR]
[ERROR]
[ERROR] For more information about the errors andpossible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you canresume the build with the command
[ERROR] mvn <goals> -rf:lens-dist