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

Custom Graph Generator: Conditional Attributes for Dependency Nodes #233

Open
NiC0x36 opened this issue Aug 26, 2023 · 0 comments
Open

Custom Graph Generator: Conditional Attributes for Dependency Nodes #233

NiC0x36 opened this issue Aug 26, 2023 · 0 comments

Comments

@NiC0x36
Copy link

NiC0x36 commented Aug 26, 2023

I wrote my own dependencyGraphGenerator. I managed to show the package name including the version.

But as soon as I add any if statement, the task fails:

Execution failed for task ':generateDependencyGraphMyGenerator '.
> Error while evaluating property 'dotFormatGraph' of task ':generateDependencyGraphMyGenerator '
   > java.lang.NullPointerException (no error message)

There are no nullpointers / empty values in my own code, I checked that. It seems like I can't manipulate only certain dependencyNodes in the lambda using ifs.

My Generator:

dependencyGraphGenerator {
	generators {
		myGenerator {
			include = { true }
			children = { true }

			dependencyNode = { node, dependency ->
				// Version of Label
				String versionedLabel = "${dependency.moduleGroup}:${dependency.moduleName}:${dependency.moduleVersion}"
				node.attrs().add(Label.of(versionedLabel))

				if (dependency.moduleName.startsWith("app")) {
					node.attrs().add(Style.FILLED, Color.rgb("#ADD8E6"))
				}

				if (dependency.moduleGroup.startsWith('org.apache')) {
					node.attrs().add(Style.FILLED, Color.rgb("#d1bc8a"))
				}
			}
		}
	}
}

How can I implement this generator, so some attributes will only be applied to dependency which fulfill a certain condition?

Thanks for your help

@NiC0x36 NiC0x36 changed the title Custom Graph Generator: Apply certain attributes only to certain dependencyNodes Custom Graph Generator: Conditional Attributes for Dependency Nodes Aug 26, 2023
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

No branches or pull requests

1 participant