4

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?

Igor Romanov
  • 1,689
  • 2
  • 19
  • 36

2 Answers2

2

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.

sblundy
  • 60,628
  • 22
  • 121
  • 123
2

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>
Balázs Németh
  • 6,222
  • 9
  • 45
  • 60
  • This is how I would have done it, but remember what the other guy said: "it will only unpack the version in your local repository, not the one you just packaged" – Sean Patrick Floyd Jul 13 '11 at 08:28
  • @Sean Patrick Floyd yes, but if I do a full rebuild, in a parent maybe with mvn install, MYPACKAGE gets built and copied to the local repo first, and then comes the build this project. or do you say that the build of the second project precedes MYPACKAGE's upload to the repo? – Balázs Németh Jul 13 '11 at 11:10
  • You sir are my hero. Thanks for taking the time to post your solution. – Uncle Iroh Apr 07 '15 at 23:34