This maven plugin provides a wagon that is capable of downloading nuget artifacts. It is mainly intended to be used with the c# maven plugin, however it can be used without it. It provides a wagon capable of to download packages from nuget that are specified as dependencies. For this to work the plugin needs to activated with extensions:
<build>
<plugins>
<plugin>
<groupId>io.github.miracelwhipp.net.nuget.plugin</groupId>
<artifactId>nuget-maven-plugin</artifactId>
<version>${project.version}</version>
<extensions>true</extensions>
</plugin>
and nuget needs to be added to the projects repositories:
<repositories>
<repository>
<id>nuget</id>
<name>microsoft nuget repository</name>
<url>nuget://api.nuget.org/v3-flatcontainer/</url>
</repository>
</repositories>
Note that the url starts with nuget. This is mavens hint to activate the nuget-maven-plugins wagon to
contact api.nuget.org/v3-flatcontainer
. Now a dependency can be specified that references an artifact from nuget,
for example newtonsoft.json:
<dependencies>
<dependency>
<groupId>Newtonsoft.Json</groupId>
<artifactId>Newtonsoft.Json</artifactId>
<version>12.0.1</version>
<type>dll</type>
</dependency>
</dependencies>
Since maven artifacts have a groupId
and an artifactId
and nuget artifacts simply have an id, it is good practice
writing the same to groupId and artifactId, however only the groupId is
important - the artifactId gets ignored. As a result the dependency above will instruct the plugin to download
newtonsonft.json in version 12.0.1 from nuget to the local maven repository. In fact, it will do a little more: it
will download the complete nupkg-package and unpack the dll.