1

一个中央 POM 定义了多个 JAR 模块,这些模块必须打包一个中央公共源文件夹的一部分。这是一个遗留项目,我想将源文件保存在一个地方。是否可以设置 MAVEN仅编译和打包此源文件夹的一部分?

SK

4

1 回答 1

0

你是对的,这是解决方案:

...
<build>
    <sourceDirectory>../src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>${version.build.helper.maven.plugin}</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>sk/maven/api/**/*.*</source>
                            <source>sk/ext/lib/**/*.*</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${version.maven.compile.plugin}</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <includes>
                    <include>sk/maven/api/**/*.*</include>
                    <include>sk/ext/lib/**/*.*</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <includes>
                    <include>sk/maven/api/**/*.*</include>
                </includes>
            </configuration>
        </plugin>
于 2013-10-29T17:07:52.267 回答