0

I'm trying to create,parent pom which will hold all the child spring boot modules, But when i build parent pom, I'm getting the below error.

[ERROR] The project com.some.special:special-parent:0.0.1 (C:\Users\location\git\special-parent-pom\pom.xml) has 1 error [ERROR] Child module C:\Users\location\git\special-parent-pom..\special-security of C:\Users\location\git\special-parent-pom\pom.xml does not exist.

Below is my project structure:

--special-parent-pom

--special-security

both parent and child in same folder(C:\Users\location\git)

below is the parent pom.xml:

<modelVersion>4.0.0</modelVersion>

    <groupId>com.some.special</groupId>
    <artifactId>special-parent</artifactId>
    <version>0.0.1</version>
    <packaging>pom</packaging>

    <name>special-parent</name>
    <description>special-parent</description>
    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.2.RELEASE</version>
    </parent>


        <modules>
            <module>../special-security</module>
         </modules>

Below is the child pom.xml:

<modelVersion>4.0.0</modelVersion>
    <artifactId>special-security</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>com.some.special</groupId>
        <artifactId>special-parent</artifactId>
        <version>0.0.1</version>
        <relativePath>../special-parent/pom.xml</relativePath>
    </parent>

I'm unable to identify where the mistake is, can someone help me on this or share any example.My final goal is when i build the parent pom, it should build all the child modules with jar, basically spring boot child modules.

Rishi
  • 51
  • 2
  • 10
  • I think the issue is possibly with the paths in your `pom.xml`'s (e.g. `...` in the parent `pom.xml` / `relativePath` in the child `pom.xml`). I may be mistaken, is somewhat unclear with a directory listing. – masseyb Jan 30 '19 at 21:37

1 Answers1

2

This is a minimal example to compile your artifact and repackage it using the spring-boot-maven-plugin. Given the below directory listing:

Project
├── pom.xml
└── special-security
    ├── pom.xml
    └── src
        └── main
            ├── java
            │   └── com
            │       └── some
            │           └── special
            │               └── SpecialSecurity.java
            └── resources
                └── META-INF
                    └── MANIFEST.MF

Parent pom.xml contents:

Project
├── pom.xml
└── ...
<?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>com.some.special</groupId>
    <artifactId>special-parent</artifactId>
    <version>${revision}</version>
    <name>special-parent</name>
    <packaging>pom</packaging>

    <properties>
        <revision>0.0.1</revision>
    </properties>

    <modules>
        <module>special-security</module>
    </modules>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Child pom.xml contents:

Project
├── ...
└── special-security
    ├── pom.xml
    ...
<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>

    <artifactId>special-security</artifactId>
    <packaging>jar</packaging>
    <name>special-security</name>

    <parent>
        <groupId>com.some.special</groupId>
        <artifactId>special-parent</artifactId>
        <version>${revision}</version>
    </parent>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.2.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <finalName>special-security</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

You can package the artifact using: mvn package or install it into your local .m2 repository using: mvn install.

Note: use of the revision property requires at least maven 3.5.0-beta-1 refer to: https://maven.apache.org/maven-ci-friendly.html. Versions of the plugins used in this example are the latest available on https://mvnrepository.com/ at the time of this writing. Source code ./special-security/src/main/java/com/some/special/SpecialSecurity.java used for the example:

package com.some.special;

public class SpecialSecurity {

    public static void main(String[] args) {
        System.out.print("Hello World\n");
    }
}
masseyb
  • 3,745
  • 1
  • 17
  • 29
  • @Rishi for sure :) hope it helps. Don’t hesitate to accept as the answer to your question if you believe it could help others. – masseyb Feb 15 '19 at 20:48