Question

I want to include a parent in a project pom, containing distribution management and repositories. As one would expect.

When I mvn package the child, maven is unable to resolve the parent pom, unsurprisingly.

I can make it resolve the parent by adding my internal nexus repository to the child pom. But this sounds like eggs laying chickens - I'm telling the child something it should know from the parent. I would have to add this repo to every child pom that has a parent.

How can I avoid this?

Was it helpful?

Solution

As khmarbaise wrote, you need to define your repositories in a profile in your settings.xml (this seems somewhat weird, but is actually the only feasible way):

<profiles>
    <profile>
        <id>repos</id>

        <repositories>
            <repository>
                <id>my-local-repo</id>
                <name>Projektserver Snapshots</name>
                <url>http://my-server/nexus/content/groups/public</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                    <updatePolicy>daily</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>repos</activeProfile>
</activeProfiles>

Depending on your actual config, you would also include mirror setting and might call your local nexus central.

OTHER TIPS

Sounds like the parent has been deployed to your internal nexus repository so it picks it up from there once you add in the distribution management and repository details.

To make it pick it up from your local copy. First ensure the versions match. Then navigate to the parent and run mvn clean install. This will push the parent pom to your local maven repo.

You may also get round this by ensuring you have added the releativePath element to the parent details in the child pom, you may not need to manually build the parent then but im not 100% sure and havent tested that.

The only things which should defined in your pom is distributionManagement the repositories should be defined in settings.xml instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top