Recently I stumbled upon JBoss Forge, it's a great way to build applications in a fast paced way.
It uses the same old command-line interface which is one of the most loved feature in Unix environment with auto complete commands and options.
We should all ask a question to ourselves that as developers do we need all fancy UI to do stuff. Eclipse is a great platform but when we start overusing it then we end up in lot of clicks and time is not utilized efficiently to do project setups and adding project dependencies.
JBoss Forge is at rescue for all those people who feel that they get stuck up with fancy UI options which are more needed for end users and not developers.
So let's get started with Forge and start with creating a new project.
Forge comes along with JBoss tools and can be downloaded from eclipse market place and as a default with Jboss developer studio.
After Installation go to Show View -> Forge Console.
Once you are done then we can start the magic of Forge and start with the creation of new project.
It uses the same old command-line interface which is one of the most loved feature in Unix environment with auto complete commands and options.
We should all ask a question to ourselves that as developers do we need all fancy UI to do stuff. Eclipse is a great platform but when we start overusing it then we end up in lot of clicks and time is not utilized efficiently to do project setups and adding project dependencies.
JBoss Forge is at rescue for all those people who feel that they get stuck up with fancy UI options which are more needed for end users and not developers.
So let's get started with Forge and start with creating a new project.
Forge comes along with JBoss tools and can be downloaded from eclipse market place and as a default with Jboss developer studio.
After Installation go to Show View -> Forge Console.
Once you are done then we can start the magic of Forge and start with the creation of new project.
- One the Forge console type the following command:
new-project --named trackr
This would create a new project named trackr and also add pom.xml file to it. - For this application we would be using the default setup of Java EE applications that's JSF, CDI, EJB and JPA for that we would use the scaffold command
scaffold setup
Use the default options and the Java EE version you want to use. Once this is done check your pom.xml and the changes that are made to that which you would have to make manually otherwise. - Once the scaffold is done we would want to setup our persistence provider for that use the command
persistence setup --provider and press tab then you would be able to see the options available
HIBERNATE OPENJPA ECLIPSELINK INFINISPAN
choose HIBERNATE and then give another configuration parameter --container and press tab to see the available options there and choose JBOSS_AS7 as the container. The final command that you would execute would be
persistence setup --provider HIBERNATE --container JBOSS_AS7
This would add persistence.xml to your project. - Now the project setup is done and we can start creating the entities. Use the command
entity --named User
It would ask for some self explanatory options and once your provide that it would create and entity for you User.java and you would be in context of that entry post that command so that you can add fields and relationships to that entry.
Isn't that awesome!! see the commands that follow and you would be amazed how easy it makes it for you. Start planning for the time you are going to save when you start using it. - Entity without fields is incomplete and now when we are in the context of that entity we would add fields to that. Type the command "field" and press tab to see the options you have. Lets start with a String field named name.
field string --named name - So with the Entity User available with a field name. Now we would create another entity names Task and have a relationship with User entity. Following are the commands which we would need to do that:
entity --named Task
field string --named description
field temporal --type DATE due
field boolean --named completed
Go back to User.java context with the following commands and add one to many relationship to tasks
cd..
cd User.java
field oneToMany --named tasks --fieldType com.example.trackr.model.Task.java
And we are done. We have two entities and also added a relationship between them. - The above steps itself have saved us so much time but is this all and you are right this is just glimse..
When we are done with all the setup and entities coded now you would be wondering that we have to still create a UI and see if this actually works. Forge would help you with a startup UI code for simple CRUD operations and show that it actually works. A small command would do that for you:
scaffold from-entity <package-where-you-have-your-entites>.*
ex. scaffold from-entity com.example.trackr.model.*
This command would create JSF views for you.
This is not all you can create rest end points and install various plugins available to add arquillian to your project and also options to create arquillian tests skeleton for you. The plugin list is big and is growing with the support of the community. If you don't find a plugin, creating a new is not tough either.
Start exploring and see the endless options available and share in the comments.