Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus is not caching maven central plugins

Tags:

maven

nexus

Im using Maven 3.0.4 and Nexus 2.0.6. I have set up my settings.xml as the Nexus instruction show for using a single repository. I get the error below when maven tries to run maven -U clean.

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its d
ependencies could not be resolved: Failed to read artifact descriptor for org.ap
ache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not find artifact org.apa
che.maven.plugins:maven-clean-plugin:pom:2.4.1 in nexus (http://localhost:8081/n
exus/content/groups/public) -> [Help 1]

If I remove the nexus mirror from the settings and go directly to maven central the command works. The settings for the maven repo in nexus show that it is in service and it is in the public group (its listed last).

I am not behind a proxy to access the internet.

Here is my settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<offline>false</offline>
<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <id>nexus</id>
        <!--Enable snapshots for the built in central repo to direct -->
        <!--all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
    <profile>
        <id>maven-central</id>
        <!--Enable snapshots for the built in central repo to direct -->
        <!--all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>
     </profile>
</profiles>
    <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
</activeProfiles>


</settings>
like image 289
Doctor Grugon Avatar asked Jul 02 '12 23:07

Doctor Grugon


2 Answers

I had the same symptom as the OP (Nexus was not mirroring an artifact) and found that it was caused by a route definition.

For example, you have an artifact org.blabla:blabla-api:1.0 which is in Maven Central. However you have set up a route matching .*/org/blabla/.* that forces any matching requests to look only in the proxied repository blabla-public ... but unfortunately blabla-public doesn't contain that particular artifact.

Solution: either update the route to add Central to the list of repos used by the route, or delete the route.

(This probably wasn't the cause for the OP, but I'm posting it in case it helps any other visitors.)

like image 170
Andrew Spencer Avatar answered Oct 30 '22 09:10

Andrew Spencer


Make sure the Central proxy repository is properly configured, and the proxied URL is http://repo1.maven.org/maven2/. Check that you can see cached artifacts at the repository's URL, should be http://localhost:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-clean-plugin/2.4.0/maven-clean-plugin-2.4.1.pom.

Make sure you have a Central proxy at all, is there anything listed at http://localhost:8081/nexus/content/repositories/central/.

If you're behind a proxy, you can configure the proxy under the Default HTTP Proxy Settings (optional) section in the Administration->Nexus pane.

Then, make sure the Public Repositories group repository is configured to include the Central repository in its list of included repositories.

If everything looks fine so far, check the logs, maybe there's a helpful message in there.

like image 28
Sergiu Dumitriu Avatar answered Oct 30 '22 09:10

Sergiu Dumitriu