Share classes within modules in maven project

筅森魡賤 提交于 2019-12-12 02:55:14

问题


firstly I'm new to maven , so sorry for the question if it's too simple :)

I have main module "main" and child modules : a , b , c , ...

What I want is to share some data which is in child module a , with child module b.

The parent pom looks like : 4.0.0

    <groupId>Parent</groupId>
    <artifactId>Parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>a</module>
        <module>b</module>
        <module>c</module>
    </modules>
</project>

The child I want to share looks like :

<parent>
    <artifactId>Parent</artifactId>
    <groupId>Parent</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>a</artifactId>
</project>

and "consumer" child looks like :

<parent>
        <artifactId>Parent</artifactId>
        <groupId>Parent</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>b</artifactId>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>a</artifactId>
            <version>${project.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>

I do see the jar file being added to the "External Library" (I'm using Intellij) But the jar contains only META-INF folder without the code (is it ok ?)

End of story, I cannot use Class ChildA in ChildB classes ... Any help whould be appriciated !!


回答1:


The problem was that I've "btoken" maven's project stracture .... Once I've build the module as it should be by maven , works like a charm :) http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html



来源:https://stackoverflow.com/questions/27406044/share-classes-within-modules-in-maven-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!