11 Important Maven Commands

1.Creating a maven standalone project

mvn archetype:generate -DgroupId=org.cloudhadoop -DartifactId=myproject

This is the starting step for any java project to create. This command runs at command prompt and create myproject with project name i.e. artifact id. This project is located in group “org.cloudhadoop” using groupid,.
After running this command for the first time, this tries to download all the required artifacts downloaded from remote repositories ( from maven .. etc) and copy to your localrepository and after that it create a project. This project contains the src/main/java and src/test/java folders which contain the hellowold java program in main folder, and test class for hell0world program in test folder.

2.Creating a web standalone project

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes
-DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.cloudhadoop
-DartifactId=mywebapp

Most of the times, we usually create a web based projects in eclipse. With this command also, we can create web project like spring, struts which contains, WEB-INF, lib, classes folders and web.xml. This command runs at command prompt and create mywebapp with project name i.e. artifact id. This project is located in group “org.cloudhadoop” using groupid,.
After running this command for the first time, this also tries to download all the required artifacts downloaded from remote repositories ( from maven .. etc) and copy to your localrepository and after that it create a project.
The directory structure is different from the #1 command and creates as per maven directory structure for web applications.

3. Cleaning project

mvn clean

As you know target folder contains all your compiled classes, as well as jar,war files when you run project with maven install.
Clean is maven predefined goal, this command delete all the contents in the target folder.

4. compile maven project

mvn compile

compile is maven predefined goal ,this command complie all your java classes which includes src files as well as test files in your project.

5.Build web apps

mvn package

maven package goal is used to build maven applications.
As you know any java project can be packed as jar or war.
Package is maven predefined goal. By giving this command, first compile all the java files(using compile goal) and run all your test classes and copy all this files to target folder and create a jar, war file. The final out put for this command is jar/war of your project located in target folder.

6.Deploy project

mvn install or
mvn deploy

When we run this command under your project, it will do all the tasks in “mvn package” and create the required jar/war file in target folder.
Maven install goal is used to deploy the project(jar/war) to the local repository. and local repository location is /.m2/repositories/groupid/.
Maven deploy goal is used to deploy the project to the remote repository like nexus. so that other developers can use this artifact in their module. remote repository location is specified in pom.xml.

7. Run unit and integration tests

mvn test

Test goal is used to run only the test classes in your project. The test files are located under src/test/java and copy the result to your target/test-classes, target/reports if any.

8. Ignore test execution

mvn package –DskipTests or
mvn package -Dmaven.test.skip

In 4#, with maven package command run, tests are also executed. If you want to skip the unit tests, The we can use this command. You can use this option with install goal also.

9.Generate java documentation for project

maven javadoc:javadoc

This will generate java documentation for your project. And the generated java doc report can be found in target folder
This will includes API documentation for your java classes in your project.
10. Debug maven

mvn -X

This command is used to start the maven goals in debug mode and gives logging information. This command gives more information like what artifact is failing for what reason .
This command can be used when you are not getting any clue for your maven project execution failure.

11.Generate site

mvn site

Predefined goal in maven is used to generate site documentation in formatted style.

Yii and Bootstrap – YiiStrap: How to Install and Configure

Simple steps to help you get started with YiiStrap.

  1. Install Yii.
  2. Create a new Yii application.
  3. Copy YiiStrap.
  4. Change configuration.
  5. Use Gii: Automated Code Generation.
  6. Create CRUD using Gii

Install Yii

  1. Download the latest Yii Framework from here: http://www.yiiframework.com/download/
  2. Unzip it into your htdocs or www or public_html folder. Basically unzip it into a browse-able location.
  3. You need only the framework folder. All other folders are optional. Keep the requirements folder if you want to ensure that your web-server has all the requirements for Yii to work.

Create a new Yii application.

  1. Open a terminal window.
  2. Go into the framework directory
  3. Run this command:

    ./yiic webapp ../myProjectName
  4. The new Yii application will be created at “[the path to the folder where the framework folder is located]/[myProjectName]”.
    You can access it with the following URL: http://mydomain/myYiiPath/myProjectName/index.php

Copy YiiStrap.

  1. Download the latest YiiStrap extension from here: http://www.getyiistrap.com
  2. Create a new folder called “bootstrap” in your new Yii applications protected/extensions folder
  3. Unzip the YiiStrap zip into this new older

