I have the following POM entry
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>3.3.0</version>
</dependency>
When I build my project it downloads the following files:
If you visit the repository at http://download.java.net/maven/2/net/java/dev/jna/jna/3.3.0/ you can see there are numerous other files. Why isn't Maven downloading those other files?
If you open the jna-3.3.0.pom you see
<plugins>
<!-- fake out maven and install the binary artifact -->
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!--<ant dir="." target="dist" />-->
<attachArtifact file="dist/jna.jar" />
<attachArtifact file="dist/platform.jar" classifier="platform" type="jar" />
<attachArtifact file="dist/src-mvn.zip" classifier="sources" type="jar"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
I suspect the issue has something to do with the comment in the pom "fake out maven and install the binary artifact".
If you add a second dependency to your project alongside the existing JNA dependency, with a classifier added, you should get the artifact added to your build.
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>3.3.0</version>
<classifier>platform</classifier>
</dependency>
As you now have two artifacts from the same project, it would be sensible to extract the version
element into a project level property so that updating it updates both:
<properties>
<jna.version>3.3.0</jna.version>
</properties>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
<classifier>platform</classifier>
</dependency>
</dependencies>
I didn't really understand the classifier
usage in @steve_barham's answer.
I searched JNA's project in github and found a file called pom-jna-platform.xml
, which includes the following artifact details:
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
So I just used the following for downloading both jna and jna-platform jars:
<properties>
<jna.version>4.0.0</jna.version>
</properties>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>${jna.version}</version>
</dependency>
</dependencies>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With