Links to Maven dependencies based on <scm> metadata in JAR's pom.xml
I use Linky only for quickly sharing links to the source code of various repositories. I’m usually disappointed when I end up in some dependency code and I can’t simply copy a link using the context menu.
Technically the operation I need to do to navigate to the dependency source code should be possible to automate. JAR files build by Maven contain pom.xml which when translated to the effective pom should contain <scm>
tag with <url>
to the source code.
It may not be simple to create a link pointing to a revision of a specific version, however even link to a default branch would greatly help in saving a lot of manual work.
Comments (3)
-
staff -
reporter Thanks a lot for reading my suggestion and for a quick and rich response! And obviously thanks for creating Linky - it really helps when discussing the code with others and documenting solutions.
I didn’t think before about the issues you described. It sounds like the solution is not really as simple as I thought to point to a specificc source file.
The potential workaround 1. you described seems like a very interesting idea. Maybe it could be even a bit simpler and it would only create a link to the repository - without locating the file. Creating a link to just a search query would also be useful though.
-
staff Thanks for your kind words I’m happy that Linky provides real value in some of your workflows.
Maybe it could be even a bit simpler and it would only create a link to the repository
Yeah that must be way easier, though I’m still not sure how much help IntelliJ can provide here vs how much logic needs to be added on top. Anyways, the idea sounds interesting and I can imagine the use case, so I’ll see what I can do here.
- Log in to comment
Hey @Przemyslaw Czuj ,
Thanks for reaching out and bringing up this idea!
I can totally understand the use case you are describing. Linky indeed does nothing to any code that is outside of any of the local repositories in the current IDE project. And at the moment Linky is agnostic to the repository content: it only needs to know SCM metadata for a given file to generate Bitbucket URL for it.
Even though you’re right about
scm.url
property in Maven projects and artifacts it produces, I can see few issues here:pom.xml
inside it, there’s no way to tell what was the layout of the classes in that JAR in the original repository. The easiest example would be a multi module maven project, where every module generates an artifact. So parsingscm.url
from just the pom wouldn’t be enough, moreover, in this case Linky would likely need to somehow fetch the parent pom first because the module pom will likely lack SCM metadata.src/main/<lang>
is just a convention, not a rule. So Linky would need to parse another bit from thepom.xml
to be able to generate the right link – source directories.pom.xml
might be generated not by maven, and this complicates things even more. For example, gradle can bakepom.xml
into the artifacts, but the repository layout will have nothing in common with maven.All these things together sound like adding a lot of complexity, and the outcome of that new logic is far from covering all of the use cases.
I can think of two potential work arounds for some of these problems, but obviously they are both limited and not ideal:
All in all, even though I really like your idea in theory, I can’t figure any feasible practical way to implement it. If you have any other ideas of how the problems I described can be approached, please share them.
Cheers,
Daniil