Bug 724599 (BRMS-516) - Package compilation should present an error or warning when a file inside a directory does not declare itself to be in the same package as the other resources in that directory
Summary: Package compilation should present an error or warning when a file inside a d...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: BRMS-516
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: 5.1.0 GA
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: 5.1.0.PostGA
Assignee: Tihomir Surdilovic
QA Contact:
URL: http://jira.jboss.org/jira/browse/BRM...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-12-20 16:23 UTC by Alessandro Lazarotti
Modified: 2010-12-21 07:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Fedora 12, JDK 1.6 sun/oracle
Last Closed: 2010-12-21 07:38:26 UTC
Type: Feature Request


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker BRMS-516 0 None None None Never

Description Alessandro Lazarotti 2010-12-20 16:23:40 UTC
Help Desk Ticket Reference: https://c.na7.visual.force.com/apex/Case_View?id=500A0000005eneY&sfdc.override=1
securitylevel_name: Public

This is a request for an error/warning mechanism in the compiler task. This case presents itself when a person defines a package and makes a unintentional mistake by not defining all the files which are intended to be in the package to be part of the package. If familiarity with drools is low this issue can cause a lot of frustration from not being able to find the issue.

If a package is composed of more than one rules source file (i.e a drl + xls + rf) there is an unreported error where the files do not all declare themselves to be of the same package. The compiler will only build the package to include some of the files.

Given 3 files in the same directory to be compiled using the drools-ant task

org.drools.contrib.DroolsCompilerAntTask

process.rf [package rsarules.quote]
start-process.drl [package rssrules.quote]
quote.xls [package rsarules.quote]

using

<target name="buildPackage" >
<compiler srcdir="${basedir}/src/test/resources/rules"
tofile="${basedir}/src/test/resources/rsa.rules.pkg"
classpathref="rsa.classpath"
binformat="package" >
<include name="*.xls"/>
<include name="*.drl"/>
<include name="*.rf"/>
</compiler>
</target>

In the above example if start-process.drl was read first the resultant package would only contain the start-process.drl rule. If on the other hand the compiler was to read any of the other two files first the package created would not contain start-process.drl. In both cases the resultant rules application would not function as was intended. This is clearly an error but the compiler should flag this.

Comment 1 Alessandro Lazarotti 2010-12-20 16:38:35 UTC
Link: Added: This issue is related to JBRULES-2840


Comment 2 Tihomir Surdilovic 2010-12-21 06:48:32 UTC
In the case where rule resources in the srcdir are in multiple packages and you specify binformat="package", each package will be serialized independently to the destination file and thus override the previous serialized package.
I added logging to the DroolsCompilerAntTask which you can invoke by adding:

1. verbose="true" attribute to the compiler task, for example:
 <compiler srcdir="${basedir}/src/test/resources/rules"
tofile="${basedir}/src/test/resources/rsa.rules.pkg"
classpathref="rsa.classpath"
binformat="package" verbose="true">

2. adding the ant recorder task to the target containing the compiler task, so for example:

<target name="rules">
<record name="build.log"/>
<compiler srcdir="${basedir}/src/test/resources/rules" verbose="true" ..../>
...
</target>

The log file will contain information about each package and its rules. Also it warns users when each individual package is serialized and that it can overwrite previous serialized packages. The sample output of the log file can look like:

 [compiler] ** Content of package: com.sample.other
 [compiler] Rule name: Your First Rule
 [compiler] ** Content of package: com.sample
 [compiler] Rule name: Your Second Rule
 [compiler] ** Serializing package [com.sample.other] to destination file. **** THIS WILL OVERRIDE ANY PREVIOUSLY SERIALIZAED PACKAGE ****
 [compiler] ** Serializing package [com.sample] to destination file. **** THIS WILL OVERRIDE ANY PREVIOUSLY SERIALIZAED PACKAGE **** 


Note You need to log in before you can comment on or make changes to this bug.