os-maven-plugin
os-maven-plugin copied to clipboard
Properties not replaced when using a BOM for `dependencyManagement`
I am using a BOM in my dependency management to get all my dependencies versions aligned.
Unfortunately, the property ${os.detected.classifier}
is not replaced in such case.
See the following pom.xml (I can't attach an XML file to the issue) for a reproducible test case:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kr.motd.test</groupId>
<artifactId>test-os-maven-plugin</artifactId>
<packaging>jar</packaging>
<version>0.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.77.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>${os.detected.classifier}</classifier>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.0</version>
</extension>
</extensions>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<fail unless="os.detected.name">os.detected.name is missing.</fail>
<fail unless="os.detected.arch">os.detected.arch is missing.</fail>
<fail unless="os.detected.classifier">os.detected.classifier is missing.</fail>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I get the following error:
$ mvn test
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for io.netty:netty-resolver-dns-native-macos:jar:${os.detected.classifier} is missing. @ line 27, column 21
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project kr.motd.test:test-os-maven-plugin:0.0.0-SNAPSHOT (/private/tmp/test-os-maven-plugin/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for io.netty:netty-resolver-dns-native-macos:jar:${os.detected.classifier} is missing. @ line 27, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
If I replace ${os.detected.classifier}
with osx-aarch_64
it works, so the artifact exists.
I am using Maven 3.8.6:
$ mvn --version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /opt/homebrew/Cellar/maven/3.8.6/libexec
Java version: 11.0.16, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@11/11.0.16/libexec/openjdk.jdk/Contents/Home
Default locale: en_FR, platform encoding: UTF-8
OS name: "mac os x", version: "12.5", arch: "aarch64", family: "mac"
I digged a bit, and it seems Maven reports this error long before calling the DetectExtension
, so that seems a bit complicated to handle this case. But my knowledge of Maven internals is quite light you'll tell me what is your findings on this.