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

Remove internal shaded jar import from ConfigureJdksIdeaPluginXml #499

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

gluxon
Copy link

@gluxon gluxon commented Jan 24, 2025

Problem

When opening a private project in IntelliJ, we're seeing a strange import error during the Gradle project sync phase.

Unable to load class 'org.gradle.internal.impldep.com.google.common.collect.ImmutableMap'.

This is an unexpected error. Please file a bug containing the idea.log file.

Here's the condensed stacktrace.

* Exception is:
org.gradle.internal.event.ListenerNotificationException: Failed to notify build listener.
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:112)
Caused by: java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/ImmutableMap
	at com.palantir.gradle.jdks.ConfigureJdksIdeaPluginXml.updateIdeaXmlFile(ConfigureJdksIdeaPluginXml.groovy:42)
Caused by: java.lang.ClassNotFoundException: org.gradle.internal.impldep.com.google.common.collect.ImmutableMap
	... 170 more

Theory

It looks like this plugin imports ImmutableMap from an internal shaded jar in Gradle. I suspect this import was accidental.

It's also possible the import as written was intentional, and the private repo I'm working on is doing something it's not supposed to with its settings.gradle. 😅

If we think that's the case, I'm happy to close this PR.

@changelog-app
Copy link

changelog-app bot commented Jan 24, 2025

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fix a possible project sync error when opening IntelliJ by removing an import to org.gradle.internal.impldep.com.google.common.collect.ImmutableMap.

Check the box to generate changelog(s)

  • Generate changelog entry

@gluxon gluxon force-pushed the bcheng/remove-gradle-api-internal-ImmutableMap-import branch from ab1f063 to f2ddaa9 Compare January 24, 2025 03:52
@gluxon gluxon changed the title Import ImmutableMap from Guava rather than internal gradle-api Remove internal shaded jar import from ConfigureJdksIdeaPluginXml Jan 24, 2025
Comment on lines +41 to +42
// Using Map rather than ImmutableMap to avoid a Guava dependency.
Map<String, String> projectNodeAttributes = Map.of("version", "4");
Copy link
Author

Choose a reason for hiding this comment

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

I could also add a Guava dependency to gradle-jdks-groovy instead of using Map.of. I saw this class gets called from ToolchainsPlugin, which already had a Guava dep.

- ToolchainsPlugin
  - PalantirGradleJdksIdeaPlugin
    - ConfigureJdksIdeaPluginXml

Do we need to keep gradle-jdks-groovy dependency-free?

Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use Map.of than require Guava anyway, bonus to avoid the dependency.

@gluxon gluxon marked this pull request as ready for review January 24, 2025 04:01
@gluxon gluxon requested review from crogoz and CRogers January 24, 2025 04:01
CRogers
CRogers previously approved these changes Jan 24, 2025
@policy-bot policy-bot bot dismissed CRogers’s stale review January 24, 2025 18:22

Invalidated by push of 32d468b

@gluxon
Copy link
Author

gluxon commented Jan 24, 2025

Thanks @CRogers!

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.

3 participants