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

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenSpyLogProcessor.java
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/DependenciesFingerprintPublisher.java
          jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtils.java
          jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenSpyLogProcessorTest.java
          maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/DependencyResolutionResultHandler.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/96e922fca238fae2f23c7014cedee949453556ba
          Log:
          JENKINS-45024 Use org.eclipse.aether.artifact.Artifact#isSnapshot() to identify snapshot versions

          JENKINS-45024 Use org.eclipse.aether.artifact.Artifact#isSnapshot() to identify snapshot versions instead of looking at the pattern of the version string

          Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/608fd2921aba...96e922fca238

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/MavenSpyLogProcessor.java jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/DependenciesFingerprintPublisher.java jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/util/XmlUtils.java jenkins-plugin/src/test/java/org/jenkinsci/plugins/pipeline/maven/MavenSpyLogProcessorTest.java maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/DependencyResolutionResultHandler.java http://jenkins-ci.org/commit/pipeline-maven-plugin/96e922fca238fae2f23c7014cedee949453556ba Log: JENKINS-45024 Use org.eclipse.aether.artifact.Artifact#isSnapshot() to identify snapshot versions JENKINS-45024 Use org.eclipse.aether.artifact.Artifact#isSnapshot() to identify snapshot versions instead of looking at the pattern of the version string Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/608fd2921aba...96e922fca238

            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: