Search code examples
javamavendependenciesartifactory

Maven does not resolve correct SNAPSHOT dependencies


I will be quick. My maven version is 3.5.0. I'm using some libraries in my web applications. The libraries are installed separately and deployed in an artifactory instance.

I have the following pom (part of):

<project>
  ....
  <properties>
    <process.domain.common.version>0.0.1-SNAPSHOT</process.domain.common.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.intersoft</groupId>
        <artifactId>process.domain.common</artifactId>
        <version>${process.domain.common.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.intersoft</groupId>
      <artifactId>process.domain.common</artifactId>
    </dependency>
  </dependencies>
</project>

but in the libs, Maven puts this library:

  process.domain.common-0.0.1-20190319.151024-3.jar

instead of this:

  process.domain.common-0.0.1-SNAPSHOT.jar

My dependencies are resolved from artifactory. Why does Maven put this temporary library with timestamp name instead of the SNAPSHOT? This behavior does not happen in all resolved libraries.


Solution

  • Finally, i found the solution.

    The solution is to add maven war plugin in your pom.xml of the war project:

    <properties>
       <version.war.plugin>2.5</version.war.plugin>
    </properties>
    
    <build>
            <finalName>${project.artifactId}</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${version.war.plugin}</version>
                    <configuration>
                        <warName>${project.artifactId}</warName>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    Proof:

    WEB-INF/lib without the war plugin:

    WEB-INF/lib with the war plugin: