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

Adding Java provenance info to gradle-based builds #63

Merged
merged 4 commits into from
Aug 4, 2021
Merged

Conversation

tkvangorder
Copy link
Contributor

Fixes #62

Copy link
Member

@sambsnyd sambsnyd left a 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);
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense

Comment on lines 210 to 220
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;
}
Copy link
Member

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.

Copy link
Contributor Author

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

Comment on lines 187 to 188
.vmRuntimeVersion(javaRuntimeVersion)
.vmRuntimeVersion(System.getProperty("java.vm.vendor"))
Copy link
Member

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

Copy link
Contributor Author

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

@sambsnyd sambsnyd merged commit aee6918 into main Aug 4, 2021
@sambsnyd sambsnyd deleted the java-provenance branch August 4, 2021 00:02
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.

Add JavaProvenance information to ASTs parsed by the gradle plugin
2 participants