I have a class ClassA in package packageA and ClassA import ClassB in packageB.(in fact ClassA import a lot of java file)
Then the directory is :
root
pom.xml
src
packageA
classA
pom.xml
packageB
classB
My goal is to generate a jar include classA and classB by only telling maven that I input classA.
the pom.xml in the root directory is like
<groupId>org.abc</groupId>
<artifactId>all-code</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>\src\packageA</module>
</modules>
<name>helloworld</name>
<dependencies>
<dependency>
</dependency>
</dependencies>
the pom.xml in the packageA directory is like
<parent>
<relativePath>..\..\</relativePath>
<artifactId>all-code</artifactId>
<groupId>org.abc</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>client-code</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>client</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<includes>
<include>packageB\*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin> <!--it doesn't work-->
</plugins>
<sourceDirectory>.</sourceDirectory> <!--it works-->
</build>
And the error message is package does not exist
I read the question here and try it. Building a fat jar using maven And I think the link question is to achieve that the asker want to include external jars into one jar . But I want to include my own classB into one jar ,while I only input classA to maven ,and let maven find classB because classA import classB.