-
Notifications
You must be signed in to change notification settings - Fork 41
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
Adding Java provenance info to gradle-based builds #63
Conversation
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.
Looks good overall 👍
javaConvention.getSourceSets().all(sourceSet -> { | ||
sourceSets.add(sourceSet); | ||
//Collect Java metadata for each project (used for Java Provenance) | ||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class); |
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.
JavaPluginExtension
was added in Gradle 4.10, which is newer than the oldest version we currently support (4.7), and we were talking about going back to support even earlier versions of Gradle. Ultimately to support Gradle versions new and old we'll need to use reflection to load one or the other at runtime. For now stick with JavaPluginConvention
if you can.
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.
makes sense
private Method sourceFileGetMarkersMethod() { | ||
if (sourceFileGetMarkers == null) { | ||
try { | ||
Class<?> sourceFileClass = getClassLoader().loadClass("org.openrewrite.SourceFile"); | ||
sourceFileGetMarkers = sourceFileClass.getMethod("getMarkers"); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
return sourceFileGetMarkers; | ||
} |
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.
Why isn't this RewriteReflectiveFacade.SourceFile.getMarkers()
? Same question re: sourceFileWithMarkersMethod()
and markersAddIfAbsentMethod()
.
This is inconsistent with how the rest of the facade is laid out and I don't see why that should be.
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.
I honestly was trying to avoid creating:
A facade for Markers, and a polymorphic facade for Marker and then having JavaProvenance extend that.
When in fact we know that there is a very limited use case for adding the JavaProvenance
.vmRuntimeVersion(javaRuntimeVersion) | ||
.vmRuntimeVersion(System.getProperty("java.vm.vendor")) |
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.
This looks accidental. You probably didn't mean to set the same property twice with different values
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.
yep, should be vmVendor, good catch
Fixes #62