Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45024

[Dependencies] Use Maven logic to identify snapshots instead of looking at the version string

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Using the version string (e.g. "1.4.2" or "1.4.2-SNAPSHOT") to identify if a dependency is a snapshot can be wrong. We should rely on org.eclipse.aether.artifact.Artifact#isSnapshot().

      ---- 

      Sample by justinbarry:

      Using this POM:

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <artifactId>test-project</artifactId>
          <packaging>jar</packaging>
          <groupId>com.armus.justin.test</groupId>
          <version>0.0.1-SNAPSHOT</version>
          <dependencies>
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context</artifactId>
                  <version>5.0.0.BUILD-SNAPSHOT</version>
                  <scope>provided</scope>
              </dependency>
          </dependencies>
          <repositories>
              <repository>
                  <id>spring-snapshots</id>
                  <name>Spring Snapshots</name>
                  <url>https://repo.spring.io/libs-snapshot</url>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
          </repositories>
      </project>
      

      The resulting maven spy log looks like this:

      <DependencyResolutionResult class="org.apache.maven.project.DefaultDependencyResolutionResult" _time="2017-06-20 11:53:04.051">
          <resolvedDependencies>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-context-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-context" optional="false" id="5.0.0.BUILD-20170620.161222-312" type="jar" version="5.0.0.BUILD-20170620.161222-312" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-context/5.0.0.BUILD-SNAPSHOT/spring-context-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-aop-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-aop" optional="false" id="5.0.0.BUILD-20170620.161222-312" type="jar" version="5.0.0.BUILD-20170620.161222-312" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-aop/5.0.0.BUILD-SNAPSHOT/spring-aop-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-beans-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-beans" optional="false" id="5.0.0.BUILD-20170620.161222-312" type="jar" version="5.0.0.BUILD-20170620.161222-312" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-beans/5.0.0.BUILD-SNAPSHOT/spring-beans-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-core-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-core" optional="false" id="5.0.0.BUILD-20170620.161222-312" type="jar" version="5.0.0.BUILD-20170620.161222-312" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-core/5.0.0.BUILD-SNAPSHOT/spring-core-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-jcl-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-jcl" optional="false" id="5.0.0.BUILD-20170620.161222-132" type="jar" version="5.0.0.BUILD-20170620.161222-132" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-jcl/5.0.0.BUILD-SNAPSHOT/spring-jcl-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
            <dependency extension="jar" groupId="org.springframework" scope="provided" name="spring-expression-5.0.0.BUILD-SNAPSHOT.jar" classifier="" artifactId="spring-expression" optional="false" id="5.0.0.BUILD-20170620.161222-312" type="jar" version="5.0.0.BUILD-20170620.161222-312" snapshot="true">
              <file>/Users/jbarry/.m2/repository/org/springframework/spring-expression/5.0.0.BUILD-SNAPSHOT/spring-expression-5.0.0.BUILD-SNAPSHOT.jar</file>
            </dependency>
          </resolvedDependencies>
        </DependencyResolutionResult>
      

        Attachments

          Activity

          cleclerc Cyrille Le Clerc created issue -
          cleclerc Cyrille Le Clerc made changes -
          Field Original Value New Value
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          cleclerc Cyrille Le Clerc made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            Assignee:
            cleclerc Cyrille Le Clerc
            Reporter:
            cleclerc Cyrille Le Clerc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: