advertisement
Chapter 4. Maven Archetype - Drools5
Integration Helper Archetype
Introduction
It is possible to automatically generated a basic Maven project that integrate all the Drools5-Integration-
Helper features. To do so, a Maven archetype is provided. This archetype provides the following stuff:
• Maven 2 project, with references to the required libraries and plugin.
• Example of Annotated interfaces.
• Example of Annotated classes.
• Using Field oriented annotations.
• Using PreCondition oriented annotations.
• Example of JUnit for the two previous entries.
Presentation of what is an archetype is out of the scope of this document. Please refer to Maven Archetype plugin [http://maven.apache.org/plugins/maven-archetype-plugin/] for more information on the archetype plugin.
Usage
The creation of the Maven 2 project is based on the maven-archetype-plugin. It is possible to use the following call, from a terminal: mvn \
archetype:generate \
-DarchetypeGroupId=org.boretti.drools.integration \
-DarchetypeArtifactId=drools5-integration-helper-archetype \
-DarchetypeVersion=1.3.0
The system will then ask you several questions (like package name for example). You must reply to the various questions and then a default Maven project, based on the archetype, will be created. This archetype is directly usable.
Example of usage
For example, it is possible to use the previous command:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
40
Maven Archetype - Drools5
Integration Helper Archetype
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[WARNING] No archetype repository found. Falling back to central repository (http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Define value for groupId: :
Here input grpid
Define value for artifactId: :
Here input artifactid
Define value for version: 1.0-SNAPSHOT: :
Here input 1.0-SNAPSHOT
Define value for package: grpid: :
Here input package
Confirm properties configuration: groupId: grpid artifactId: artifactid version: 1.0-SNAPSHOT package: package
Y: :
Finally confirm the data you input
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25 seconds
[INFO] Finished at: Sun Nov 15 12:46:56 CET 2009
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------
The resulting folder will be named artifactid. It will contains a single pom.xml file. A src folder will be created. It will contains the main and test folder. You will then have a drools folder for the drools file, a java folder for the java source.
41
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Related manuals
advertisement
Table of contents
- 7 Presentation
- 7 License
- 19 Drools5 Integration Helper
- 20 Installation
- 21 Download
- 21 All in one download
- 21 Per files download
- 21 Installation in local maven repository
- 21 Installation in remote maven repository
- 22 Introduction
- 23 Dependencies
- 23 DroolsInterface
- 23 Interface(s)
- 24 Method(s)
- 24 Session
- 25 Activation Group
- 25 Setter Methods
- 25 Asynchronous methods
- 26 Parameter(s)
- 26 Return value
- 26 Generic
- 26 Future
- 27 Primitive types
- 27 DroolsClass
- 27 Class(s)
- 28 Field(s)
- 29 Constructor(s)
- 29 Multiple constructors usage.
- 29 Multiple constructors without Drools override
- 30 Multiple constructors with Drools override.
- 30 How to avoid the unnecessary construction of the rule data
- 30 Drools Execution
- 31 DroolsCondition
- 31 Idea
- 31 Condition definition
- 31 PreCondition
- 31 PostCondition
- 32 Exception throwing
- 32 Static methods
- 32 DroolsProvider
- 32 Getting concrete instance from interface
- 33 Getting RuleBase from interface or class
- 33 Getting RuleBase from type and resource
- 33 Running pre-condition
- 34 Running post-condition
- 34 Spring Integration
- 34 Exceptions
- 35 Logging
- 35 Summaries
- 35 Annotations
- 36 Enumerations
- 36 Classes
- 36 Interfaces
- 36 Errors and Exceptions
- 37 Performance
- 38 Introduction
- 38 Drools Packaging
- 39 Validation Drools Goals
- 39 drools-copy-validate
- 39 configuration
- 40 Notes
- 40 drools-copy-validate-test
- 40 configuration
- 40 Notes
- 40 Compilation Drools Goals
- 41 drools-compile
- 41 configuration
- 41 Notes
- 41 drools-compile-test
- 42 configuration
- 42 Notes
- 42 PostProcessing Drools Goals
- 42 drools-postprocessor
- 42 configuration
- 43 Notes
- 43 drools-postprocessor-test
- 43 configuration
- 43 Notes
- 43 Report Goal
- 43 drools-report
- 44 configuration
- 44 Results
- 44 Logging of maven plugin execution
- 46 Introduction
- 46 Usage
- 46 Example of usage
- 48 Presentation
- 48 The problem
- 48 Examples using interface
- 48 General idea
- 48 Implementation
- 48 Java Source
- 48 Customer.java
- 50 CustomerEvaluator.java
- 50 Drools file
- 51 Maven integration
- 52 Usage
- 52 Examples using class
- 52 General idea
- 53 Implementation
- 53 Java Source
- 55 Drools file
- 56 Maven integration
- 57 Usage
- 57 Examples using condition
- 57 General idea
- 57 Implementation
- 57 Java Source
- 57 Customer class
- 59 Error class
- 59 Drools file
- 60 Maven integration
- 61 Usage