-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Improve documentation of classpath.idx
file and its generation by the Maven and Gradle plugins
#37125
Comments
It isn't intended for the As a Maven user, if you want to change the ordering of entries in We should update the documentation to clarify this. |
classpath.idx
file and its generation by the Maven and Gradle plugins
I had assumed that the order in the dependencies list in the pom.xml would control this, but it had no effect. I think the behavior of this might differ between "top-level" dependencies, specified directly in the pom.xml, and transient dependencies of those top-level dependencies. When I moved the "top-level" dependency that has a transient dependency on an artifact I needed to be reordered, it didn't matter whether I had that "top-level" dependency at the top of the list or the bottom of the list, it didn't change the ordering of the transient dependencies I needed to control. |
If those transitive dependencies share the same top-level dependency, moving the top-level dependency will indeed have no effect on the ordering of the transitive dependencies. To have an effect, you would have to declare those transitive dependencies directly in the pom in the desired order. Note that this isn't specific to Spring Boot, it's Maven's standard behavior, and the Maven pom is the right place to fix it as then it'll fix the ordering of the classpath for tests as well. |
Do you think that specifying those transient dependencies in the dependencyManagement section of the parent pom would have an effect? The "top-level" dependencies are specified in the parent pom, but not the particular transient dependencies. |
I don't believe it does, but you could experiment to get a definitive answer. |
The "classpath.idx" file allows for the possibility of controlling the artifact load order. In reality, it's completely impractical to do anything with this.
The entries in the file are in the form of "artifactname-version.jar". In a Maven application, it would be extremely awkward to have a local copy of this file in the project and cause that file to be used instead of the generated one, for multiple reasons.
The Spring-boot-maven-plugin really needs an interface for manipulating the content of this file, but not necessarily the entire file.
One reason someone might need to control the order of these artifacts is if two or more artifacts have the same FQCN, with different content. Obviously, that's a bad situation, and artifacts like that likely would be considered to be defective, but that's no consolation if you have no choice but to use them.
At a minimum, to deal with this particular situation, I would want to be able to specify a list of GA pairs, with the implication that the order of those pairs should reflect the ordering of those pairs in the classpath.idx file. There may be other artifacts in between, but for instance, if I had artifact "Foo" first in the list, and artifact "Bar" second in the list, in the resulting "classpath.idx" file, the entry for "Foo-version.jar" needs to be before the entry for "Bar-version.jar".
The text was updated successfully, but these errors were encountered: