子项目无法通过relativePath

时间:2019-04-16 16:18:15

标签: maven docker build dependencies gitlab-ci

我已经创建了一个项目父级,用于管理子项目中的依赖关系和版本,请参阅pom.xml

<groupId>myCompany</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

然后,我创建了一个从父级继承的子项目,请参阅pom.xml

<parent>
<groupId>myCompany</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>filrstChild</artifactId>
<name>filrst Child</name>

请注意,两个项目位于同一文件夹中

  • group:
    • 父母
    • firstChild

PS:

子项目在父项目之前就已经存在,因此体系结构不是从零开始的,这就是为什么我没有使用标准方法创建父项目和模块的原因

使用gitlab-ci,在构建父级后,我试图构建firstChild

因此,父级构建正确,但firstChild未构建

这是我关于firstChild的gitlab-ci

image: appinair/jdk11-maven

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

cache:
  paths:
    - target/

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
  artifacts:
      paths:
        - target/
        - .m2/repository/

这是我构建firstChild后得到的错误

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for myCompany:firstChild:[unknown-version]: Could not find artifact myCompany:parent:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 10
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project myCompany:firstChild:[unknown-version] (/builds/compiere-ws/firstChild/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for myCompany:firstChild:[unknown-version]: Could not find artifact myCompany:parent:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 10 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
ERROR: Job failed: exit code 1

那么,有什么主意吗?

PS:

请注意,firstChild可以在我的本地服务器或jenkins中正确构建,而不仅仅是使用gitlab-ci构建

0 个答案:

没有答案