javamavenx86armrosetta-2

How do I tell maven to work with x86_64 packages?


I want to force maven to use x86_64 packages on my MacBook M1 and run my application through Rosetta 2.

I tried mvn clean install -Dos.detected.classifier=osx-x86_64 but maven seems to not care about it.

Is there a way to force maven to use packages with a certain architecture?


Solution

  • It seems that the -Dos.detected.classifier=osx-x86_64 parameter is ignored or overloaded, but you can force it.

    In your /Users/yourname/.m2 directory, edit (or create) the settings.xml file to create a profile that sets the os.detected.classifier property and always enables the profile.

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <activeProfiles>
            <activeProfile>
                apple-silicon
            </activeProfile>
        </activeProfiles>
        <profiles>
            <profile>
                <id>apple-silicon</id>
                <properties>
                    <os.detected.classifier>osx-x86_64</os.detected.classifier>
                </properties>
            </profile>
        </profiles>
    </settings>
    

    Once it's done, just mvn clean install and it will download and use x86_64 packages.