让Maven找到我项目的父POM的正确方法是什么?

时间:2014-10-28 11:33:46

标签: maven repository pom.xml parent-pom

我有一个Maven项目,它是大型企业系统的一部分。我还没有开发这个项目,但是我开发了一个小框架,我应该测试它,并与之集成。在复制,构建和安装项目时,它已编译,我能够启动它。但是,在尝试添加我的框架(父pom + 3模块)之后,我可能已经更改了一些设置,现在我在构建项目时遇到了问题。我花了很多时间试图解决这个问题,但我所能做的就是产生不同的错误,我理解的更少。

我似乎无法找到告诉maven在哪里寻找父POM的地方。我已经尝试了pom.xml和settings.xml,但我还没有找到任何好的选择。我也试图改变不太明显的参数,比如更改localRepository或添加存储库,但是它们被证明是无效的

这是我的错误消息,与我尝试修复它的行为交织在一起:

C:\development\my-main\customer-webpart>mvn install -Dmaven.test.skip=true

这是我的域名。这包括这个项目的主要pom,虽然它仍然是更大系统的一部分,而不是根。我想构建,安装和运行这个项目,以测试我的框架。我的框架作为pom.xml中的依赖项添加。

[INFO] Scanning for projects...
Downloading: http://my-server:8080/archiva/repository/my-repository//
org/myportal/client-product/0.0/client-product-0.0.pom

我不知道这个archiva存储库的定义位置。它不在pom.xml或settings.xml中。它似乎与double /有一个错误,但无论如何都不应该从这里检索client-product-0.0.pom。它位于 C:/mavenLocalRepository/my-main/client-product/0.0/client-product-0.0.pom

Downloading: http://repo1.maven.org/maven2/org/myportal/
client-product/0.0/client-product-0.0.pom

这也是寻找.pom文件的错误位置......所以产生了错误的其余部分:

[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: null:customer-webpart:zip:${org.myportal.version}

Reason: Cannot find parent: org.myportal:client-product for project: null:customer-webpart:zip:${org.myportal.version} for project null:customer-webpart:zip:${org.myportal.version}


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find parent: org.myportal:client-product for project: null:customer-webpart:zip:${org.myportal.version} for project null:customer-webpart:zip:${org.myportal.version}

        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:378)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:292)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        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: Cannot find parent: org.myportal:client-product for
project: null:customer-webpart:zip:${org.myportal.version} for project null:customer-webpart:zip:${org.myportal.version}
        at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1370)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:821)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.ja
va:506)
        at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:198)
        at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:583)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:461)
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:365)
        ... 11 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.myportal:client-product' not found in repository: Unable to download the artifact from any repository

  org.myportal:client-product:pom:0.0

from the specified remote repositories:
  my-repository (http://my-server:8080/archiva/repository/my-repository/),
  localRepository2 (C:/mavenLocalRepository/logging-framework/),
  localRepository (C:/mavenLocalRepository/my-main/),
  central (http://repo1.maven.org/maven2)
 for project org.myportal:client-product
        at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:6
03)
        at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1366)
        ... 17 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository

  org.myportal:client-product:pom:0.0

from the specified remote repositories:
  my-repository (http://my-server:8080/archiva/repository/my-repository/),
  localRepository2 (C:/mavenLocalRepository/logging-framework/),
  localRepository (C:/mavenLocalRepository/my-main/),
  central (http://repo1.maven.org/maven2)

        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:212)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:74)
        at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:5
56)
        ... 18 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
        at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:331)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:200)
        ... 20 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Oct 28 11:15:40 CET 2014
[INFO] Final Memory: 4M/61M
[INFO] ------------------------------------------------------------------------

C:\development\my-main\customer-webpart>

此外,此Eclipse警告在我的项目的pom.xml的父标记上给出:

