user358448
user358448

Reputation: 1187

Why does Maven not always download the last dependency from theartefactory, build from bamboo?

I am using bamboo for automated build of our modules and maven for build tool. It works correctly, but sometimes if I need to increase the version of the module (for example from 1.0-SNAPSHOT change to 1.1-SNAPSHOT)

I do the following things: 1) tag the 1.0-SNAPSHOT version in my svn repository under the same directory scructure, but in tags root directory. This is done for compatibility reasons. 2) Create bamboo build plan, that builds the tagged module. 3) Increase the module's version, which is in trunk.

So far so good. But sometimes when i build my client's project, the tagged module is not downloaded from maven (even i can see that it is correctly built from bamboo) and it uses the old jar before the tag. Also apart from that maven does not always download the last jar and i have to go and manually delete it from .m2 directory or update the module and rebuild it manually on my machine (no offline mode is used). It's pain in the ass, but as a developer i can do this, but our projects are also built from administrators, who don't know how to manage this and they sometimes deploy projects with wrong dependencies, which leads to trouble :).

So if someone knows how to fix this let me know.

Upvotes: 1

Views: 3847

Answers (2)

Asgard
Asgard

Reputation: 622

Try mvn deploy -U when you're building your client application, which is dependent of that module. -U argument is used to retrieve the latest built SNAPSHOT dependencies (is not reffering to latest version, but to the last built SNAPSHOT artifact) when building the dependent project, which in your case is probably the client application.

Upvotes: 2

FrVaBe
FrVaBe

Reputation: 49341

Have a look at your settings.xml file. You will find a section like this:

    <profile>
      <id>FooBar</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>nexus</id>  
          <!-- use a bogus URL as this gets overwritten by the mirror settings -->
          <url>http://central</url>
         <releases>
            <enabled>true</enabled>
             <updatePolicy>daily</updatePolicy>
         </releases>
          <snapshots>
            <enabled>true</enabled>
             <updatePolicy>always</updatePolicy>
         </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>nexus</id>
          <!-- use a bogus URL as this gets overwritten by the mirror settings -->
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>FooBar</activeProfile>
  </activeProfiles>

Ensure to use <updatePolicy>always</updatePolicy> everywhere you want to download artifacts each time instead of using your local ones.

Upvotes: 3

Related Questions