mvn archetype:generate \ -DarchetypeArtifactId=jboss-as-subsystem \ -DarchetypeGroupId=org.jboss.as.archetypes \ -DarchetypeVersion=7.1.1.Final \ -DarchetypeRepository=http://repository.jboss.org/nexus/content/groups/public
To make your life easier we have provided a maven archetype which will create a skeleton project for implementing subsystems.
mvn archetype:generate \ -DarchetypeArtifactId=jboss-as-subsystem \ -DarchetypeGroupId=org.jboss.as.archetypes \ -DarchetypeVersion=7.1.1.Final \ -DarchetypeRepository=http://repository.jboss.org/nexus/content/groups/public
Maven will download the archetype and it's dependencies, and ask you some questions:
$ mvn archetype:generate \ -DarchetypeArtifactId=jboss-as-subsystem \ -DarchetypeGroupId=org.jboss.as.archetypes \ -DarchetypeVersion=7.1.1.Final \ -DarchetypeRepository=http://repository.jboss.org/nexus/content/groups/public [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] ......... Define value for property 'groupId': : com.acme.corp Define value for property 'artifactId': : acme-subsystem Define value for property 'version': 1.0-SNAPSHOT: : Define value for property 'package': com.acme.corp: : com.acme.corp.tracker Define value for property 'module': : com.acme.corp.tracker [INFO] Using property: name = JBoss AS 7 subsystem project Confirm properties configuration: groupId: com.acme.corp artifactId: acme-subsystem version: 1.0-SNAPSHOT package: com.acme.corp.tracker module: com.acme.corp.tracker name: JBoss AS 7 subsystem project Y: : Y [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:42.563s [INFO] Finished at: Fri Jul 08 14:30:09 BST 2011 [INFO] Final Memory: 7M/81M [INFO] ------------------------------------------------------------------------ $
|
Instruction |
1 |
Enter the groupId you wish to use |
2 |
Enter the artifactId you wish to use |
3 |
Enter the version you wish to use, or just hit Enter if you wish to accept the default 1.0-SNAPSHOT |
4 |
Enter the java package you wish to use, or just hit Enter if you wish to accept the default (which is copied from groupId ). |
5 |
Enter the module name you wish to use for your extension. |
6 |
Finally, if you are happy with your choices, hit Enter and Maven will generate the project for you. |
You can also do this in Eclipse, see AS7:Creating your own application for more details. We now have a skeleton project that you can use to implement a subsystem. Import the acme-subsystem project into your favourite IDE. A nice side-effect of running this in the IDE is that you can see the javadoc of JBoss AS 7 classes and interfaces imported by the skeleton code. If you do a mvn install in the project it will work if we plug it into JBoss AS 7, but before doing that we will change it to do something more useful.
The rest of this section modifies the skeleton project created by the archetype to do something more useful, and the full code can be found in acme-subsystem.zip.
If you do a mvn install in the created project, you will see some tests being run
$mvn install [INFO] Scanning for projects... [...] [INFO] Surefire report directory: /Users/kabir/sourcecontrol/temp/archetype-test/acme-subsystem/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.acme.corp.tracker.extension.SubsystemBaseParsingTestCase Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.424 sec Running com.acme.corp.tracker.extension.SubsystemParsingTestCase Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.074 sec Results : Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 [...]
We will talk about these later in the Testing the parsers section.
NOTE!!!! There is a problem with the 7.1.1.Final version of the artifact, so when running the tests you will see errors like these:
testSubsystem(com.acme.corp.tracker.extension.SubsystemBaseParsingTestCase): Can't find bundle for base name aaa.extension.LocalDescriptions, locale en_US
The fix for this is to move src/main/resources/com/acme/corp/tracker/subsystem/extension/LocalDescriptions.properties to src/main/resources/com/acme/corp/tracker/extension/LocalDescriptions.properties substituting com/acme/corp/tracker with the path for what you entered as the package name.