Can you help me understand why I cannot put my <pluginMangement>
config on my parent POM?
I have this <pluginMangement>
config. When it is in the parent POM, my build fails
because the <pluginArtifact>
incorrectly resolves to:
io.grpc:protoc-gen-grpc-java:1.23.0:exe:linux-x86_64
When it is in my POM, the <pluginArtifact>
correctly resolves to
io.grpc:protoc-gen-grpc-java:1.23.0:exe:osx-x86_64
In my local POM, I use this build extension:
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<pluginMangement>
config
(Note dynamic <pluginArtifact>
)
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- http://os72.github.io/protoc-jar-maven-plugin/run-mojo.html -->
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>${protoc-jar-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<addProtoSources>all</addProtoSources>
<includeMavenTypes>direct</includeMavenTypes>
<includeMavenTypes>transitive</includeMavenTypes>
<includeDirectories>
<include>src/main/proto</include>
</includeDirectories>
<inputDirectories>
<include>src/main/proto</include>
</inputDirectories>
<protocArtifact>
com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
</protocArtifact>
<outputTargets>
<outputTarget>
<type>java</type>
</outputTarget>
<outputTarget>
<type>grpc-java</type>
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
</pluginArtifact>
</outputTarget>
</outputTargets>
</configuration>
</execution>
</executions>
</plugin>
When the configuation is on the parent, the os.detected.classifier
shows correct at the start of the build:
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
...
[INFO] os.detected.classifier: osx-x86_64
But then the plugin shows to resolve to the incorrect artifact:
[INFO] --- protoc-jar-maven-plugin:3.8.0:run (generate-sources) @ recipe-order-processor ---
[INFO] Resolving artifact: com.google.protobuf:protoc:3.9.0:exe:linux-x86_64, platform: osx-x86_64
I suspect the issue is due to when inherited variables on managed plugins are bound, but I can't find any Apache Maven references to "binding order" regarding <pluginMangement>
on parent POMs.