(cont. from drools-usage) kjar maven archetype templates to share?

53 views
Skip to first unread message

Matteo Mortari

unread,
Sep 9, 2014, 3:04:36 AM9/9/14
to drools-de...@googlegroups.com
Sorry Mark, you are right, it just started indeed as an usage topic and possibly evolved into a development one.

As per below, if you find this code helpful, I would be happy if you want to include it back into a module of drools; you guys let me know if I shall perform any specific action on github, or anything else further required / helpful in that direction, in case. 

Ciao
MM

On Mon, Sep 8, 2014 at 11:52 PM, Mark Proctor <mdpr...@gmail.com> wrote:
Please, if possible, continue this conversation in drools-development.

Mark
On 8 Sep 2014, at 22:42, Matteo Mortari <matteo....@gmail.com> wrote:

Hi Mario,
thanks, and yes actually I would be happy if you found something useful to include back into a module of drools.

Found your questions very interesting and in fact appears it's possible to make it parametric, thanks to the Velocity templates; so you can see:
  1. commit 4c57951 - adds parameter switch for inclusion of Eclipse-compatibility plugin in pom.xml
  2. commit eb371df - adds parameter switch for use of CEP features in example rules.drl and JUnit test
You will also notice the default value of the parameters are likely *the opposite* of what you may want to have in the Drools distribution, moving in the direction you suggested; but this is only because for my use-case made more sense this way. Possibly the non-CEP rule shall provide a different example... You guys let me know if I shall perform any specific action on github, or anything else further required / helpful in that direction, in case. 

My perspective on archetypes is that shall be kept to the minimum as possible, both in the dimensions of qty and params; the drools-examples-api will do the rest because indeed being examples. I think we can reasonably agree on this perspective and I'm just mentioning this because, on other OS projects, I found too many archetypes available to being with was somehow confusing. 

Thanks, Ciao
MM

On Monday, September 8, 2014 10:05:32 AM UTC+2, Mario Fusco wrote:
Hi Matteo,

you did a very nice and useful job there. If it's ok for you I believe we could include what you did in a module of drools and then provide this archetype natively. However to do so we will need to generalize it a bit. At the moment I see 2 things that I'd like to configure deriving from the fact that not everybody wants:

1. use Eclipse as IDE
2. have a CEP project

I don't know if it is possible to make your maven archetype parametric in order to have these features optional or if we will need to have totally different archetypes to achieve this. What do you think?

Thanks,
Mario



On Sun, Sep 7, 2014 at 3:46 PM, Matteo Mortari <matteo....@gmail.com> wrote:
Ciao,

tl;dr: I would like to share below this Maven archetype for a basic kjar template with CEP, JUnit 4 and Eclipse org.eclipse.m2e lifecycle-mapping plug-in settings. I would value feedback, but most importantly I would like to know from other users if:
  • are finding themselves having created their own archetype for kjar projects
  • possibly created an archetype using one of the drools/drools-examples-api as the starting base for running mvn archetype:create-from-project
  • any other suggestion
Thanks.

In details. The reason I created this archetype, as documented: I found myself creating many times a single-use, disposable, simple template project for testing new rules or new concepts in isolation. However the creation of this kind of project in Eclipse, usually required performing manually the following steps:
  • Create new Maven project with archetype quickstart
  • Set-up the new project's pom:
    • Change Java version to 1.6 or greater, by including the maven-compiler-plugin
    • Add Drools dependencies
    • Change JUnit dependencies to version 4
    • Add kie-maven-plugin
    • Add plug-in org.eclipse.m2e/lifecycle-mapping settings, to avoid Eclipse ERROR at the pom.xml line defining the kie-maven-plugin
    • Set packaging to 'kjar'
  • ( ALT + F5 in betweens )
  • Creation of an initial .drl file in src/main/resources
  • Creation of minimal kmodule.xml in src/main/resources/META-INF directory
  • Create a simple JUnit test for:
    • Creation of KieBase with STREAM option for CEP features
    • Creation of KieSession with pseudo-clock
    • Advance / Insert / Fire template
    • ... and other verification/output patterns
  • Include SLF4J and LOG4J binding for logging, including a log4j.properties file in src/test/resources
This archetype automate the above steps. https://github.com/tarilabs/kjar-cep-archetype

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/209bf94e-3fc1-46f8-abd5-c27c581f0ee1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/5ed51327-3559-4c82-be71-346354f19129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/j_IUyWvSj2c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/241BD92D-210C-4CFD-AE8B-174A7E6F7D51%40gmail.com.

For more options, visit https://groups.google.com/d/optout.

Mario Fusco

unread,
Sep 9, 2014, 3:28:39 AM9/9/14
to drools-de...@googlegroups.com
Matteo,

I still have to give a run to your archetype, but I think you really did a good job. Also the 2 additional parameters you introduced are ok (except for the fact that as you said we need the opposite default).

I would like to create a new module in the drools project and move what you did there. We have 2 options to achieve this: either you clone drools, create the module and send a pull request or I'll do it on my own "cannibalizing" your project. I'd prefer the 1st option even because in this way the git commit will be in your name. However if you don't have time to create that PR I could go with option 2 and we could find other ways (in docs?) to give you credit for your contribution.

