2
votes

I am new to Drools and to Guvnor. We have created DRL file and loaded in Guvnor and we got the package built. It has resulted in a .pkg file. We download this .pkg file from Guvnor and use it for our different projects. Now I am trying to see things inside the .pkg file, but I am not sure how to open this.

2
Your Drools version is...? What exactly are you trying to "see" in the PKG file, and why? It doesn't contain anything that isn't in your DRL file, but getting all of that is no easy task.laune

2 Answers

1
votes

There is no tool (that I'm aware of) for opening a Drools pkg file and inspect its content. Depending on what you are trying to achieve, a possible solution would be to programatically create a Kiebase (or kbase) from that pkg and programatically inspect its content.

By the way, what are you trying to find inside that file?

Hope it helps,

1
votes

The following code examines a knowledge base and will write out the names of all the packages that were loaded into it and the names of the rules in those packages. There's probably a bit more info that can be extracted, but I have never found the need. The only thing you won't get is the source code of the rules. But going by your explanation, that is available in Guvnor.

/**
 * Return a string containing the packages used to build the knowledge base.
 */
public static String knowledgeBaseDetails(KieBase kbase) {
    if (kbase == null) {
        return "Knowledge Base is null.";
    } else {
        StringBuilder sb = new StringBuilder(
                "Knowledge base built from the following packages:");
        Collection<KiePackage> packages = kbase
                .getKiePackages();
        for (KiePackage kp : packages) {
            sb.append("\n    Package: [" + kp.getName() + "]");
            for (Rule rule : kp.getRules()) {
                sb.append("\n        Rule: [" + rule.getName() + "]");
            }
        }
        return sb.toString();
    }
}

It's almost the same for Drools 5 and 6. Generally for the earlier versions of Drools, just change Kie to Knowledge.