maven not able to download jacoco 0.7.10-SNAPSHOT

2019-08-06 18:14发布

问题:

I am puzzled by this. I have this in my pom.xml

<build>
    <pluginManagement>
        ... other plugins ...
        <plugin>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
           <version>0.7.10-SNAPSHOT</version>
        </plugin>
    </pluginManagement>
</build>

And this my repository section

<repositories>
    <repository>
        <id>oss-sonatype</id>
        <name>oss-sonatype</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <snapshots>
            <updatePolicy>daily</updatePolicy>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    ..... other repositories ....        
</repositories>

As far as i can find out the jacoco-0.7.10-SNAPSHOT is present at https://oss.sonatype.org/content/repositories/snapshots/org/jacoco/jacoco-maven-plugin/0.7.10-SNAPSHOT/

My understanding is that it should be downloaded and build should succeed but i get the following error

[ERROR] Plugin org.jacoco:jacoco-maven-plugin:0.7.10-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.jacoco:jacoco-maven-plugin:jar:0.7.10-SNAPSHOT -> [Help 1]

I saw solution where people suggested to add the repository in ~/.m2/settings.xml file. I want to know can i do this without changing the .m2/settings.xml and why is the current setup not working. Any tips are greatly appreciated.

P.S. Please pardon me if this is already answered somewhere. I haven't been able to find a solution yet.

回答1:

Maven distincs between normal repositories and plugin repositories. You have to define the plugin repositories with

<pluginRepositories>
   <pluginRepository>
      ...
   </pluginRepository>
</pluginRepositories>