-
Notifications
You must be signed in to change notification settings - Fork 9
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
add the namespace mapping capability of avrohugger #13
Conversation
Hi @shudas, thank you very much for the feature implementation. I am going to review the PR right now. |
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.
Could you add one test for the feature?
Thanks!
@@ -52,7 +58,20 @@ public void execute() throws MojoExecutionException, MojoFailureException { | |||
String outputDirectoryPath = outputDirectory.getAbsolutePath(); | |||
getLog().info("Generating Scala files for schemas in " + sourceDirectoryPath + " to " + outputDirectoryPath); | |||
|
|||
Map<String, String> nonNullNamespaceMapping = new HashMap<>(); | |||
if (namespaceMapping != null && !namespaceMapping.isEmpty()) { |
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.
What do you think about using an empty List
as default value? This would remove the null
check.
You can remove the if
statement completely as for empty List
s the code would be executed zero times.
Please also move the transformation to Map
to the AvrohuggerGenerator
class since we need a Scala
Map
anyways.
@@ -0,0 +1,6 @@ | |||
package at.makubi.maven.plugin.avrohugger; | |||
|
|||
public class mapping { |
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.
Please rename the class to start with an upper-case like Mapping
.
package at.makubi.maven.plugin.avrohugger; | ||
|
||
public class mapping { | ||
String from; |
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 am not sure, if this works or if you need to use a POJO with setters and getters.
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 tested it out myself and this works.
Hi, I've made the changes you have asked for. Thanks for the quick PR |
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.
Thanks for updating the PR.
Can you please use another (meaningful) branch than master
as source branch and squash the commits to one?
Thanks
</executions> | ||
<configuration> | ||
<namespaceMapping> | ||
<Mapping> |
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.
For convenience, can you change the example doc to mapping
with a lower case? I guess this should work with the upper case Mapping
class name.
@@ -19,6 +19,12 @@ | |||
<recursive>true</recursive> | |||
<limitedNumberOfFieldsInCaseClasses>true</limitedNumberOfFieldsInCaseClasses> | |||
<sourceGenerationFormat>STANDARD</sourceGenerationFormat> | |||
<namespaceMapping> | |||
<Mapping> |
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.
And update it here as well.
In order to change the base branch name, it looks like I had to open a new PR against master. #15 Please approve that one and I will close this, and squash and merge that one. |
Just squash the three commits at the new PR and close this one, then I will approve it. |
Avro Hugger has the ability to change the namespace of the generated scala source files.
https://github.com/julianpeeters/avrohugger#customizable-namespace-mapping
This PR exposes this mapping functionality.