Skip to content

feat: scope deps#2133

Closed
maxandersen wants to merge 5 commits intojbangdev:mainfrom
maxandersen:scopeddeps
Closed

feat: scope deps#2133
maxandersen wants to merge 5 commits intojbangdev:mainfrom
maxandersen:scopeddeps

Conversation

@maxandersen
Copy link
Copy Markdown
Collaborator

@maxandersen maxandersen commented Aug 1, 2025

this PR will grow to have scope deps.

for now this is just implementing precursor for #2126 as a mechanism to store scopes and possible other attributes on dependency.

Basically can parse a string into a map of key->List to capture any kind of options that we add to a MavenCoordinate as a DependencyAttributes.

With this in place doing additional filtering when resolving becomes somewhat trivial.

We can utilize this notion of attributes on potential anything

Currently implemented syntax is inspired by asciidoc: https://docs.asciidoctor.org/asciidoc/latest/attributes/positional-and-named-attributes/

I initially started with https://github.com/yupiik/tools-maven-plugin/blob/d1e8b97ebcae032684a0fafac426bcc25819089f/asciidoc-java/src/main/java/io/yupiik/asciidoc/parser/Parser.java#L1634 but it was too simple so with a bit a LLM help got something that supports things like:

g:a:v or g:a:v{} -> scope will be build, run
g:a:v{build} -> scope will be build
g:a:v{build, boot} -> scope will be build , boot g:a:v{build, scope=boot} -> scope will be build , boot
`g:a:v{build, scope=boot,%transitive} -> scope will be build , boot and there will be a "transitive=[true]

...I even allow quotes...
`g:a:v{build, scope=boot,comment="This is probably over kill",%transitive} -> scope will be build , boot and there will be a "transitive=[true] and "comment"=["This is probably over kill"]

...will allow for things like:

g:a:v{build,exclude=org.jreleaser:*} which is pretty nice too imo :)

oh...and I converted to assertJ in the tests where I need to...hamcrest need to retire.

...will update this main description as things evolve and this eventually will Fix #2126

@maxandersen maxandersen changed the title feat: dependency attributes feat: scope deps Aug 1, 2025
}

// lazy computed; dont store hashset unless truly needed
public boolean includeInScope(String scope) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the word scope - mainly because these aren't actually maven scopes but rather something that gets translated into a scope.

includeInConfig(String config) maybe ? (gradle use configuration as name for different scenarios)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it would be defaultConfigs if follow same route.

}

@Override
public boolean equals(Object o) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so first push resulted in funky TestModules errors that was caused by equals method missing on Attributes - which is fair..but reveals a conondrum - how do we define equals for these? i've implemented a few tests (which currently fails) showing situations that we probably want to make equals...which we can by unifing attributes...but should we?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just did an update where i split it out in a DependencyRequest even though I do thing the other properties makes sense to have on the "thing" that encodes the dependency - but it seems like we have places where we treat MavenCoordinate as absolutes which can be used as keys....that is NOT the case even with these new info because MavenCoordinates can have version ranges defined.

"}\n";

String srcWithVersionRangeDep = "//MODULE testmodule\n" +
"//DEPS info.picocli:picocli:4.6+\n" +
Copy link
Copy Markdown
Collaborator Author

@maxandersen maxandersen Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this test as realized the module support seem to rely on exact string matches rather than understanding of resolved dependencies - is that a known/expected limitation @quintesse ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like Module generation should only compare on the group + artifict + type ..ignore version range or any properties?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're referring to @maxandersen . What exact string matches? What understanding of resolved dependencies? There's not really a relationship between modules and maven dependencies implemented (at least as far as I remember).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's #2135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scoped and managed dependencies

2 participants