使用maven清理安装一些模块导致错误:构建POM时出错(可能不是此项目的POM)

时间:2015-10-02 13:30:35

标签: java maven pom.xml

在路径C:\ PMX \ checkout \ components \ promomax-all_webapps_component我有这个文件:pom-aggregator-packaging.xml

文件pom-aggregator-packaging.xml包含一些使用turtoiseCVS检出的模块。

当我进入cmd到路径C:\ PMX \ checkout \ components \ promomax-all_webapps_component并输入 mvn -f pom-aggregator-packaging.xml clean install 时返回的错误是:< / p>

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: unknown

Reason: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Could not find the model file 'C:\PMX\checkout\bundles\promomax-spring_aspects'. for project unknown
    at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1575)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
    at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
    at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:560)
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
    ... 12 more
Caused by: java.io.FileNotFoundException: C:\PMX\checkout\bundles\promomax-spring_aspects (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at hidden.org.codehaus.plexus.util.xml.XmlReader.<init>(XmlReader.java:124)
    at hidden.org.codehaus.plexus.util.xml.XmlStreamReader.<init>(XmlStreamReader.java:67)
    at hidden.org.codehaus.plexus.util.ReaderFactory.newXmlReader(ReaderFactory.java:118)
    at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1570)
    ... 18 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Oct 02 15:46:09 EEST 2015
[INFO] Final Memory: 6M/243M
[INFO] ------------------------------------------------------------------------

pom-aggregator-packaging.xml的内容是:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company_name.app_name</groupId>
  <artifactId>monitoring-pom-aggregator</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>
  <name>NameOfTheApp Engine Server Component Pom Aggregator</name>
  <modules>
    ...
    <module>../../bundles/promomax-spring_aspects</module> 
    ... 
  </modules>
</project>

请帮助我解决此错误?

如果在pom-aggregator-packaging.xml中我改变了

<module>../../bundles/promomax-spring_aspects</module>给出绝对路径:

<module>C:/PMX/checkout/components/promomax-all_webapps_component/bundles/promomax-spring_aspects</module>

然后再次运行命令 mvn -f pom-aggregator-packaging.xml clean install ,新错误是:

[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to canonicalize file name C:\PMX\checkout\components\promomax-all_webapps_component\C:\PMX\checkout\components\promomax-all_webapps_component\bundles\promomax-spring_aspects
The filename, directory name, or volume label syntax is incorrect
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:1)

非常肯定,如果你更换

<module>../../bundles/promomax-spring_aspects</module> 

<module>../../components/promomax-all_webapps_component/bundles/promomax-spring_aspects</module> 

它会起作用。

但是你的设置对我来说似乎并不干净。引用模块通常是从父POM完成的,它应该位于比子poms更高级别(文件系统)上。

所以更像是

  • 的myproject
    • 我的模块1
      • 的pom.xml
    • 我的模块2
      • 的pom.xml
    • pom.xml(parent)

除非你在父母/子女的背景下,否则你不应该依赖相对路径。

进一步阅读: https://stackoverflow.com/a/10453063/190596