-
Notifications
You must be signed in to change notification settings - Fork 57
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
base: main
Are you sure you want to change the base?
Use provided
configuration for optional language dependencies
#411
Conversation
…s and add file-checkers with a reflection-class-exists-check
Co-authored-by: Tim te Beek <[email protected]>
I'd like to use the old nebula provided configuration plugin instead here, such that the dependency winds up with a |
src/main/java/org/openrewrite/staticanalysis/csharp/CSharpFileChecker.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/groovy/GroovyFileChecker.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/kotlin/KotlinFileChecker.java
Outdated
Show resolved
Hide resolved
public class ClassPathUtils { | ||
public static boolean isAvailable(String className) { | ||
try { | ||
Class.forName(className); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one thing I'm wondering here but I'm not sure about, is if the classloader used here would contain the C# / Groovy / Kotlin classes we are likely to parent class load in the CLI & Platform. Something to keep an eye on I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only just now saw this comment; indeed makes most sense to add those <provided>
dependencies, which are missing right now after a publish to Maven local.
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>26.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java</artifactId>
<version>8.43.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openrewrite.meta</groupId>
<artifactId>rewrite-analysis</artifactId>
<version>2.15.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.13.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-templating</artifactId>
<version>1.21.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
</dependencies>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should always use this form and set the initialize
boolean to false
so that static initializers etc don't get executed unintentionally.
is if the classloader used here would contain the C# / Groovy / Kotlin classes we are likely to parent class load in the CLI & Platform
@timtebeek yes it would, because by default forName
uses the classloader of ClassPathUtils
, which will be in the same classloader as the recipe whose parent classloader contains the language specific classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provided
configuration for optional language dependencies
} | ||
apply(plugin = "com.netflix.nebula.provided-base") |
There was a problem hiding this comment.
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.
What's changed?
Groovy, Kotlin and CSharp dependencies are changed to
compileOnly
. The filechecker-classes have been adjusted with a reflection checkWhat's your motivation?
compileOnly
configuration for optional language dependencies #410Checklist