maven-3

Maven message about artifacts being present locally but cached from remote repository


Suddenly, running Maven 3.9.5 in GitLab with a cached .m2 repository mounted locally in the project, I am getting this message:

[INFO] Artifact XXX is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from [central (https://repo.maven.apache.org/maven2, default, releases)]

The artifacts it is always checking are in one of the public repositories (central, jboss, etc.) and it is not even all of them - just a handful but enough to clutter the logs.

Nothing I seem to do resolves it. I've seen you might be able to delete the "remote repository" files in the .m2 folder but I would prefer not to manipulate that. I do not get this locally, only when running with the local .m2 mounted repository in a GitLab job.

Things I have tried:

Interestingly, if kick off another pipeline build right after where I got the message, I do not see that logged message so it does not even happen consistently.

An example of the settings.xml:

<settings>
    <!-- Servers -->
    <servers>
        <server>
            <id>companya</id>
            <username>companya-dev</username>
            <password>PASSWORD</password>
        </server>
        <server>
            <id>companya-projects</id>
            <username>companya-dep</username>
            <password>PASSWORD</password>
        </server>
        <server>
            <id>companya-releases</id>
            <username>companya-dep</username>
            <password>PASSWORD</password>
        </server>
        <server>
            <id>companya-snapshots</id>
            <username>companya-dev</username>
            <password>PASSWORD</password>
        </server>
        <server>
            <id>oss</id>
            <username>USERNAME</username>
            <password>PASSWORD</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>companya</id>
            <repositories>
                <repository>
                    <id>companya</id>
                    <url>https://companya.com/repository/maven-public</url>
                    <layout>default</layout>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </snapshots>
                </repository>
                <repository>
                    <id>companya-projects</id>
                    <url>https://companya.com/repository/maven-projects/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </snapshots>
                </repository>
                <repository>
                    <id>companya-releases</id>
                    <url>https://companya.com/repository/maven-releases/</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>companya-snapshots</id>
                    <url>https://companya.com/repository/maven-snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>daily</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
        <profile>
            <id>oss</id>
            <properties>
                <gpg.executable>gpg</gpg.executable>
                <gpg.passphrase>PASSWORD</gpg.passphrase>
            </properties>
        </profile>
    </profiles>
    <!-- Active Profile -->
    <activeProfiles>
        <activeProfile>companya</activeProfile>
    </activeProfiles>
    <!-- Plugin Groups -->
    <pluginGroups>
        <pluginGroup>org.sonatype.plugins</pluginGroup>
    </pluginGroups>
</settings>

Solution

  • For whatever reason this seems to resolve the issue (mostly, because I get 1 or 2 occasionally with the same warning?). I am not trying to mirror anything, just use Maven Central for dependencies that are public and our own repository for a handful of private dependencies. This is real specific to being run in GitLab with caching because it does not happen locally.

    I can somewhat replicate it locally as well but playing around with the repos in my own settings.xml and get the same warning.

    I added Maven Central 1st to my list of repositories and moving our own public last. In between are the release and snapshot repos:

    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>