Scientist
Scientist

Reputation: 1464

maven build issue for parent child modules

I have a maven parent pom as :

    <?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>spark_argo_test</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>src/modules/spark_stage1</module>
        <module>src/modules/spark_stage2</module>
    </modules>
    <properties>

The child module is as :

 <?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>spark_argo_test</artifactId>
        <groupId>groupId</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>spark_stage1</artifactId>
    <packaging>jar</packaging>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

when i build this i get following error as :

     mvn clean package -DskipTests=clear
[INFO] Scanning for projects...
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]   
[ERROR]   The project groupId:spark_stage1:1.0-SNAPSHOT (/home/srivastu/projects/spark_argo_test/src/modules/spark_stage1/pom.xml) has 1 error
[ERROR]     Invalid packaging for parent POM groupId:spark_argo_test:1.0-SNAPSHOT, must be "pom" but is "jar" @ groupId:spark_argo_test:1.0-SNAPSHOT
[ERROR]   
[ERROR]   The project groupId:spark_stage2:1.0-SNAPSHOT (/home/srivastu/projects/spark_argo_test/src/modules/spark_stage2/pom.xml) has 1 error
[ERROR]     Invalid packaging for parent POM groupId:spark_argo_test:1.0-SNAPSHOT, must be "pom" but is "jar"
[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

Please suggest further

Upvotes: 0

Views: 672

Answers (1)

swapyonubuntu
swapyonubuntu

Reputation: 2110

Kindly check the relative path in your child poms

<relativePath>pom.xml</relativePath>

I think you are referencing to this pom only. Maybe you, meant it to be

 <relativePath>../pom.xml</relativePath>

Upvotes: 1

Related Questions