Hello! Within one project, there are two applications (modules) that use one common module. I translate the whole thing to maven and ran into a problem, how can I describe it all there?

Annex 1

Appendix 2

common - the common module they use enter image description here

The project is not fully assembled, but each application is assembled separately, which uses the common common module during assembly. Tell me how to describe this matter to the collector? Thank you in advance.

    3 answers 3

    Can the common module simply indicate how dependecy? Maven will find it in the local repository.

    Common project:

    <?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>ru.net.arh</groupId> <artifactId>common</artifactId> <version>1.0-SNAPSHOT</version> </project> 

    maven-> install

    project1:

     <?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>ru.net.arh</groupId> <artifactId>project1</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>ru.net.arh</groupId> <artifactId>common</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project> 

    Similarly with project2

    • Could you give an example? - bench_doos

    need to do a common module or a common parent in maven

    • those. is it necessary for each of the applications to specify parent - common? And then how to build applications? Applications should be built from parent, no? - bench_doos

    A generic module must be described using a simple POM. Never a group, etc. As if he is on his own. This is the 1st pom.xml.

    Next, create the 2nd pom.xml, do a group project, for starters, for application 1, and specify your common module (1st pom.xml) in the modules section:

     <modules> <module>./path/to/shared/project/pom.xml</module> </modules> 

    Next, describe application 1 as a module for a group project, in the usual way with reference to the parent group project in the parent section. This is our 3rd pom.xml.

    After that, you can add a dependency to your “common” module (1st pom.xml) in the 3rd pom.xml using the usual dependency tag.

    Similarly for your application 2, make the 4th (group) and 5th (module) pom.xml.

    The technique is rarely used, because there is little where described, and if you believe some of the popular maven manual, even impossible.