Maven-Plugin can not download dependency from custom repository
Hello there!
Currently i am using version 1.12.8 of byte-buddy with java 17 and created a small validation-helper dependency for my java projects. Inside this library i created a custom ValidationPlugin and used the META-INF-way to configure it with byte-buddy-maven-plugin. The dependency is stored inside GitHub package registry (so i have to add a repository-section inside poms of projects using my dependency).
<plugin>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-maven-plugin</artifactId>
<version>${bytebuddy.version}</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>de.mclonips</groupId>
<artifactId>validation</artifactId>
<version>${validation.version}</version>
</dependency>
</dependencies>
</plugin>
Inside a test-maven-module inside my validation-module it seems to be working fine!
Now i want to use my validation-lib in my Project B and used the dependency as seen above.
But if i run maven clean package (and removed the dependency from my local repository to force it to download it again) i got the following error:
Execution default of goal net.bytebuddy:byte-buddy-maven-plugin:1.12.8:transform failed: Plugin net.bytebuddy:byte-buddy-maven-plugin:1.12.8 or one of its dependencies could not be resolved: Could not find artifact de.mclonips:validation:jar:1.2.1 in central (https://repo.maven.apache.org/maven2)
I configured the corresponding GitHub Package Registry repo in the repository-section of my pom. As i used the dependency in my normal dependency-management to use classes from it inside project B, maven is able to download it. But it seems that the plugin ignores the server-section of the pom and tries to find the plugin using maven-central. Do i miss something or is it a bug?
Hope you have an idea for my problem :-)
Greetings from Germany!
Did you specify the repository under pluginRepositories in the POM file? I do not think I resolve project repositories. This is how I understood the mechanism was supposed to work.
Or are you suggesting that you wanted to pick the plugin from your current build without publishing it to your local Maven? I am not sure how this is resolved normally. Could you create a sample project that reproduces this? I might be able to solve this then.
Oh that's interesting.
If i add my repository to the pluginRepositories section of my pom.xml the plugin is able to download my validation dependency.
I thought pluginRepositories is a legacy option for maven and a relict from the days where plugins and dependencies has to be stored in different repositories (like in maven 1.x and 2.x).
If i take a deeper look inside the maven-4.0.0.xsd ,pluginRepositories is described as
The lists of the remote repositories for discovering plugins for builds and reports.
The repository-section is described as
The lists of the remote repositories for discovering dependencies and extensions.
In my opinion you should have to use the normal repository-section of pom.xml to resolve plugins configured dependencies?
In any case thanks for your support, byte-buddy is a wonderful extension of the java world :-)
Edit: Forgot to answer second part, everything works fine and without any additional configuration if my needed validation-dependency is part of the build :-)
Thanks, I'll hear with the Maven crew what the idea was. It's a bit thin to really make a choice. I thought plugins were not to affect the artifact and should therefore be stored in a different namespace but it's not certain, of course.
From this description, I argue that pluginRepositories is the right place: https://lists.apache.org/thread/kqft9qonhzhsmq2f9ov2vt3krqv40t5k
Sorry, vacation-mode was ON :-)
Thanks for your search, i think pluginRepositories should be the right place!
But maybe i have an other problem. My validation-module is part of a multi-module maven project. One of the modules is a maven-java-parent for all of my personal projects using and configuring the byte-buddy plugin with my validation-module.
Both modules (validation and maven-parent) will be build during the same build cycle. Now i have a dependency-problem when compiling my modules. The maven-parent points on a version 1.0.0 of my validation-module which will be build first. But when compiling my maven-parent the plugin tries to download it from remote artifactory. It seems the plugin does not see that the requested module is part of the build.
Do you have any idea how to fix this issue?
Maybe the link to my personal project may help you: https://github.com/MCLonips/java-common/runs/6076984648?check_suite_focus=true#step:5:1295
Are you running mvn install? In this particular case you have to to make sure that your plugin is in the local repository. I do not think that plugins are resolved against the current build.