0

I am working on the project with the project structure as

root lib xyz.jar modules module1 module2 Now I want to include the xyz.jar in the module1 but owing to the multimodule structure of the project, I am not able to add the jar directly through maven.

I tried using

<plugin>
                <groupId>org.commonjava.maven.plugins</groupId>
                <artifactId>directory-maven-plugin</artifactId>
                <version>0.1</version>
                <executions>
                    <execution>
                        <id>directories</id>
                        <goals>
                            <goal>highest-basedir</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <property>multi.module.project.root.dir</property>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

and then using

<dependency>
            <groupId>org.abc.com</groupId>
            <artifactId>xyz</artifactId>
            <version>0.1.0</version>
            <scope>system</scope>
            <systemPath>${multi.module.project.root.dir}/lib/xyz.jar</systemPath>
        </dependency>

but throws error to specify absolute path of jar. next I tried using the de

pendency management in parent pom  by specifying 
<dependency>
                <groupId>org.abc.com</groupId>
                <artifactId>xyz</artifactId>
                <version>0.1.0</version>
                <scope>system</scope>
                <systemPath>${pom.basedir}/lib/xyz.jar</systemPath>
            </dependency>

This resolves the dependency but I am not able to use the dependency in the child pom of module1

How can I solve this

Vishal
  • 1,442
  • 3
  • 29
  • 48
  • Am I correct to understand that the `xyz` dependency is not a dependency published in a Maven repository nor installed in your local maven repository? It is only available as a jar that you store directly in the `lib` directory of your project? – Victor Noël Feb 18 '18 at 15:45
  • @VictorNoël yes its not available in maven repo – Vishal Feb 18 '18 at 15:47
  • 1
    Install that lib separately into your local repo (better start using a repository manager) and use it as dependency. Don't use system scope dependencies cause they are deprecated...Where is this xyz.jar coming from ? From another Maven build ? – khmarbaise Feb 18 '18 at 16:31

1 Answers1

0

The documentation of the directory-maven-plugin you are using explicitly says about the variables produced by the plugin:

They will be useful ONLY IN PLUGIN CONFIGURATIONS, NOT DURING POM INTERPOLATION.

This means you cannot use it like what you are doing.

As an alternative, I would consider referring to this SO answer.

Victor Noël
  • 842
  • 8
  • 14