[rules-dev] FAO: conan, laune: PackageBuilder

Michael Anstis michael.anstis at gmail.com
Fri Jul 15 04:33:08 EDT 2011


This fails:-

*Test
*
package com.guvnor.tests;

import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderErrors;
import org.drools.io.ResourceFactory;
import org.drools.lang.descr.PackageDescr;

public class FragmentsTest {

    public static final void main(String[] args) {
        try {
            PackageBuilderErrors pbe;
            PackageBuilder pb = new PackageBuilder();
            pb.addPackage( new PackageDescr( "p3" ) );
            pb.addPackageFromDrl( ResourceFactory.newClassPathResource(
"Fragment1.drl" ) );
            pbe = pb.getErrors();
            System.out.println("Errors = " + pbe.getErrors().length );
            pb.addPackageFromDrl( ResourceFactory.newClassPathResource(
"Fragment2.drl" ) );
            pbe = pb.getErrors();
            System.out.println("Errors = " + pbe.getErrors().length );
            pb.addPackageFromDrl( ResourceFactory.newClassPathResource(
"Fragment3.drl" ) );
            pbe = pb.getErrors();
            System.out.println("Errors = " + pbe.getErrors().length );
            pb.getPackage();
        } catch ( Exception e ) {
            e.fillInStackTrace();
            e.printStackTrace();
        }
    }
}

*Fragment1.drl
*
package com.guvnor.package3

import com.guvnor.package1.Person
import java.math.BigDecimal


*Fragment2.drl
*
package com.guvnor.package3

//import com.guvnor.package1.Person <<Fails unless I add this import

declare Person
end

declare Person2 extends Person
    name : String
    age : Integer
end

*Fragment3.drl
*
package com.guvnor.package3

rule "test"
when
    Person( salary == 10 )
then
    System.out.println("Hello Fred!");
end

Resolved with
https://github.com/droolsjbpm/drools/commit/dc00433f3e3821a2c224ba8dc36f0235b07aef2f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110715/5a8f3290/attachment.html 


More information about the rules-dev mailing list