Varun
Varun

Reputation: 4452

Why my maven project does not pick-up the jar from nexus

I am on Redhat, using jenkins with Nexus Repository Manager OSS 2.12.0-01.

What I am trying to achieve is to download all the jar from nexus. What, I have accomplished. Successfully installed nexus 2.12.0-01

This is the content of my maven setting.xml

<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">
 

    <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>
    </profiles>

    <activeProfiles>
    <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings> 

Successfully installed 3rd party jar for Ojdbc5 in nexus enter image description here

content of my parent pom

<project 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc</groupId>
  <artifactId>Test</artifactId>
  	<packaging>pom</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <modules>
    <module>Project1</module>
    <module>Project2</module>
 </modules>
 
 <distributionManagement>
    <snapshotRepository>
        <id>my-snapshots</id>
        <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>

    <repository>
        <id>my-releases</id>
        <url>http://localhost:8081/nexus/content/repositories/releases</url>
    </repository>

</distributionManagement>
</project>

In the above pom.xml there are two projects define. When I build using jenkins, The first project get successfully build. but the second one throws error.

Failed to execute goal on project project2: Could not resolve dependencies for project com.abc:project2:war:0.0.1-SNAPSHOT: Failure to find com.oracle:ojdbc5:jar:11.2.0.1 in http://localhost:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]

Please see the project2 pom.xml

<project 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc</groupId>
  <artifactId>project2</artifactId>
    <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Maven Webapp</name>
  <url>http://localhost:8081/nexus/content/repositories/releases</url>

 <distributionManagement>
  <repository>
    <id>thirdparty</id>
    <url>http://localhost:8081/nexus/content/repositories/thirdparty</url>
  </repository>
</distributionManagement>

  <dependencies>
        <!-- Spring ORM support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.2.13.RELEASE</version>
        </dependency>

        <!-- Spring Batch -->
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-core</artifactId>
            <version>3.0.1.RELEASE</version>
        </dependency>

        <!-- ojdbc 5 dependency provide by nexus-->

        <dependency>
         <groupId>com.oracle</groupId>
         <artifactId>ojdbc5</artifactId>
         <version>11.2.0.1</version>
        </dependency>
    <!-- That is creating problem -->

Please do not worry about the above pom.xml I have removed lot of dependency from pom to reduce the size of question. The pom structure is Ok.

Now coming to question. Have I missed any configuration, Why I am getting

Failed to execute goal on project gsdataprocessor: Could not resolve dependencies for project com.globalss.batch:gsdataprocessor:war:0.0.1-SNAPSHOT: Failure to find com.oracle:ojdbc5:jar:11.2.0.1 in http://localhost:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]

This error. Please help

Update 1: As suggest by user sanigo I have added Thirdpary repository the Public Repository Group

Update 2: Below is the screen-short which shows oracle ojdbc5 is available is public repository. enter image description here enter image description here

Upvotes: 0

Views: 7455

Answers (1)

sanigo
sanigo

Reputation: 645

Your http://localhost:8081/nexus/content/groups/public (Public Repository Group) is mirror of "*", so you should add http://localhost:8081/nexus/content/repositories/thirdparty(Thirdparty repositoy) to the Public Repository Group, you can do this in the Public Repository Configuration tab. Then you can use mvn -U clean install.

Upvotes: 5

Related Questions