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

Resolves #973: NPE if actual version is null for a dependency #974

Merged

Conversation

jarmoniuk
Copy link
Contributor

@jarmoniuk jarmoniuk commented Jun 9, 2023

In case a dependency version is specified in dependencyManagement, a dependency can be versionless.

Dependency updates goals would then attempt to find an updated version to a versionless dependency, which would fail with an NPE or, if that is prevented, an attempt would have been made to find an update to version specified as [,0], which would be any version.

Preventing both issues.

@slawekjaranowski please review.

@jarmoniuk jarmoniuk force-pushed the issue-973-npe-empty-version branch from f8e0c0c to a27af46 Compare June 9, 2023 15:46
@jarmoniuk jarmoniuk marked this pull request as draft June 9, 2023 15:48
@jarmoniuk jarmoniuk force-pushed the issue-973-npe-empty-version branch 4 times, most recently from ad63336 to 56106e8 Compare June 9, 2023 18:41
@jarmoniuk jarmoniuk marked this pull request as draft June 23, 2023 17:40
@jarmoniuk
Copy link
Contributor Author

jarmoniuk commented Jun 23, 2023

@slawekjaranowski The plugin itself must define a dependency version in its dependencies or dependency management.

This does trigger the error and will be helped with the patch.

For this to work though as an it, the plugin needs to be executed.

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>4.7.3.4</version>
          <dependencies>
            <!-- overwrite dependency on spotbugs if you want to
            specify the version of spotbugs -->
            <dependency>
              <groupId>com.github.spotbugs</groupId>
              <artifactId>spotbugs</artifactId>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>

In this case, it does define the dependency on com.github.spotbugs:spotbugs:${spotbugsVersion}. -- see https://repo1.maven.org/maven2/com/github/spotbugs/spotbugs-maven-plugin/4.7.3.4/spotbugs-maven-plugin-4.7.3.4.pom

EDIT: No, it will still fail if we actually try executing the plugin

@jarmoniuk
Copy link
Contributor Author

jarmoniuk commented Jun 23, 2023

@slawekjaranowski Ok, so I guess this is another edge case: the pom.xml will fail when we try executing the actual plugin as it is invalid -- lacks version. However, this faulty pom.xml will cause an NPE on the versions plugin if we try bumping the versions. So, maybe let's allow this faulty pom.xml as the goal here is not to execute the plugin, but to make the versions plugin not fail while processing the pom.

@slawekjaranowski
Copy link
Member

@slawekjaranowski Ok, so I guess this is another edge case: the pom.xml will fail when we try executing the actual plugin as it is invalid -- lacks version. However, this faulty pom.xml will cause an NPE on the versions plugin if we try bumping the versions. So, maybe let's allow this faulty pom.xml as the goal here is not to execute the plugin, but to make the versions plugin not fail while processing the pom.

Sounds reasonable - we only need comments on IT tah such configurations is not working

@slawekjaranowski
Copy link
Member

Dropped my test commit 😄

@jarmoniuk jarmoniuk marked this pull request as ready for review June 23, 2023 19:05
@jarmoniuk
Copy link
Contributor Author

Added a description. Did not squash :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants