mardi 5 mai 2015

How to cache artifact from a public repository(e.g., Maven Central) to a private-owned nexus repository?

Basically, I am asking the same thing as the question linked here.

However, I don't think the picked answer solved the question. In addition, the former one was asked years ago.

The Nexus OSS version I installed is 2.11.2-06(the latest version).

I CAN cache an artifact if I search with the nexus GUI and click download button. the Nexus GUI

However, an artifact IS NOT cached if I declare it in the pom file in eclipse. It will just fetch it from MAVEN CENTRAL and cache it locally in my computer but not in the Nexus Repository.

I WISH when I declare a dependency in the POM file in eclipse, if it is not cached locally, maven will fetch it from MAVEN CENTRAL, cache it both locally in my computer AND in the Nexus Repository as well.

My maven settings.xml is shown below:

<settings xmlns="http://ift.tt/1hf6Yt2"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/1hf6Yt2 http://ift.tt/1j24fGg">
<profiles>
    <profile>
        <id>kingstar-internal</id>
        <repositories>
            <repository>
                <id>kingstar-internal-repository</id>
                <name>Kingstar Internal Repository</name>
                <url>http://localhost:8081/nexus/content/repositories/KingstarRepository</url>
            </repository>
            <repository>
                <id>kingstar-snapshot-repository</id>
                <name>Kingstar Snapshot Repository</name>
                <url>http://localhost:8081/nexus/content/repositories/KingstarSnapshotRepository</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

<mirrors>
<mirror>
  <id>public-mirror</id>
  <mirrorOf>*</mirrorOf>
  <name>public mirror</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>

<activeProfiles>
    <activeProfile>kingstar-internal</activeProfile>
</activeProfiles>

<servers>
    <server>
        <id>kingstar-internal-repository</id>
        <username>deployment</username>
        <password>deployment</password>
    </server>
    <server>
        <id>kingstar-snapshot-repository</id>
        <username>deployment</username>
        <password>deployment</password>
    </server>
</servers>
</settings>

Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire