问题
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