JET FAQ What is JMerge?
Whay is JMerge?
JMerge is a technology developed by the Eclipse Modeling Framework (EMF) so that code generators that produce Java code can permit user modification of that code, while still permitting the code generator to be re-executed.
Using JMerge creates a contract between Code Generator and the Consumer. The actual contract depends which JMerge rules are used. Here is a description of the contract for the JMerge rules provided by EMF.
- On code generation execution/re-execution
- The Code Generator shall only update Java elements with an intact @generated tag.
- The Code Generator may remove Java elements with an intact @generated tag this is no longer specified by the code generator input. The Consumer must be aware that such removal can result in compilation users in the Consumer's code.
- While editing generated Java code
- The Consumer may add new Java elements without worry that the Code Generator will overwrite them. The Consumer must be aware that a subsequent change in the code generator's input may cause the Code Generator to fail to write a Java element with the same signature as the new element. JMerge provides no feedback that such a failure has occured.
- The Consumer may modify a generated Java element (and preserve their changes) by removing or defacing the @generated javadoc tag on the element. Defacing is a good practices, is it clearly indicates the Consumer's intent to modify generated code. Common ways of defacing the @generated tag are to change it to '@generated not' or '@!generated'.
- JET FAQ How do I use JMerge to manage user specific code?
- JET FAQ How does JMerge work?
- JET FAQ How do I write custom JMerge rules?
Back to the M2T-JET-FAQ