Adding a dependency child module in a parent module causing side effects on existing child modules

56 Views Asked by At

In my parent pom I build 2 modules: Commons is a dependency of CoreUnit, but I want to build it seperately and exclude it from the CoreUnit

<modules>
    <module>Commons</module>
    <module>CoreUnit</module>
</modules>

CoreUnit pom:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <filters>
                        <filter>
                            <artifact>com.asi:Commons</artifact>
                            <excludes>
                                <exclude>**/*</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>

                <configuration>
                    <outputDirectory>${project.basedir}/../Build</outputDirectory>
                    <archive>
                        <manifest>
                            <mainClass>com.asi.coreunit.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

The trouble starts when adding the so called "excluded dependency" pom build node. Here is Commons pom:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.5.1</version>

                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>

                <configuration>
                    <outputDirectory>${project.basedir}/../Build</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

Then, the coreunit.jar is not excluding the commons anymore

0

There are 0 best solutions below