0

我有以下目录结构:

my_sources
    my_project
        src
            main
                java
                    a
                        A.java
                    b
                        B.java

我想打包

a.A.class

在 A.jar 和

b.B.class

在 B.jar 中单

mvn package

是否可以从同一源目录创建更多 JAR?

谢谢你,SK

4

1 回答 1

1

I'll explain two solutions for you.

You could consider making a multi-module maven project, with a structure like this:

my_project
pom.xml
    module_A
        pom.xml
        src
            main
                java
                    a
                        A.java
    module_B
        pom.xml
        src
            main
                java
                    b
                        B.java

And your "parent pom" (the one at the project root level) will contain this:

<modules>
    <module>module_A</module>
    <module>module_B</module>
</modules>

Then you can just run mvn clean install from the project root and look in module_A/target and module_B/target to find your jars which have been built.

The other solution involves using exclusions and the maven-jar-plugin (or another plugin that does the same job). Here's maven-jar-plugin example configuration, for a question similar to your own.

Hope this helps...

于 2013-10-22T09:54:34.890 回答