We are using <a href="http://www.jboss.org/drools/" rel="nofollow">JBoss Rules</a> (a.k.a. Drools) and have several <em>.drl</em> files that each contain several rules. Is there a way to avoid duplication between files, so that we can define common rules that are available to more than one <em>.drl</em> file?
Unfortunately, there does not seem to be any kind of <em>include</em> or module facility.Answer1:
There is no way of including rules from another .drl file from within a .drl file.
You can however add two .drl files to the same ruleBase and they will work as if they were in the same file.
PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "common.drl" ) ) ); builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "rules1.drl" ) ) ); RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( builder.getPackage() );