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

Use provided configuration for optional language dependencies #411

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jevanlingen
Copy link
Contributor

What's changed?

Groovy, Kotlin and CSharp dependencies are changed to compileOnly. The filechecker-classes have been adjusted with a reflection check

What's your motivation?

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

…s and add file-checkers with a reflection-class-exists-check
build.gradle.kts Outdated Show resolved Hide resolved
Co-authored-by: Tim te Beek <[email protected]>
@jevanlingen jevanlingen marked this pull request as ready for review December 23, 2024 12:06
@jevanlingen jevanlingen self-assigned this Dec 23, 2024
@jevanlingen jevanlingen added the enhancement New feature or request label Dec 23, 2024
@jkschneider
Copy link
Member

I'd like to use the old nebula provided configuration plugin instead here, such that the dependency winds up with a provided scope. Most of the tooling we have that executes recipes have runtime dependencies on language bindings and "provide" them in a parent classloader scheme that is highly similar to the original intent of the provided scope in Maven (in the old days when J2EE containers provided servlet types, etc.).

https://github.com/nebula-plugins/gradle-extra-configurations-plugin?tab=readme-ov-file#using-the-provided-plugin

@jkschneider jkschneider changed the title Use compileOnly configuration for optional language dependencies Use provided configuration for optional language dependencies Dec 23, 2024
build.gradle.kts Outdated
}
apply(plugin = "com.netflix.nebula.provided-base")
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't have both a plugin id block above and also an apply call. This apply mechanism is an old way of applying plugins.

Copy link
Contributor Author

@jevanlingen jevanlingen Dec 24, 2024

Choose a reason for hiding this comment

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

Thx for the info! I am still trying to make it work; I don't have much experience with Gradle, so this was my first attempt. At the moment, the provided functions do not work at all 😞. I think it has something to do with Kotlin DSL not supported out-of-the-box.

Copy link
Contributor Author

@jevanlingen jevanlingen Dec 24, 2024

Choose a reason for hiding this comment

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

Ah, now I get it! The plugin does not do anything anymore, it's only an empty plugin today:

LOGGER.warn("nebula.provided-base plugin does nothing. Use the 'compileOnly' configuration")

See alse: history.

What do you propose @jkschneider? Start going for the compileOnly scope? What do you think @timtebeek ? Maybe you have something to say as well @sambsnyd?


FYI: there is another archived project with the same intention.

import org.openrewrite.marker.SearchResult;

/**
* Add a search marker if vising a CSharp file
*/
public class CSharpFileChecker<P> extends TreeVisitor<Tree, P> {
private static final boolean IS_CSHARP_AVAILABLE = ReflectionUtils.isClassAvailable("org.openrewrite.csharp.tree.Cs");
Copy link
Member

Choose a reason for hiding this comment

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

Let's make an isLanguageAvailable function part of ReflectionUtils or otherwise available in the rewrite core modules as this functionality will end up used in many places

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

Use compileOnly configuration for optional language dependencies
4 participants