Maven property not being evaluated as expected (os-maven-plugin)

3.4k Views Asked by At

I have a parent project with modules. One of the modules declares the following in its pom file:

...
<build>
    <extensions>
        <extension>
            <groupId>kr.motd.maven</groupId>
            <artifactId>os-maven-plugin</artifactId>
            <version>1.2.3.Final</version>
        </extension>
    </extensions>
</build>
...
<dependencies>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative</artifactId>
        <version>${netty.tcnative.version}</version>
        <classifier>${os.detected.classifier}</classifier>
    </dependency>
</dependencies>    
...

This project will build successfully when mvn package is run from the parent project. I then want to use this submodule project as a dependency in some other gradle project so I install the parent project to my maven local repo and declare the dependency in my build.gradle file.

When building the gradle project I run into this error:

Could not resolve all dependencies for configuration ':runtime'.
> Could not find netty-tcnative-${os.detected.classifier}.jar (io.netty:netty-tcnative:1.1.33.Fork2).
    Searched in the following locations: https://repo.grails.org/grails/core/io/netty/netty-tcnative/1.1.33.Fork2/netty-tcnative-1.1.33.Fork2-${os.detected.classifier}.jar

Why is ${os.detected.classifier} not being evaluated? It should be noted that ${netty.tcnative.version} is being evaluated as a property defined in the parent pom as it appears in the jar path that is being sought after.

Thank you.

edit: I think the issue may be because gradle is referencing the dependency and maven isn't being invoked to exercise the os-maven-plugin, which evaluates the expression. Just a guess.

1

There are 1 best solutions below

0
On

I have seen problems with correctly resolving os.detected.classifier when my POM includes a parent POM that also defines os-maven-plugin to be an extension.

You can try configuring it as a plugin https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides

<plugin>
  <groupId>kr.motd.maven</groupId>
  <artifactId>os-maven-plugin</artifactId>
  <version>1.6.1</version>
  <executions>
    <execution>
      <phase>initialize</phase>
      <goals>
        <goal>detect</goal>
      </goals>
    </execution>
  </executions>
</plugin>