3

How i can force maven to recompile OpenDaylight-Openflowplugin project using previous generated Java classes by Yang, rather then generate new java classes with every compilation?

I'm trying to edit the java classes generated by Yang but every time that i recompile the project, maven re-generates the java classes and my changes are removed.

Kevin Costa
  • 87
  • 10

1 Answers1

1

I don't know why you would want to manually edit generated classes but, if that's what you really want to do, then don't run the yang-maven-plugin or just copy the generated classes you want to edit to a different package under src/main/java where they won't be overwritten.

Tom Pantelis
  • 1,349
  • 1
  • 7
  • 6
  • Thanks for the help. What i'm tryng to do requires throw an checked exception in the code of a class that implements an API that are generated by Yang, so i need to throw the checked exception in the API method that will be overriden as well. – Kevin Costa Jan 15 '19 at 16:09
  • I'm not skilled in Java and Yang tho, so i don't know if there more neat ways to do this – Kevin Costa Jan 15 '19 at 16:12
  • I worked around with the second option that you showed, however with the first option (don't run yang-maven-plugin) i haven't found a definition of the yang-maven-plugin anywhere in the pom's to be able to disable it. Do you know the location of the yang-maven-plugin definition in the openflowplugin poms? – Kevin Costa Jan 15 '19 at 18:50
  • It gets picked up from the mdsal binding-parent pom. The thing is the yang-generated code is not intended to be modified for obvious reasons - each time you modify the yang then you'd have to reconcile with your manual changes which isn't very maintainable. – Tom Pantelis Jan 15 '19 at 23:08
  • 1
    I assume you're implementing a generated yang RPC or notification interface... I would suggest wrapping the implementation with your own interface that throws the checked exception rather than trying to modify generated code. – Tom Pantelis Jan 15 '19 at 23:17
  • The situation is that i'm trying to get data directly from classes in the openflowplugin-impl module and also implement socket communication in some of this classes – Kevin Costa Jan 16 '19 at 21:40
  • The problem is that i need to throw checked exceptions in some overrided methods that don't have in their original methods (these original methods are located in yang generated java interfaces) checked exceptions, which isn't permited in java. – Kevin Costa Jan 16 '19 at 21:42