如何自动收集所有相关的类到一个罐子(使用Maven)? [英] How to automatically collect all related class into one jar (use maven)?
问题描述
我有一个类ClassA的封装程序包A和ClassA的进口ClassB的在packageB。(其实ClassA的大量进口的java文件)
I have a class ClassA in package packageA and ClassA import ClassB in packageB.(in fact ClassA import a lot of java file)
那么目录是:
root
pom.xml
src
packageA
classA
pom.xml
packageB
classB
我的目标是产生一个罐子包括ClassA和ClassB的只有行家告诉我输入CLASSA。
My goal is to generate a jar include classA and classB by only telling maven that I input classA.
在根目录下的pom.xml就像
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>
在程序包A目录中的pom.xml就像
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>
和错误消息是包不存在
我在这里阅读问题和尝试。
建筑使用maven 脂肪罐子
而且我认为该链接的问题是实现这一提问者要包括外部罐成一个罐子。但我想我自己的CLASSB包括成一个罐子,而我只输入CLASSA到Maven,并让行家找到CLASSB因为CLASSA进口ClassB的。
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
http://blog.csdn.net/guotong1988/article/details/50265463
这篇关于如何自动收集所有相关的类到一个罐子(使用Maven)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!