Search code examples
ide-customizationfaktor-ips

How do I extend the code generation of Faktor-IPS to modify generated Code


I need to modify the code generated by Faktor-IPS. I've seen the extension property "org.faktorips.devtools.core.artefactbuilderset" and created a class extending the StandardBuilderSet.

I created my own builder (MetaattributPolicyCmptClassBuilder) and extended the default implementation by putting my implementation in the builder map as shown below:


    @Override
    protected LinkedHashMap<IBuilderKindId, IIpsArtefactBuilder> createBuilders() throws CoreException {
        LinkedHashMap<IBuilderKindId, IIpsArtefactBuilder> builders = super.createBuilders();
        
        builders.put(BuilderKindIds.POLICY_CMPT_TYPE_IMPLEMEMENTATION, new MetaattributPolicyCmptClassBuilder(false, this, getGeneratorModelContext(), getModelService()));
        
        return builders;
    }

    
}

I would expect my custom code (put in the list of builders in the example above) to be executed, but only the code of the standard builder set is executed. What is wrong or what else has to be done to get this to work?


Solution

  • To let your project use your custom builder, set the builder set ID in the .ipsproject file using the XMl tag instead of the "org.faktorips.devtools.stdbuilder.ipsstdbuilderset"