Let me know how you want to proceed.

Mario

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-developm...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-development/CAHOoiEoQs%3D5VmD4e5umOKZ3JRakrVGGB8vwiW6o8ttgW3aCGqA%40mail.gmail.com.

Matteo Mortari

unread,
Sep 9, 2014, 5:48:58 AM9/9/14
to drools-de...@googlegroups.com
Mario,
Option 1 sounds feasible to me and I'd prefer option 1 too.

I will proceed as you suggested: clone drools, add a module with this archetype and the parameter defaults to suit - potentially there is also space for better ux by putting them as optional, with the default logic indeed inverted.

In case I will experience difficulties I will be in touch and if gets over-complicated we can evaluate alternative way to address this.

I will keep this thread posted, thanks,
Ciao,
MM
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.

Maciej Swiderski

unread,
Sep 9, 2014, 5:53:30 AM9/9/14
to drools-de...@googlegroups.com

guys, 

just a side note - what do you think about putting that in like kie-archtypes module instead of drools one? There will be more and more archetypes we could put in there so anyone who uses any of kie projects might make use of it - either it will be drools, jbpm, optaplanner, etc.

Wdyt?

Maciej
To unsubscribe from this group and stop receiving emails from it, send an email to drools-developm...@googlegroups.com.

To post to this group, send email to drools-de...@googlegroups.com.

Mario Fusco

unread,
Sep 9, 2014, 6:02:19 AM9/9/14
to drools-de...@googlegroups.com
Hi Maciej,

where are you suggesting to put this? Should we create a kie-archtypes module in -knowledge with the project developed by Matteo as its first submodule?

Mario

Maciej Swiderski

unread,
Sep 9, 2014, 6:05:36 AM9/9/14
to drools-de...@googlegroups.com
Mario,

yes, I believe -knowledge would be good place for such modules as then when working on them we'd make sure they rely only on api packages when it comes to code references. 

Maciej

Mario Fusco

unread,
Sep 9, 2014, 6:08:48 AM9/9/14
to drools-de...@googlegroups.com
Agreed.

Matteo, Maciej is suggesting to add your new module here https://github.com/droolsjbpm/droolsjbpm-knowledge that is the project containing KIE API (common to drools and jbpm). What do you think? Can you do this?

Mario

Matteo Mortari

unread,
Sep 9, 2014, 7:41:38 AM9/9/14
to drools-de...@googlegroups.com
Ack. Alright I will proceed this way, will be in touch if I experience any problem.

Thanks, Ciao,
MM

guys, 

To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

Matteo Mortari

unread,
Sep 14, 2014, 6:57:53 AM9/14/14
to drools-de...@googlegroups.com
Ciao, as agreed I've raised PR with archetype with property switch defaults inverted. You can see it DROOLS-599, signed CLA, linked on JIRA the github PR. Is my first time raising a PR with a code submit (earlier PR just doc corrections still in the queue) so can you kindly let me know if I missed any steps or details, please?

To be noted:
  • the non-CEP rule is quite "dumb", because it's basically a counter-example of the CEP rule. You let me know if I shall use another rule example instead.
  • apparently it's not possible to put maven archetype property as optional, so indeed this archetype has the required properties, but with defaults of: non-CEP, non-Eclipse
  • I've improved the maven archetype property management in the Velocity template according to some JBoss 'guideline' I found lately.
  • The test of the archetype is triggered via 'mvn integration-test', standard maven. Besides testing I've also tried it out manually.
Hope this helps, kindly let me know if this addresses fully what was mentioned in this discussion, or I missed anything, please?
Thanks,
Ciao,
MM

Mario Fusco

unread,
Sep 22, 2014, 12:36:11 PM9/22/14
to drools-de...@googlegroups.com
I just merged (with some minor rewording and improvements) what Matteo did. Great job Matteo, well done!

Now we have a module for maven archetypes containing a first archetype that generates a basic drools project: https://github.com/droolsjbpm/droolsjbpm-knowledge/tree/master/kie-archetypes

I think we could add more archetypes there (jbpm?) in a near future.

Mario

To unsubscribe from this group and stop receiving emails from it, send an email to drools-developm...@googlegroups.com.

To post to this group, send email to drools-de...@googlegroups.com.

Maciej Swiderski

unread,
Sep 23, 2014, 5:33:13 AM9/23/14
to drools-de...@googlegroups.com
Great news. 

I’ll need to find some time to update some of the archetypes i have in my repos and push them up to that module.

Maciej

Matteo Mortari

unread,
Sep 23, 2014, 2:48:52 PM9/23/14
to drools-de...@googlegroups.com
Thanks Mario, I'm happy seeing the PR being merged !
Be able to discover-reproduce-submit bugs is good; but getting a chance to submit even a small contribution like this one, is one of the reasons making open source projects awesome.

Ciao,
MM

guys, 


--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsubscribe@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsubscribe@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsubscribe@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Drools Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-development+unsub...@googlegroups.com.
To post to this group, send email to drools-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages