kjar maven archetype templates to share?

178 views
Skip to first unread message

Matteo Mortari

unread,
Sep 7, 2014, 9:46:48 AM9/7/14
to drools...@googlegroups.com
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

Mario Fusco

unread,
Sep 8, 2014, 4:05:32 AM9/8/14
to drools...@googlegroups.com
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



--
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.

Matteo Mortari

unread,
Sep 8, 2014, 5:42:26 PM9/8/14
to drools...@googlegroups.com
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

Mark Proctor

unread,
Sep 8, 2014, 5:53:07 PM9/8/14
to drools...@googlegroups.com
Please, if possible, continue this conversation in drools-development.

Mark
Reply all
Reply to author
Forward
0 new messages