Category Archives: Uncategorized

Some Maven gyaan

Maven is a project management and comprehension tool and as such provides a way to help with managing:
• Builds
• Documentation
• Reporting
• Dependencies
• SCMs
• Releases
• Distribution
Buzzwords
1) POM (Project Object Model) – The POM is the basic unit of work in Maven. POM essentials:
• project This is the top-level element in all Maven pom.xml files.
• modelVersion This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model. By default, the model version is set to 4.0.0.
• groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins.
• artifactId This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form . (for example, myapp-1.0.jar).
• packaging This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. The default value for the packaging element is JAR so you do not have to specify this for most projects.
• version This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development. We will discuss the use of snapshots and how they work further on in this guide.
• name This element indicates the display name used for the project. This is often used in Maven’s generated documentation.
• url This element indicates where the project’s site can be found. This is often used in Maven’s generated documentation.
• description This element provides a basic description of your project. This is often used in Maven’s generated documentation.
More information about POM files can be found in POM reference and POM Introduction.
2) Archetype – Archetype is a Maven project templating toolkit. It provides a standard way to enable creation of sample projects which can be used as a starting point.

• To create a maven project based on archetype, you need to give the following command:
mvn archetype:generate

• Following archetypes are provided by maven:

Archetype ArtifactIds Description
maven-archetype-archetype An archetype which contains a sample archetype.
maven-archetype-j2ee-simple An archetype which contains a simplifed sample J2EE application.
maven-archetype-mojo An archetype which contains a sample a sample Maven plugin.
maven-archetype-plugin An archetype which contains a sample Maven plugin.
maven-archetype-plugin-site An archetype which contains a sample Maven plugin site.
maven-archetype-portlet An archetype which contains a sample JSR-268 Portlet.
maven-archetype-quickstart An archetype which contains a sample Maven project.
maven-archetype-simple An archetype which contains a simple Maven project.
maven-archetype-site An archetype which contains a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site.
maven-archetype-site-simple An archetype which contains a sample Maven site.
maven-archetype-webapp An archetype which contains a sample Maven Webapp project.

• Archetypes are packaged up in a JAR and they consist of the archetype metadata which describes the contents of archetype and a set of velocity templates which make up the prototype project. Archetype contents are as follows:
a) an archetype descriptor (archetype.xml in directory: src/main/resources/META-INF/maven/). It lists all the files that will be contained in the archetype and categorizes them so they can be processed correctly by the archetype generation mechanism.
b) the prototype files that are copied by the archetype plugin (directory: src/main/resources/archetype-resources/)
c) the prototype pom (pom.xml in: src/main/resources/archetype-resources)
d) a pom for the archetype (pom.xml in the archetype’s root directory).
See guide for creating archetype descriptors here for more information.
3) Build Lifecycle & Build Phases – Maven is based on concept of build lifecycle. This allows one to have a clearly defined process for building and distributing a particular artifact.

• There are three build lifecycles- default, clean and site. Default lifecycle is for handling project deployment, clean handles project cleanup and site handles the creation of project’s site documentation.
• Each of these lifecycles is made up of build phases. The build phase represents a stage in the lifecycle. eg. the default lifecycle is made up of following phases:

a) validate – validate the project is correct and all necessary information is available
b) compile – compile the source code of the project
c) test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
d) package – take the compiled code and package it in its distributable format, such as a JAR.
e) integration-test – process and deploy the package if necessary into an environment where integration tests can be run
f) verify – run any checks to verify the package is valid and meets quality criteria
g) install – install the package into the local repository, for use as a dependency in other projects locally
h) deploy – done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
These phases (and other phases in clean and site phases) would be run sequentially. For example, if the following maven command is issued:
mvn compile
maven would do every build phase prior to compile before compile it (namely validate).
• A build phase is further made up of goals. Even though it may be responsible for a specific step in the build lifecycle, the manner in which it carries those responsibilities varies. This is achieved by declaring the goals bound to these build phases. A goal represents a specific task (finer than a build phase) which contributes to the building and managing of a project. It may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation.

Overloading in C…..? ..Its possible…..

hi everyone..

since we started studying C language, we have been taught that method overloading is not possible in C..like everyone, even I believed that..
But yesterday I learnt that it is possible..by including a header file named STDARG.H.

This header file lets you create variadic functions.i.e. functions with variable arguments.
To perform method overloading, you just have to include this header file and declare a function which you intent to “overload” or provide variable inputs.

syntax:-
return type function-name( datatype1 arg1, datatype2 arg2,…);

Note:- the last 3 dots in the list(…), this is the one which tells the compiler that it would be taking variable arguments. It is mandatory to include these 3 dots(…) else your function would not accept variable inputs.

You can make a function which accepts same typed arguments or different.

The procedure to be followed is as follows:
1. you need to declare a variable “va_list” for iterating through the variable list.
2. then use macros like “va_start” – to start iterating through the variable list va_list.This macro takes two arguments. First the variable with type va_list and second is the name of the last argument given in the list. In the syntax given above , it would be arg2.
3. va_arg- to retrieve an argument from the list. In this macro you need to provide two arguments. First bariable of type va_list and second is the datatype of the next argument to be fetched.
4. finally, va_end macro- to find the end to the variable list.

Its really fun to work with this feature of C and perform a function which was said not to be possible in C.

This was just a jist about the header file and its macros.

Happy C Programming..!!!

My triumph over MYSQL..!

My fight with MySQL has finally come to an end. It has been troubling me past few weeks.
I was facing troubles on installing it on my office PC. Finally I got it right..!!!! hurrayyy..I won over it..!

The error which was troubling was ” Error No:1045- Access denied for user ‘root@localhost’ (using password:YES)”.

the resolution is:
MySQL configuration wizard doesn’t set or reset the root password. It simply leaves the password as blank. Otherwise the installation is complete.

The crack is: On getting this error, go to MySQL Command Line. Press ENTER when it asks for password(because it has been left blank by the Server Configuration Wizard).
On the command prompt, type SET PASSWORD FOR ‘root@localhost’ = PASSWORD(‘newpwd’);

Now its running….

Reverse Logic :: Launched!

Gang,

I am pleased to announce that we own a domain name on the world wide web!

we are *http://reverselogic.info*

Our next steps:

1/Subscribe to the gang(gangRemovemE@reverselogic.info)– ALL

2/Download the pencil plugin(firefox) and start sketching the screen
design how we want the web to reflect us!– ALL

3/Pen down how you would want your information made available on the
web for presence!–ALL

4/Pull your thinking hat’s on and start chalking out
mail-boxes/sections you would want to see on
http://reverselogic.info –ALL

5/Atleast feel excited! 🙂 –ALL(mandatory!)

Keep The Stir In!

~rohit.