Maven in multimodule web project: how to put sibli

2019-05-04 16:05发布

I have a multi-module Maven project. By default when I build a web module, all sibling modules of type JAR it depends on are copied to WEB-INF/lib folder. I want output of sibling modules to be placed in WEB-INF/classes folder without packaging to JAR.

More general question may be: how to keep sibling modules' configuration files out of JARs so that they can be edited after deployment easily?

标签: maven-2 war
2条回答
叼着烟拽天下
2楼-- · 2019-05-04 16:22

You could use an overlay, although that requires that the sibling be of type war rather than jar. There's also using the dependency plugin to unpack the jar, but it will only unpack the version in your local repository, not the one you just packaged.

As for your 'more general' question, there's the excludes tag for the jar plugin.

查看更多
Melony?
3楼-- · 2019-05-04 16:42

In case if somebody is interested, I found this solution. I had exactly the same issue.

            <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <packagingExcludes>WEB-INF/lib/MYPACKAGE_TO_EXCLUDE.jar</packagingExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>unpack-MYPACKAGE_TO_EXCLUDE</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>${project.groupId}</groupId>
                                        <artifactId>MYPACKAGE_TO_EXCLUDE</artifactId>
                                        <version>${project.version}</version>
                                        <type>jar</type>
                                        <outputDirectory>${project.build.directory}/classes
                                </outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
查看更多
登录 后发表回答