<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 12/14/10 5:20 PM, Michael Neale wrote:
    <blockquote
      cite="mid:AANLkTi=svgHfceACUhd7eEBf6AXbUUOGtWZsbGXf1agU@mail.gmail.com"
      type="cite">Any package scoped things really should go in the
      .package file IIRC.&nbsp;
      <div>There is no clever resolving across multiple files (not sure
        if that is a valid feature request or not).&nbsp;<br>
        <br>
      </div>
    </blockquote>
    For now I'll just make sure .package files get read in first (if
    exist).<br>
    <br>
    <blockquote
      cite="mid:AANLkTi=svgHfceACUhd7eEBf6AXbUUOGtWZsbGXf1agU@mail.gmail.com"
      type="cite">
      <div>
        <div class="gmail_quote">On Wed, Dec 15, 2010 at 3:13 AM,
          Tihomir Surdilovic <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:tsurdilo@redhat.com">tsurdilo@redhat.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">Yep, I can reproduce what you are
            seeing. The order of files being read<br>
            in (alphabetical/lexical order..) matters in that the<br>
            DroolsCompilerAntTask will compile them one at a time:<br>
            <br>
            public class DroolsCompilerAntTask extends MatchingTask {<br>
            ....<br>
            private void createWithKnowledgeBuilder(AntClassLoader
            loader) throws<br>
            FileNotFoundException,<br>
            DroolsParserException,<br>
            IOException {<br>
            ...<br>
            <br>
            for ( int i = 0; i &lt; fileNames.length; i++ ) {<br>
            // compile rule file and add to the builder<br>
            compileAndAddFile( builder,<br>
            fileNames[i] );<br>
            }<br>
            <br>
            ...<br>
            }<br>
            }<br>
            <br>
            I'll take a look at the code and fix it up in the near
            future, but for<br>
            now what you can do is just as Mic said to put your declared
            types in<br>
            let's say drools.package file and make sure in your ant
            tasks that they<br>
            get read first. In my simple test this worked fine:<br>
            <br>
            &lt;target name="declaredtypes"&gt;<br>
            &lt;compiler srcdir="ant" tofile="antout/person.rules"&gt;<br>
            &lt;!-- classpathref="cheese.classpath" --&gt;<br>
            &lt;include name="*.package" /&gt;<br>
            &lt;/compiler&gt;<br>
            &lt;/target&gt;<br>
            <br>
            &lt;target name="rules" depends="declaredtypes"&gt;<br>
            &lt;compiler srcdir="ant" tofile="antout/person.rules"&gt;<br>
            &lt;!-- classpathref="cheese.classpath" --&gt;<br>
            &lt;include name="*.drl" /&gt;<br>
            &lt;include name="*.brl" /&gt;<br>
            &lt;include name="*.xml" /&gt;<br>
            &lt;include name="*.dslr" /&gt;<br>
            &lt;/compiler&gt;<br>
            &lt;/target&gt;<br>
            <br>
            since all declarations are in drools.package (or
            person.package or<br>
            whatever you want to call it), and making sure that "rules"
            target<br>
            depends on the "declaredtypes" target you can assure your
            declared types<br>
            get read first. Let me know if this helps.<br>
            <br>
            Thanks.<br>
            <div>
              <div class="h5"><br>
                On 12/14/10 7:23 AM, stanka wrote:<br>
                &gt; Here are more details:<br>
                &gt;<br>
                &gt; I have one drools resource Person.drl with the
                following content:<br>
                &gt;<br>
                &gt; package testpkg<br>
                &gt;<br>
                &gt; declare Person<br>
                &gt; &nbsp; &nbsp; &nbsp; name : String<br>
                &gt; end<br>
                &gt;<br>
                &gt; And another file PersonRules.drl in the same dir
                with the following content:<br>
                &gt; package testpkg<br>
                &gt;<br>
                &gt;<br>
                &gt; rule "Your First Rule"<br>
                &gt;<br>
                &gt; &nbsp; &nbsp; &nbsp; when<br>
                &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Person(name == "Bobi")<br>
                &gt; &nbsp; &nbsp; &nbsp; then<br>
                &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("hi bobi");<br>
                &gt;<br>
                &gt; end<br>
                &gt;<br>
                &gt; 1)Drools builder shows an error(Unable to resolve
                ObjectType person) on line<br>
                &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Person(name == "Bobi")<br>
                &gt; Is there a way to workarround the problem?<br>
                &gt; 2)I construct the knowledgebase using<br>
                &gt; <a moz-do-not-send="true"
href="http://grepcode.com/file/repository.jboss.com/maven2/org.drools/drools-ant/5.1.0.M1/org/drools/contrib/DroolsCompilerAntTask.java#DroolsCompilerAntTask.execute%28%29"
                  target="_blank">http://grepcode.com/file/repository.jboss.com/maven2/org.drools/drools-ant/5.1.0.M1/org/drools/contrib/DroolsCompilerAntTask.java#DroolsCompilerAntTask.execute%28%29</a><br>
                &gt; and &nbsp;bintype=PACKAGEBINTYPE= "knowledge" and
                binformat:PACKAGEBINFORMAT !=<br>
                &gt; package.<br>
                &gt; When I use PeronRules for name of the drools rules
                resource, the<br>
                &gt; knowledgebase is built, but if I rename the file
                from PeronRules to<br>
                &gt; 1PeronRules I get the following error:<br>
                &gt; Unable to resolve ObjectType 'Person' : [Rule
                name='Your First Rule']<br>
                &gt;<br>
                &gt; The problem with the order is, sometimes the rules
                filename may be loaded<br>
                &gt; after the type declaration which seems to be a
                problem, how can I deal with<br>
                &gt; this?<br>
                &gt;<br>
                <br>
              </div>
            </div>
            <div>
              <div class="h5">_______________________________________________<br>
                rules-dev mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
                <a moz-do-not-send="true"
                  href="https://lists.jboss.org/mailman/listinfo/rules-dev"
                  target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        Michael D Neale<br>
        home: <a moz-do-not-send="true"
          href="http://www.michaelneale.net">www.michaelneale.net</a><br>
        blog: <a moz-do-not-send="true"
          href="http://michaelneale.blogspot.com">michaelneale.blogspot.com</a><br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>