I have a Maven repository set up to host some dlls, but I need my Maven projects to download different dlls depending on whether the JVM in use is x86 or x64.
So for example, on a computer running an x86 version of the JVM I need ABC.dll to be downloaded from the repository as a dependency, but on another computer running an x64 version of the JVM, I need it download XYZ.dll instead.
How would I go about doing this? An example pom.xml file would be nice.
Dependency mediation - this determines what version of an artifact will be chosen when multiple versions are encountered as dependencies. Maven picks the "nearest definition". That is, it uses the version of the closest dependency to your project in the tree of dependencies.
Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.
org.apache.maven.plugins:maven-dependency-plugin:3.3.0:resolve. Description: Goal that resolves the project dependencies from the repository. When using this goal while running on Java 9 the module names will be visible as well.
This will work on any VM. You can use profiles to have alternate configurations according to the environment.
A profile contains an activation block, which describes when to make the profile active, followed by the usual pom elements, such as dependencies:
<profiles>
<profile>
<activation>
<os>
<arch>x86</arch>
</os>
</activation>
<dependencies>
<dependency>
<!-- your 32-bit dependencies here -->
</dependency>
</dependencies>
</profile>
<profile>
<activation>
<os>
<arch>x64</arch>
</os>
</activation>
<dependencies>
<!-- your 64-bit dependencies here -->
</dependencies>
</profile>
</profiles>
As you mentioned DLLs, I'm assuming this is Windows-only, so you may also want to add <family>Windows</family>
under the <os>
tags.
EDIT: When mixing 32-bit VM on a 64-bit OS, you can see what value the VM is giving to the os.arch
system property by running the maven goal
mvn help:evaluate
And then entering
${os.arch}
Alternatively, the goal help:system
lists all system properties (in no particular order.)
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