How to use platform architecture in Maven to determine dependency?
What is the problem with using profiles? They have been made exactly for such a situation. You can specify the profile action by OS/platform and add the dependency. Completely transparent.
The other way would be to move your core lib to a separate module and have a module for each platform.
I don't know of any way to do this without profiles. This is the main use case for which profiles were added to maven. You can do it using the following:
<profiles>
<profile>
<activation>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
</os>
</activation>
...
</profile>
<profile>
<activation>
<os>
<family>Linux</family>
<arch>x64</arch>
</os>
</activation>
...
</profile>
<profile>
<activation>
<property>
<name>integration-test</name>
</property>
</activation>
...
</profile>
</profiles>
Then, when someone checks out a project and builds it on a Linux x64 machine, they will automatically get everything under the Linux x64 profile. If they also provided the property -Dintegration-test
on the command line, they would activate the integration-test profile as well. You can have any number of active profiles, which are combined to create the effective POM for the build. These profiles can be defined in a shared parent POM for all projects that you work on, so developers don't have to change their settings.xml files.
To get more info on the activation of profiles, check out: http://maven.apache.org/guides/introduction/introduction-to-profiles.html.