Check syntax errors in rule file of Drools - drools

I am new to Drools Guvnor and have set up a basic rool framework using the same. I just want to know if current Drool file is correct or not.
As of now, I have no way except running it end to end. Is there any to check compilation issues immediately?
EDIT:
When we have syntax errors, for example, 'string.Contains' instead of 'string.contains' validate/verify pass successfully and so does 'Build Package' option. Let me know If I am missing anything.
Apart from this, I don't have much idea about QA section (in fact, we haven't put any test there).
Thanks,

In Guvnor you can
1) Validate individual rules by Source -> Validate menu, (can be seen when rule is open)
2) Define and run a test scenario using QA section. Guvnor manual has a nice section describing its use.
3) Use Validate Configuration and Build Package buttons on Edit tab of your package. This will compile all rules in your package.
I suggest you use use validate menu on every edit to a rule, and write test scenarios that cover 100% of your rules.

Related

Eclipse messing up excluded filter?

Eclipse is setting constantly excluded filter in build path config to **, which causes resources to be excluded from deployment. Anyone aware of this issue, and how this can be prevented? Any thoughts?
How i said in the comments of your question i did not verify any of both approaches and i only think/hope they could lead to a solution rather than i know it exactly.
First approach:
Since you handle the entire process of compilation and packaging via Maven i assume you collect required ressources with Maven only (and that if you filter out certain ressources you would do that with Maven only). In that case i would try to disable all of the eclipse filters to be included into the build path - which i would expect as the behaviour if you disable this option:
(i once experienced eclipse added a "*"Filter to my Type Filters hence i wasnt able to find anything on typesearch Ctrl+Shift+T anymore - so my hope is a similar behaviour when it comes to your filter-all-resources filter"
Second approach
Actually i think that this approach will only affect the view rather than the build/ deployment process but hey its eclipse - you just never know so i guess its worth a try:
In the following screen you should see any filters known by eclipse - i assume you will see the . Filter there as well and be able to unselect it:
I guess its worth a try - good luck ;)

.ant-targets-build.xml puts eclipse project into error

