0

I am observing whenever I am executing the below command:-

mvn -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report

maven is downloading maven-metadata & plugin artifacts every time.

Downloading: http://maven.twttr.com/com/neveda/kekin-storage-metrics/0.001-SNAPSHOT/maven-metadata.xml 

...

Downloading: http://artifactory.kekin.local:XXXX/libs-release/org/

I have gone through this answer & my settings.xml looks like below:-

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <profiles>
   <profile>
     <repositories>
       <repository>
         <snapshots>
           <enabled>false</enabled>
           <updatePolicy>never</updatePolicy>
         </snapshots>
         <id>central</id>
         <name>libs-release</name>
         <url>http://artifactory.kekin.local:XXXX/libs-release</url>
       </repository>
       <repository>
         <snapshots>
          <updatePolicy>never</updatePolicy>
         </snapshots> 
         <id>snapshots</id>
         <name>libs-snapshot</name>
         <url>http://artifactory.kekin.local:XXXX/libs-snapshot</url>
       </repository>
     </repositories>
     <pluginRepositories>
       <pluginRepository>
         <snapshots>
           <enabled>false</enabled>
           <updatePolicy>never</updatePolicy>
         </snapshots>
         <id>central</id>
         <name>plugins-release</name>
         <url>http://artifactory.kekin.local:XXXX/plugins-release</url>
       </pluginRepository>
       <pluginRepository>
     <snapshots>
        <updatePolicy>never</updatePolicy>
     </snapshots>
         <id>snapshots</id>
         <name>plugins-snapshot</name>
         <url>http://artifactory.kekin.local:XXXX/plugins-snapshot</url>
       </pluginRepository>
     </pluginRepositories>
     <id>artifactory</id>
   </profile>
 </profiles>
 <activeProfiles>
   <activeProfile>artifactory</activeProfile>
 </activeProfiles>
</settings>

Environment:-

  • Maven - 3.5
  • OS - 10.12.6
tuk
  • 5,941
  • 14
  • 79
  • 162
  • Are you having SNAPSHOT dependencies? Please show your full pom file. – khmarbaise Aug 17 '17 at 11:19
  • Yes I have SNAPSHOT dependency. It is a multimodule project. Do you want all the poms? – tuk Aug 17 '17 at 11:32
  • Do you have SNAPSHOT dependencies outside the multi module project? If the SNAPSHOT deps only intermodule dependencies that should not result in downloads from repository if so something is wrong... – khmarbaise Aug 17 '17 at 12:00
  • I am seeing releases also getting downloaded. For example `Downloading: http://artifactory.kekin.local:XXXX/plugins-release/commons-digester/commons-digester/a.b/commons-digester-a.b.pom` – tuk Aug 17 '17 at 12:04
  • Are you deleting everytime the local cache ($MAVEN_REPO) ? – khmarbaise Aug 17 '17 at 12:22
  • I do `mvn clean install -DskipTests -T 6` and then `mvn -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report` . As per my understanding `clean` don;t delete the local repo. – tuk Aug 17 '17 at 12:30
  • The question is how your job is configured cause it looks like you are running inside a CI solution like Jenkins otherwise your calling from command line with so many parameters does not make sense...? – khmarbaise Aug 17 '17 at 18:12
  • The commands that I have posted in my question is in my local dev machine, MacOS , 10.12.6. But I don;t think having the parameters in command line is anything to do with download issue I am facing. – tuk Aug 18 '17 at 05:41
  • Please add the full pom file to your pom... – khmarbaise Aug 18 '17 at 06:32
  • Sorry @khmarbaise I did not get you.Can you please explain what do you mean by "add full pom file to your pom" ? – tuk Aug 18 '17 at 18:27
  • Just add the pom file you are using in this case to the post...? – khmarbaise Aug 19 '17 at 15:54

1 Answers1

1

I am not sure if this would be a solution for you but you can invoke maven with the --offline switch to stop it from doing any downloads:

mvn --offline  -f pom.xml -Dmaven.repo.local=$MAVEN_REPO -Drat.skip=true -DnoTest=true surefire-report:report

This has the side-effect, though, that your build will fail if any artifact is missing.

Christoph Böhme
  • 3,766
  • 1
  • 19
  • 29
  • I know about `-o` but I want something like if the artifact is missing or have been modified then only download. – tuk Aug 17 '17 at 11:47
  • The other side effect you have here is that any SNAPSHOT dependencies will not be updated, if you care about that, the offline mode is all or nothing, and there's nothing to do about that – mikeb Aug 17 '17 at 11:47