问题
I'm suffering for a Could not find artifact org.apache.commons:commons-numbers-core:jar:1.0-SNAPSHOT Maven error on Travis CI which I can't explain because I ran the exact same build command locally after deleting ~/.m2/repository
and moving ~/.m2/settings.xml
to a backup location.
The error message is
[ERROR] Failed to execute goal org.codehaus.izpack:izpack-maven-plugin:5.1.1:izpack (default) on project document-scanner: Execution default of goal org.codehaus.izpack:izpack-maven-plugin:5.1.1:izpack failed:
Plugin org.codehaus.izpack:izpack-maven-plugin:5.1.1 or one of its dependencies could not be resolved:
The following artifacts could not be resolved:
org.apache.commons:commons-numbers-core:jar:1.0-SNAPSHOT,
org.apache.commons:commons-numbers-gamma:jar:1.0-SNAPSHOT,
org.apache.commons:commons-numbers-fraction:jar:1.0-SNAPSHOT,
org.apache.commons:commons-numbers-combinatorics:jar:1.0-SNAPSHOT,
org.apache.commons:commons-numbers-arrays:jar:1.0-SNAPSHOT,
org.apache.commons:commons-numbers-angle:jar:1.0-SNAPSHOT,
org.apache.commons:commons-rng-sampling:jar:1.1-SNAPSHOT:
Could not find artifact org.apache.commons:commons-numbers-core:jar:1.0-SNAPSHOT`
which makes me think that the SNAPSHOT version is required by izpack-maven-plugin
so that I can't avoid it.
Afaik the repositories ought to be picked up based on repository
elements in pom.xml
s which are equal on the local and Travis CI's side. The issue occurs for > 12h, now and 100% of the time (restarted the Travis CI build 3 times), so that a caching issue is unlikely.
I'm using Maven 3.1.1 which is enforced by one dependency which I modified and which I'm building in an aggregator project.
回答1:
Adding
<repositories>
<repository>
<id>apache-snapshots-group</id>
<name>Apache snapshots group repository</name>
<url>https://repository.apache.org/content/groups/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<!-- fix missing `commons-numbers-core:1.0-SNAPSHOT` on Travis CI
-->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache-snapshots-group</id>
<name>Apache snapshots group repository</name>
<url>https://repository.apache.org/content/groups/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
<!-- fix missing `commons-numbers-core:1.0-SNAPSHOT` on Travis CI
-->
</pluginRepositories>
to the POM fixes the issue on Travis CI, although that doesn't explain why it's not necessary when building with a reset system locally (see How to avoid issues with Maven builds on Travis CI which don't occur locally? for an eventual explanation).
来源:https://stackoverflow.com/questions/45140703/why-fails-travis-ci-to-retrieve-a-snapshot-artifact-when-retrieval-works-locally