I am using the most excellent ant/bin/complete-ant-cmd.pl for bash completion of ant targets and it caches its results in a file called .ant-targets-build.xml. The problem is, in my eclipse project, eclipse is a little overaggressive validating everything it believes is actually XML (which .ant-targets-build.xml isn't...its just the raw targets separated by newlines).
How do I get eclipse to relax its restrictions and treat .ant-targets-build.xml as NOT an xml file...just text or something.
Project->Properties
Check Enable project specific settings.
Click ellipsis next to XML Validator
Click on Exclude Group
Click on Add Rule
Follow wizard and create File exclusion.
One of the most annoying "features" of this dialog is that you cannot edit existing rules. If you make a mistake you will need to delete that rule and recreate it from scratch.
BTW, in your case it may be preferable to create a global workspace rule ( I usually like to keep special cases with the project ).
In any case after you finished with rule creation, right-click on a project with warnings and choose Validate. This will clear these warnings
If you decided to edit validation preferences in project and not in workspace, then add project-name/.setting/org.eclipse.wst.validation.prefs file to source control.

How to apply an external formatting script to files in eclipse?

I'd like to run an external beautifier over my code that's open and replace the contents of the document with the output. Is there a plugin or something I can exploit to do this? I thought it would be a no-brainer under the formatter preferences, but it looks like you can only use internal templates.
One solution is the following:
Create an ant builder on your project. See this article about how to do that. The important things you should know after you read the article:
Add a new ant builder by right click on project and properties. See the implicit variables your ant script will have. The variables will contain one or more resource name and path. So be prepared for collections.
Filter the resouces in the "Build
options" tab. This is important,
since launching a JVM (or a new task
inside IDE JVM) for the change of
every file (filetype) is not so
fast. So filter resources to be
processed like this:
The third thing is to ask eclipse to refresh the resource after the script is run. Like this:
Set the target of the ant script to be run as automatic build (third option). You can set all the four anyway it will be ok:
Write your script. You will find the log of the ant script in console, and you may redirect the log into a file as well. You can see the option on the second picture. Start your script with an echoproperties tag to see what your script gets from eclipse.
I used such builders a lot, it works like it should. I like them. Good luck. Consider accepting your answers, 42 % is not too much :D

Eclipse: On Save execute a program

I have recently come across the LESS Leaner CSS a template engine for CSS based on ruby. The idea sounded neat, but in practice we need to compile the program to get CSS. This is cumbersome as we make too many changes while working on CSS and for every edit we don't want to compile.
In Eclipse, there are "Save-Actions" but it handles only formatting changes.
Is there a way on saving the file in Eclipse, to call or trigger the compilation?
Its easy to do this in Vi or Emacs.
I think all you need is to define a custom Builder for your project. That way, you can run a program or an ant script whenever certain files change.
Right click on the project -> Properties -> Builders -> New
While the Builders are a good solution, keep in mind they only work when a build is issued - either using auto-build or using a manual build which is invoked, well, manually. If you are looking for something that will operate after a save, regardless of the auto-build state you will need to write a plugin which listens to resource changes in Eclipse.
You do that by creating a workspace change listener and installing it like that:
ResourcesPlugin.getWorkspace().addResourceChangeListener(
..., IResourceChangeEvent.POST_CHANGE);
I'm sure you can take it from here :-)

Excluding/Disabling Validation in Eclipse

I have the (mis)fortune of having a large project source-base in which I am working primarily on PHP and JavaScript. I have to have the full project area as the project root in Eclipse, but unfortunately this includes several directories that drive the validation built into WST/DLTK/etc. nuts.
I have tried disabling all validators in the project properties. I have gone into the validators one at a time and added rules to the "Exclude Group" set to exclude the specific folders. I have removed the folders from the PHP build path in the project properties. And yet, my Problems view/tab is still littered with thousands of red flags that stem mostly from a folder that we use to keep copies of external elements (Apache, PHP, etc.). You know, typical "have a copy of the specific versions we currently use" sort of thing.
The signal-to-noise ratio is so bad that I'm unable to use the view at all, which is a shame. If I'm not going to have the benefits of the IDE, I might as well be using vim for this (I use it for other stuff, but for this codebase a good IDE is a better choice, providing I can get it to work). It seems to me that it would be an obvious feature to be able to right-click a folder in a project and select "Exclude from Validation", but alas there is no such feature. Is there another way to get the validators (PHP, HTML, etc.) to ignore the folders I need ignored?
Tried solution;
Right click project
Select properties
Select validation
Check Enable Project specific settings
On the XML Validator row, click the '...' button
Select Exclude Gruop
Click Add rule
Select 'Folder or file name'
Click Next
Select files or folder which are not validated.
Click Finish
Click OK
Click OK
This solved my problem. Because eclipse validation gives error for generated GWT files.
Best regards.
I came upon this question while looking for the same answer. I will list the steps I did here and hopefully it will help someone in the future.
I am using Eclipse 4.1 and I do the following to exclude validation for specific xml files. I am sure if you configure the different validators it will work for other files as well.
Go to Preferences -> Validation
Find the Validator you wish to change and select settings (not all of the validators have settings, hopefully yours do).
In the settings you can add an Exclude Group where you can add a rule to specify to exclude the validator for specific extensions, folder or file name, project nature, facet or content type.
I have Eclipse for PHP Developers and I was dealing with the same issue.
In addition tot he excellent answers above, I have one more suggestion.
My first recommendation is not to use Aptana unless you actually want those validators (as they are nearly impossible to turn off from my experience).
Beyond that, go to File -> Properties -> Builders, and deselect "Validation" and "Script Builder" and "JavaScript Validator".
So far it's helped speed up some operations tremendously.
I also recommend disabling "Automatic Build". Because you're using PHP, the odds that you actually need it to build anything if you don't want validation is slim.
In the main menu, go to Project and uncheck "Build Automatically". You will want to build your project every now and then by right clicking on the project and selecting "Build Project".
All the above steps have helped me get the basic editor, which is exactly what I wanted.
I used to exclude resources from validation via project specific Exclude Group (as the most answer here suggests). But in case anyone is still having problems with disabling validation for a specified folder in 2014 - just mark the folder resource as Derived:
This should disable validation for that folder.
If you are using EGIT you might also want to disable automatic inclusion of derived resources in .gitignore:
It is not really possible to select a directory, at least under Windows.
After having pressed Preferences->Validation->Settings->Add Exclude Group->Add Rule->Folder or filename->Browse Folder->(selecting some directory)->[OK]
The "Browse for folder" dialog is being closed, with the "File or folder" field staying empty.
I had the same problem with the web app i'm developping.
I ended up disabling automatic build, and building once a day (Project->Build automatically), that way i still get the benefits of code completion from libraries, while speeding up the program on older computers.
I found in the project properties there is a Builders category. In the list of builders I had a JavaScript Builder. I deselected this builder and all my annoying javascript validation woes went away.
this worked for me:
Properties > Builders section and unchecking the corresponding box. https://bugs.eclipse.org/bugs/show_bug.cgi?id=317833
seems to be a bug in some versions of eclipse.
There are more gloabal validation parameters. You can suspend all validation (or only the ones you don't need) by going to:
Window > Preferences > Validation.
Here, check the box "Suspend all validators".
Alternatively, uncheck the validators you don't need from the list below.
A full build will be requested which might take some time. But Eclipse will run a lot faster afterwards [But without validation of course]
http://www.flickr.com/photos/jesuspresley/5094048124/
Solution.
Go configure what's displayed in the Problems View like lothar proposed, create new custom filter and in "Scope" area choose "On working set". Now press the button right below this option to configure what working set would it be: in working set selection pop-up hit the "New" button and mark all your project files EXCEPT those you want to exclude from validation. You might want to save this working set under convenient name, like "No_Validation_Set".
Summary:
1) working set excluding problematic files.
2) custom Problems View filter to operate on this set.
Issues:
when adding new files to project you need to update your working set, so they are validated too.
When I excluded files from validation for the project, my setting didn't seem to be recognised until I restarted Eclipse and cleaned the project.