How to automatically collect all related class into one jar (use maven)?

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 :


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



the pom.xml in the packageA directory is like

        </plugin>                               <!--it doesn't work-->
    <sourceDirectory>.</sourceDirectory>        <!--it works-->

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.


Finally I write a program myself to solve this problem

Need Your Help

Ruby Homebrew Support

ruby macos rvm homebrew

My brew doctor command is getting this warning: