javamavennexusbroadleaf-commerce

Configure local nexus server to download artifacts from other remote nexus repository


I have installed Nexus repository locally and configuried maven to use my Nexus repo. I am trying to install broadleaf commerce but always getting the error. Broadleaf demo: https://github.com/BroadleafCommerce/DemoSite.

When I build the project with default maven settings file I can able to build the project. But with nexus local repo, I couldn't able to download the broadleaf artifacts. Can anyone help me what's wrong with my settings?

My settings.xml

<settings>
<mirrors>
<mirror>
  <!--This sends everything else to /public -->
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://localhost:8081/repository/maven-proxy-test/</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>
<repository>
      <id>broadleaf-repo</id>
      <url>http://nexus.broadleafcommerce.org/nexus/content/groups/public</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>
<pluginRepository>
      <id>broadleaf-repo</id>
      <url>http://nexus.broadleafcommerce.org/nexus/content/groups/public</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>

When I build the broadleaf project I am always getting the build error.

INFO] Reactor Summary:
[INFO] 
[INFO] Broadleaf Spring Boot Community Demo 1.0.0-SNAPSHOT  SUCCESS [  0.612 s]
[INFO] Community Demo Core ................................ FAILURE [  0.652 s]
[INFO] Community Demo Site ................................ SKIPPED
[INFO] Community Demo Admin ............................... SKIPPED
[INFO] Community Demo API 1.0.0-SNAPSHOT .................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.885 s
[INFO] Finished at: 2018-11-18T18:48:31+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project boot-community-demo-core: Could not resolve dependencies for project com.mycompany-community:boot-community-demo-core:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at org.broadleafcommerce:broadleaf-framework:jar:5.2.7-SNAPSHOT -> org.broadleafcommerce:broadleaf-common:jar:5.2.7-SNAPSHOT -> org.broadleafcommerce:broadleaf-common-presentation:jar:1.0.4-SNAPSHOT: Failed to read artifact descriptor for org.broadleafcommerce:broadleaf-common-presentation:jar:1.0.4-SNAPSHOT: Failure to find org.broadleafcommerce:broadleaf-module-parent:pom:1.0.13-GA in http://localhost:8081/repository/maven-proxy-test/ 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]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project boot-community-demo-core: Could not resolve dependencies for project com.mycompany-community:boot-community-demo-core:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at org.broadleafcommerce:broadleaf-framework:jar:5.2.7-SNAPSHOT -> org.broadleafcommerce:broadleaf-common:jar:5.2.7-SNAPSHOT -> org.broadleafcommerce:broadleaf-common-presentation:jar:1.0.4-SNAPSHOT

Solution

  • You have 2 options and depends on how you want to handle it.

    If your nexus should also hold the artifacts from broadleafcommerce you have to add it as a proxy repository:

    In Nexus create a Proxy Repository with ID broadleafcommerce, URL http://nexus.broadleafcommerce.org/nexus/content/groups/public and Version policy Mixed In your settings.xml define your mirrors:

    <mirrors>
        <mirror>
          <id>nexus</id>
          <mirrorOf>*,!broadleaf-repo</mirrorOf>
          <url>http://localhost:8081/repository/maven-proxy-test/</url>
        </mirror>
        <mirror>
          <id>broadleafcommerce</id>
          <mirrorOf>broadleaf-repo</mirrorOf>
          <url>http://nexus.broadleafcommerce.org/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>
    

    If you do not want to have the artifacts from broadleafcommerce in your nexus repository:

    Define your mirror in that way:

    <mirrors>
        <mirror>
          <id>nexus-group</id>
          <mirrorOf>*,!broadleaf-repo</mirrorOf>
          <url>http://localhost:8081/repository/maven-proxy-test/</url>
        </mirror>
    </mirrors>
    

    Notice that <mirrorOf>*,!broadleaf-repo</mirrorOf> points to the ID of your defined repository and excludes it.