2

I have a multi-module project with a structure that goes as:

-ParentModule
  -AggregateModule
    -pom.xml
    -ShadedModule
      -src
      -pom.xml
  -pom.xml

So in essence, I'm trying to create a shaded jar for ShadedModule which is a submodule/child of AggregateModule, which is a submodule/child of ParentModule.

When I go to build ShadedModule it completes without error. The issue I'm having however is when I look at the POM that is generated, none of the POM properties which ShadedModule relies on are resolved. The top of the aforementioned POM looks like

  <parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>aggregate-module</artifactId>
    <version>${parent-module.version}</version>
  </parent>

  <groupId>com.foo.bar</groupId>
  <artifactId>shaded-module</artifactId>
  <version>${shaded-module.version}</version>

But if I build ShadedModule without the shaded plugin, the properties are resolved fine and the generated POM looks as it should.

The plan is to use ShadedModule as a dependency for yet another project. But when trying to build this other project it fails with error:

Could not find artifact com.foo.bar:aggregate-module:pom:${parent-module.version}

Anyways I need to rely on ParentModule for dependency management and so on. Any insights on how to resolve this?

Simplified versions of the POMs look like:

ShadedModule

<parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>aggregate-module</artifactId>
    <version>${parent-module.version}</version>
</parent>
<groupId>com.foo.bar</groupId>
<artifactId>shaded-module</artifactId>
<version>${shaded-module.version}</version>
    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                      ...relocate packages and exclude some deps
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
.
.

AggregateModule

<parent>
    <groupId>com.foo.bar</groupId>
    <artifactId>parent-module</artifactId>
    <version>${parent-module.version}</version>
</parent>
<packaging>pom</packaging>
<artifactId>aggregate-module</artifactId>
<modules>
   <shaded-module>
   .
   .
</modules>

ParentModule

<artifactId>parent-module</artifactId>
<version>${parent-module.version}</version>
<packaging>pom</packaging>
<properties>
  <parent-module.version>2.0</parent-module.version>
  <shaded-module.version>2.2</shaded-module.version>
</properties>
<modules>
  <module>aggregate-module</module>
  .
</modules>
<dependencyManagement>
  .
  .

0 Answers0