-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bug Fixes: Maven Classifier, SemVer #1924
Conversation
a1flecke
commented
Jun 19, 2020
•
edited
Loading
edited
- Add support for maven dependency classifiers
- Build Identifiers should not be used in SemVer comparisions
- Dependabot was not ignoring the build identifier when determing if a dependency update was a semver update
This would be a great addition to dependabot! Thanks for making this @a1flecke! |
c98cc04
to
08af3c8
Compare
@feelepxyz All checks pass. My employer is encountering both of these bugs which is lowering the utility of dependabot for us. Please let me know if there is something that I need to do for this PR. |
@@ -257,15 +258,16 @@ def dependency_metadata_url(repository_url) | |||
end | |||
|
|||
def dependency_files_url(repository_url, version) | |||
group_id, artifact_id = dependency.name.split(":") | |||
group_id, artifact_id, classifier = dependency.name.split(":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this also needs to change in dependency_metadata_url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's also quite a few instances where we split and get the last element as the artifact id in the MetadataFinder, e.g. https://github.com/dependabot/dependabot-core/blob/master/maven/lib/dependabot/maven/metadata_finder.rb#L26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feelepxyz From what I can tell the classifier itself it not used in the url for fetching maven metadata. Mulesoft dependencies use classifiers a lot, an example being the pom file in this repo I created for a Mulesoft support ticket. I checked a couple of the metadata paths for those dependencies and only group_id
and artifact_id
were needed.
Thank you for catching the other .last
calls. I will fix those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together and writing all the tests 🙇 added a few minor comments. Could you also add a test case in the file_updater_spec.rb
updating io.mockk
in the basic pom file you edited?
* [Add support for maven dependency classifiers](https://maven.apache.org/pom.html#dependencies) >classifier: >The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number. >As a motivation for this element, consider for example a project that offers an artifact targeting Java 11 but at the same time also an artifact that still supports Java 1.8. The first artifact could be equipped with the classifier jdk11 and the second one with jdk8 such that clients can choose which one to use. >Another common use case for classifiers is to attach secondary artifacts to the project's main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files. * [Build Identifiers should not be used in SemVer comparisions](https://semver.org/#spec-item-11) * Dependabot was not ignoring the build identifier when determing if a dependency update was a semver update
Co-authored-by: Philip Harrison <philip@mailharrison.com>
88cf5a7
to
dbb7740
Compare
@feelepxyz I could use some assistance here. I have been fighting what appears to be some flaky tests with VCR and requests to rubygems Are these tests known to have issues? Example results when running locally is VS Code devcontainer using the same rspec seed:
|
dbb7740
to
a2779cf
Compare
@feelepxyz It seems like the backports gem is missing a spec fixture in I believe this helper will then setup the missing HTTP stub The CircleCI failure.
|
We currently don't have any tooling but if you copy this https://index.rubygems.org/info/backports into a file named These stubs are pretty annoying as it seems like VCR/webmock don't always pick up that they are needed. Possibly because we run Bundler in a forked process 🤷♂️ |
Co-authored-by: Philip Harrison <philip@mailharrison.com>
Co-authored-by: Philip Harrison <philip@mailharrison.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks again and big 🙌 for the thorough testing 🙇 hopefully tests will pass now 🤞
Looks like maven, common and bundler are passing so going to this 🎉 |
@feelepxyz Thanks for your help with this. |
Sorry for digging into this old thread. This is a great improvement btw. Thanks for doing this. We hit a corner case of this change so would like to clarify whether it is intended or not. When checking whether a dependency is internal, meaning some submodule of a project, <dependencyManagement>
<dependencies>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>${project.version}</version>
<classifier>foobar</classifier>
</dependencies>
</dependencyManagement> Because it believes Due to another no-so-standard setup we have, a submodule would have an auto-bumped version of artifacts published every time CI passes in main branch (without changing source code), and the result of that is the published artifacts have higher version than the project's. In this case, for this classified dependency, Dependabot would try to bump the project version in parent pom.xml because it is a property, and that is not what we expect since it results an invalid parent pom.xml because all children still refer to the old version in My question is, whether this is intended change? Would it be better we exclude |
@honnix Unfortunately a lot of time has passed since I created this PR. Given the complexity of Maven I cannot be 100% certain, but you are likely accurate that using a classifier for intra-project dependencies is not going to work since the classifier comes into play when an artifact is published. |
@a1flecke Thanks for replying and the confirmation. I will try to work on a PR to address this. |