Is it possible to define PlanningVariables programmatically (at runtime) instead of through annotations?
I am afraid there is no such API allowing that yet (there is a jira for it). But I see your motivation to reduce code duplication. I can only advise sharing as many of the domain classes as you can. In this case, if you say the domains differ only in the PlanningVariable, you need to have separate @PlanningEntity and @PlanningSolution classes. Even further, these might have a common ancestor to reduce the duplication further.
In the solverConfig.xml
(one for each of the 2 SolverFactories) you can then use <entityClass>
and <solutionClass>
for which one to use.