Any package scoped things really should go in the .package file IIRC. <div>There is no clever resolving across multiple files (not sure if that is a valid feature request or not). <br><br><div class="gmail_quote">On Wed, Dec 15, 2010 at 3:13 AM, Tihomir Surdilovic <span dir="ltr">&lt;<a href="mailto:tsurdilo@redhat.com">tsurdilo@redhat.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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&#39;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&#39;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=&quot;declaredtypes&quot;&gt;<br>
&lt;compiler srcdir=&quot;ant&quot; tofile=&quot;antout/person.rules&quot;&gt;<br>
&lt;!-- classpathref=&quot;cheese.classpath&quot; --&gt;<br>
&lt;include name=&quot;*.package&quot; /&gt;<br>
&lt;/compiler&gt;<br>
&lt;/target&gt;<br>
<br>
&lt;target name=&quot;rules&quot; depends=&quot;declaredtypes&quot;&gt;<br>
&lt;compiler srcdir=&quot;ant&quot; tofile=&quot;antout/person.rules&quot;&gt;<br>
&lt;!-- classpathref=&quot;cheese.classpath&quot; --&gt;<br>
&lt;include name=&quot;*.drl&quot; /&gt;<br>
&lt;include name=&quot;*.brl&quot; /&gt;<br>
&lt;include name=&quot;*.xml&quot; /&gt;<br>
&lt;include name=&quot;*.dslr&quot; /&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 &quot;rules&quot; target<br>
depends on the &quot;declaredtypes&quot; target you can assure your declared types<br>
get read first. Let me know if this helps.<br>
<br>
Thanks.<br>
<div><div></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;       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 &quot;Your First Rule&quot;<br>
&gt;<br>
&gt;       when<br>
&gt;               Person(name == &quot;Bobi&quot;)<br>
&gt;       then<br>
&gt;               System.out.println(&quot;hi bobi&quot;);<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt; 1)Drools builder shows an error(Unable to resolve ObjectType person) on line<br>
&gt;               Person(name == &quot;Bobi&quot;)<br>
&gt; Is there a way to workarround the problem?<br>
&gt; 2)I construct the knowledgebase using<br>
&gt; <a 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  bintype=PACKAGEBINTYPE= &quot;knowledge&quot; 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 &#39;Person&#39; : [Rule name=&#39;Your First Rule&#39;]<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></div><div class="h5">_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a 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 href="http://www.michaelneale.net">www.michaelneale.net</a><br>blog: <a href="http://michaelneale.blogspot.com">michaelneale.blogspot.com</a><br>

</div>