Change configuration.

  1. Open your new Yii applications protected/config/main.php file
  2. Add this to the beginning of the file:
    Yii::setPathOfAlias(‘bootstrap’, realpath(__DIR__ . ‘/../extensions/bootstrap’));
  3. Add these to your return array:
    // path aliases
    ‘aliases’ => array(
    ‘bootstrap’ => realpath(__DIR__ . ‘/../extensions/bootstrap’), // change this if necessary
    ),
    ‘import’=>array(
    ‘application.models.*’,
    ‘application.components.*’,
    ‘bootstrap.behaviors.TbWidget’,
    ‘bootstrap.helpers.*’,
    ‘bootstrap.widgets.*’,
    ‘bootstrap.helpers.TbHtml’,
    ),
    ‘modules’=>array(
    // uncomment the following to enable the Gii tool
    ‘gii’=>array(
    ‘class’=>’system.gii.GiiModule’,
    ‘password’=>’admin123′,
    // If removed, Gii defaults to localhost only. Edit carefully to taste.
    ‘ipFilters’=>array(‘127.0.0.1′,'::1′),
    ‘generatorPaths’ => array(‘bootstrap.gii’),
    ),
    ),

    ‘components’=>array(
    . . . . . . . . .
    . . . . . . . . .
    ‘bootstrap’ => array(
    ‘class’ => ‘bootstrap.components.TbApi’,
    ),

    ‘db’=>array(
    ‘connectionString’ => ‘mysql:host=localhost;dbname=pmtool’,
    ’emulatePrepare’ => true,
    ‘username’ => ‘jessie’,
    ‘password’ => ‘jessonita’,
    ‘charset’ => ‘utf8′,
    ),
    . . . . . . . . .
    . . . . . . . . .
    ),

Use Gii: Automated Code Generation.

Use the Gii Automated Code Generator to create CRUDs for your tables. The tools is pretty straight forward. Here is the URL:
http://myDomain/myYiiPath/index.php?r=gii/

That’s it! Open the model, controller and view folder in the protected folder to see how they are written.

Bootstrap – What Is It and Why Learn It?

Twitter Bootstrap was first developed by the founders of Twitter, and is a part of the open source web development technology. It allows for front-end web frameworks, and even today, this is still popular and growing stronger every year.

Bootstrap

The History

Twitter has long since carved a niche in the open source web development arena, especially because it foud a unique approach to front end web framework development. Since then Twiter has released most of its codes to open source and Bootstrap (as it is known) is available to everyone, which has made it a chosen platform among web developers and users.

Bootstrap allows for exclusive, clean and professional themes and templates that can be made into websites and website applications. Websites created using Bootstrap are very compatible with all web browsers, and this platform simplifies responsive design and speeds up front end web applications.

Bootstrap and WordPress

Even those developers who prefer to use WordPress as their content management system can combine the Twitter Bootstrap into their web project, and thereby get a well-coded theme.

Bootstrap and Joomla

The Joomla community is also using Twitter Bootstrap, and they also see an improved level of interactivity and integration with add-ons. Bootstrap is very useful and practical when it comes to creating fast loading, beautiful Joomla templates and themes.

With Joomla community beginning to use the Twitter Bootstrap; we can see an improved level of consistency between the add-ons. For instance, if you have a medium-sized Joomla website with 15-20 elements in it, then your web developer needs to spend a considerable amount of time updating the icons and styles of each element so as to keep up the pace with the rapidly changing world, otherwise your website might online casino appear broken/ inconsistent. Apart from the above Bootstrap is also useful in creating beautiful Joomla themes and templates.

Bootstrap and Drupal

Those that develop with Drupal are also finding Twitter Bootstrap extremely useful as it helps them create highly responsive front-end interface themes.

The new version of Bootstrap

The latest version of Bootstrap adds many more features and in this version many of the bugs have been fixed from the prior version. Now there are new navigations, taglines and layouts. There are also new dropdowns that support sub-menus, classifications, buttons and block levels in this new Bootstrap version.

Bottom Line

As a developer it may very well be in your best interest to learn Bootstrap. This gives you added skills but also helps you better develop front end cloud applications. Bootstrap integrates well with other languages and makes this type of needed interface easier to use and more efficient.