Drools在ant构建期间无法解析ObjectType

时间:2016-02-11 18:21:12

标签: java ant build drools

我正在使用DroolsCompilerAntTask进行ant构建,我在构建过程中遇到以下错误

rules:
 [compiler] Unable to resolve ObjectType 'Result' : [Rule name='Test']

对于我有

的规则文件
package rules

import com.drools.info.*; 

dialect "java"

rule "Test"   
    when
        $r:Result(total == Result.ONE  )
    then
        System.out.println( "Test Complete." );
end

的build.xml

<!-- rule -->
 <path id="drools.path" >
    <fileset dir="${basedir}/libs">
        <include name="*.jar"/>
    </fileset>  
    <pathelement location="${basedir}/build/rules" /> <- this is my path to compiled class files. If I exclude this line I got the above error. If I include this line then I got the (Access is denied) error. Either way is errored out. Are there permanent solution to this?

 </path>

 <path id="compile.classpath"> 
 </path>

 <taskdef name="compiler" classname="org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.path" />

  <target name="rules" >
    <compiler
      binformat="package" 
      srcdir="${basedir}/src/rules"
      tofile="${basedir}/build"
      classpathref="compile.classpath" >
      <include name="*.drl" />
      <include name="*.brl" />
      <include name="*.xml" />
      <include name="*.dslr" />
    </compiler>
  </target>

其中Result是com.drool.info.Result中的类对象 我认为当我编译规则时,我没有添加类文件以及规则可能导致这个?或者有没有办法告诉蚂蚁规则编译器类文件是否相关?如果这是问题,我该如何解决它?

1 个答案:

答案 0 :(得分:0)

编译.drl文件类似于在几个方面编译Java文件。最重要的是,.drl中使用的所有类必须与.drl位于同一个包中,否则必须导入它们。但是,导入只是解析名称空间 - 要获取类的结构,必须提供类的.class文件。编译器还能知道字段引用的含义吗?

确保.class文件或包含它们的.jar文件位于类路径中。

相关问题