Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in DependencyUpdatesXmlRenderer.getVersionsBlocks with version ranges #323

Closed
TobiX opened this issue Nov 29, 2018 · 1 comment · Fixed by #653
Closed

Comments

@TobiX
Copy link
Contributor

TobiX commented Nov 29, 2018

When there is a dependency with a version range (I know, bad practice) in the dependencyManagement the xml renderer throws a null pointer exception:

Caused by: java.lang.NullPointerException
    at org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.getVersionsBlocks (DependencyUpdatesXmlRenderer.java:190)
    at org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.getDependencyInfoBlock (DependencyUpdatesXmlRenderer.java:251)
    at org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.render (DependencyUpdatesXmlRenderer.java:101)
    at org.codehaus.mojo.versions.DependencyUpdatesReport.doGenerateReport (DependencyUpdatesReport.java:177)

Minimal test-pom (run mvn site on it):

<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>
  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <version>[2.6.0-SNAPSHOT,2.99)</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>2.7</version>
          <configuration>
            <formats>
              <format>html</format>
              <format>xml</format>
            </formats>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>
</project>
@github-actions github-actions bot added the Stale label Sep 25, 2021
@github-actions github-actions bot closed this as completed Oct 3, 2021
@slachiewicz slachiewicz removed the Stale label Oct 3, 2021
@slachiewicz slachiewicz reopened this Oct 3, 2021
@jarmoniuk
Copy link
Contributor

DefaultArtifact::version is set to null in its constructor if the dependency specifies a range and there's no recommended version:

    private void selectVersionFromNewRangeIfAvailable()
    {
        if ( ( versionRange != null ) && ( versionRange.getRecommendedVersion() != null ) )
        {
            selectVersion( versionRange.getRecommendedVersion().toString() );
        }
        else
        {
            version = null;
            baseVersion = null;
        }
    }

jarmoniuk added a commit to jarmoniuk/versions-maven-plugin that referenced this issue Aug 26, 2022
jarmoniuk added a commit to jarmoniuk/versions-maven-plugin that referenced this issue Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants