<!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.
<div>There is no clever resolving across multiple files (not sure
if that is a valid feature request or not). <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"><<a
moz-do-not-send="true" href="mailto:tsurdilo@redhat.com">tsurdilo@redhat.com</a>></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 < 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>
<target name="declaredtypes"><br>
<compiler srcdir="ant" tofile="antout/person.rules"><br>
<!-- classpathref="cheese.classpath" --><br>
<include name="*.package" /><br>
</compiler><br>
</target><br>
<br>
<target name="rules" depends="declaredtypes"><br>
<compiler srcdir="ant" tofile="antout/person.rules"><br>
<!-- classpathref="cheese.classpath" --><br>
<include name="*.drl" /><br>
<include name="*.brl" /><br>
<include name="*.xml" /><br>
<include name="*.dslr" /><br>
</compiler><br>
</target><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>
> Here are more details:<br>
><br>
> I have one drools resource Person.drl with the
following content:<br>
><br>
> package testpkg<br>
><br>
> declare Person<br>
> name : String<br>
> end<br>
><br>
> And another file PersonRules.drl in the same dir
with the following content:<br>
> package testpkg<br>
><br>
><br>
> rule "Your First Rule"<br>
><br>
> when<br>
> Person(name == "Bobi")<br>
> then<br>
> System.out.println("hi bobi");<br>
><br>
> end<br>
><br>
> 1)Drools builder shows an error(Unable to resolve
ObjectType person) on line<br>
> Person(name == "Bobi")<br>
> Is there a way to workarround the problem?<br>
> 2)I construct the knowledgebase using<br>
> <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>
> and bintype=PACKAGEBINTYPE= "knowledge" and
binformat:PACKAGEBINFORMAT !=<br>
> package.<br>
> When I use PeronRules for name of the drools rules
resource, the<br>
> knowledgebase is built, but if I rename the file
from PeronRules to<br>
> 1PeronRules I get the following error:<br>
> Unable to resolve ObjectType 'Person' : [Rule
name='Your First Rule']<br>
><br>
> The problem with the order is, sometimes the rules
filename may be loaded<br>
> after the type declaration which seems to be a
problem, how can I deal with<br>
> this?<br>
><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>