Project build error: Non-resolvable parent POM: Failure to transfer org.myportal:client-product:pom:0.0 from http://my-server:8080/archiva/repository/my-repository/ was cached in the local repository, resolution will not be reattempted until the update 
 interval of my-repository has elapsed or updates are forced. Original error: Could not transfer artifact org.myportal:client-product:pom:0.0 from/to my-repository (http://my-server:8080/archiva/repository/my-repository/): Failed to transfer http://my-server:8080/archiva/repository/my-repository/org/myportal/client-product/0.0/client-product-0.0.pom. Error code 307, Temporarily Moved for Domain Name Expansion and 'parent.relativePath' points at wrong local POM

...我尝试了三种不同的parent.relativePath方法。 1.根本没有(没有标签),2。空标签(在这里的另一篇文章中建议)3。标记.pom文件的完整路径。

的pom.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.myportal</groupId>
        <artifactId>client-product</artifactId>
        <version>0.0</version>
        <relativePath>C:\mavenLocalRepository\my-main\org\myportal\client-product\0.0\client-product-0.0.pom</relativePath>
    </parent>
    <artifactId>my-webpart</artifactId>
    <version>${org.myportal.version}</version>
    <name>my-webpart</name>
    <packaging>zip</packaging>
    <description>
        customer webpart
    </description>
    <properties>
        <maven.test.skip>true</maven.test.skip>
        <org.logging.framework.version>0.0.1-SNAPSHOT</org.logging.framework.version>
    </properties>

    <build>
        <sourceDirectory>src/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/java</directory>
            </resource>
        </resources>
        <testSourceDirectory>src/test</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.maven.plugins</groupId>
                <artifactId>unzip-plugin</artifactId>
                <version>${org.unzip.plugin.version}</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <goals>
                            <goal>unzip</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <resources>
                                <resource>
                                    <groupId>org.workflow</groupId>
                                    <artifactId>workflow-framework</artifactId>
                                    <version>${org.myportal.version}</version>
                                    <type>jar</type>
                                    <includes>
                                        <include>*.pdpart</include>
                                    </includes>
                                    <target>src/java/generated/common-pdparts</target>
                                </resource>
                                <resource>
                                    <groupId>org.myportal</groupId>
                                    <artifactId>myportal-portletframework</artifactId>
                                    <version>${org.myportal.version}</version>
                                    <type>jar</type>
                                    <includes>
                                        <include>*.pdpart</include>
                                    </includes>
                                    <target>src/java/generated/common-pdparts</target>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.maven.plugins</groupId>
                <artifactId>descriptorloader-plugin</artifactId>
                <version>${org.descriptorloader.plugin.version2}</version>
                <executions> 
                    <execution>
                        <id>vdoclet-java-clean</id>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <source>src/java</source>
                            <target>src/java</target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>vdoclet-java</id>
                        <goals>
                            <goal>vdoclet</goal>
                        </goals>
                        <configuration>
                            <source>src/java</source>
                            <target>src/java</target>
                            <template>portletdescriptor/Control.vm</template>
                            <report>target/java-conversion.txt</report>
                        </configuration>
                    </execution>
                    <execution>
                        <id>vdoclet-jsp-clean</id>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <source>src/java</source>
                            <target>src/webapp</target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>vdoclet-jsp</id>
                        <goals>
                            <goal>vdoclet</goal>
                        </goals>
                        <configuration>
                            <source>src/java</source>
                            <target>src/webapp</target>
                            <template>portletdescriptor/JspControl.vm</template>
                            <report>target/jsp-conversion.txt</report>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.main</groupId>
                        <artifactId>main-build-dependencies</artifactId>
                        <version>${org.main.version}</version>
                        <type>pom</type>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.maven.plugins</groupId>
                <artifactId>zip-plugin</artifactId>
                <version>${org.zip.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <fileSets>
                        <fileSet>
                            <directory>src/webapp</directory>
                        </fileSet>
                        <fileSet>
                            <directory>target/classes</directory>
                            <outputDirectory>WEB-INF/classes/</outputDirectory>
                        </fileSet>
                    </fileSets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <!-- Clean generated diretory -->
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/java</directory>
                            <includes>
                                <include>**/generated/**</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

        </plugins>

    </build>

    <dependencies>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>my-client</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>my-portletdomain</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>effect-client</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>

        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>mycase-client</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>mycase-portletdomain</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <!-- myportal -->
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>mysecondportal-common</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>mysecondportal-webpartcommon</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>host-types</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.workflow</groupId>
            <artifactId>workflow-framework</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>${library.commons.fileupload.version}</version>
        </dependency>
        <!-- external -->
        <dependency>
            <groupId>faceless</groupId>
            <artifactId>bfopdf</artifactId>
            <version>0.0</version>
        </dependency>
        <!-- main -->
        <dependency>
            <groupId>org.main</groupId>
                <artifactId>main-assemble-ear</artifactId>
        <type>pom</type>
            <version>${org.main.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>my-webdelegate</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myportal</groupId>
            <artifactId>myportal-portletframework</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>       
        <dependency>
            <groupId>org.myshare</groupId>
            <artifactId>myshare-common</artifactId>
            <version>${org.myshare.version}</version>
        </dependency>
        <dependency>
            <groupId>org.myshare</groupId>
            <artifactId>myshare-webpartcommon</artifactId>
            <version>${org.myshare.version}</version>
        </dependency>
        <dependency>
            <groupId>org.docflow</groupId>
            <artifactId>docflow-client</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.docflow</groupId>
            <artifactId>docflow-webdao</artifactId>
            <version>${org.myportal.version}</version>
        </dependency>
        <dependency>
            <groupId>org.esb.logging</groupId>
            <artifactId>logging-framework</artifactId>
            <version>${org.logging.framework.version}</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>localRepository</id>
            <url>C:/mavenLocalRepository/my-main/</url>
        </repository>
        <repository>
            <id>localRepository2</id>
            <url>C:/mavenLocalRepository/logging-framework/</url>
        </repository>
    </repositories>
</project>

parent(client-product-0.0.pom):

<?xml version="1.0" encoding="ISO-8859-1"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.product</groupId>
    <artifactId>my-version-pom</artifactId>
    <version>0.0</version>
    <relativePath>..</relativePath>
  </parent>
  <groupId>org.product</groupId>
  <artifactId>my-product</artifactId>
  <packaging>pom</packaging>
  <version>0.0</version>
  <name>my-product  ${project.version} (old root-pom, now child of ${parent.artifactId})</name>

  <modules>
    <module>my-foundation-pom</module>
    <module>pb-product-pom</module>    
  </modules>
  <properties> 
    <!-- NISX: These properties should never be changed. Only change the value of org.component.version. -->
    <org.assemble.my.version>${org.component.version.with.build.number}</org.assemble.my.version>
    <org.myportal.version>${org.component.version}</org.myportal.version>
    <org.myshare.version>${org.component.version}</org.myshare.version>
   ... + several others. shortened for stackoverflow
  </properties>


  <build>
  <plugins>
      <plugin>
      <!-- NISX: This is a trick to avoid the ghost pom to be ever deployed to a repository. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.4</version>
        <inherited>false</inherited>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
                <plugin>
                <groupId>org.maven.plugins</groupId>
                <artifactId>qdev-maven-plugin</artifactId>
                <version>${org.qdev.plugin.version}</version>
                <inherited>true</inherited>
                <configuration>
                    <beaDeployDirectory>${qdev.deploy.dir}</beaDeployDirectory>
                    <earName>${qdev.ear.name}</earName>
                    <warName>${qdev.war.name}</warName> 
                    <isSingleWar>true</isSingleWar>
                </configuration>
            </plugin>
            <plugin>
                    <groupId>org.maven.plugins</groupId>
                    <artifactId>maven-udv-plugin</artifactId>
                    <version>1.1.2</version>
                    <configuration>
                        <settingsApplicationName>my</settingsApplicationName>
                        <settingsApplicationVersion>${my.branch.name}</settingsApplicationVersion>
                        <settingsApplicationState>${profile.state}</settingsApplicationState>
                    </configuration>
            </plugin>
    </plugins>
  </build>
</project>

0 个答案:

没有答案
相关问题