Top 10 Best Maven Plugins for Java Developers

In the last couple of years, maven has become the de-facto build tool for Java applications. Although there are challenges exists from tools like Gradle, however i believe the dominance of maven can help it to win the ultimate battle. When I started with maven, i used to be pleased with just dependency management on the other hand I come back to know regarding maven plugins that allow you to customise your build up to the level you'll do with ant. These plugins give true power to maven to modify most of the build related task e.g. compilation, testing, packaging, deployment, and even committing the source code into the remote source repository.



Several Java developers who use maven daily are sometimes not aware of these essential maven plugins mostly as a result of maven just works, or someone has already done the hard work for them.

Maven uses conventions over configuration which means even if you do not understand much about maven you can use it to create your project and manage dependency. So as to bridge that gap, i'm going to share 10 essential maven plugins for Java developers. Knowing these plugins and what the do can help you to know however maven works normally and allow you to higher management your build process.

Top 10 Best Maven Plugins for Java Developers

Here is my list of useful and essential maven plugins every Java developer should be aware of. There is a good chance that you might be using many of them without knowing much about them, this article will help you to explore them better.

1. maven-compiler-plugin


This is the most important maven plugin. You almost always use it unknowingly. This plugin compiles your Java code from the standard location Maven specifies e.g. /src/main/java and /src/main/resources. You can customize the default behavior of maven-compiler-plugin by specifying instructions in pom.xml file. For example, in following pom.xml file we are telling maven-compiler-plugin to expect Java 7 source, and output Java 7 specific classes.
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
You can also see Maven: The Definitive Guide to learn more about this plugin.

2. maven-surefire-plugin


The Maven Surefire plugin is the default plugin for running unit tests. You can also customize the behavior of this plugin by specifying configuration in pom.xml. The Surefire Plugin has only one goal: surefire:test runs the unit tests of an application.

3. maven-assembly-plugin


The Maven Assembly plugin is another useful maven plugin which allows you to create your project distribution in zip or tar format, suitable for deployment in Linux environment. We used to do this for our project, where tar file contains all config, binary and resources together. Though it's not a good idea to release binary and config together, sometimes it makes a lot of sense in smaller projects. Btw, all goals except assembly:single have been deprecated of maven-assembly-plugin.

4. maven-jetty-plugin


The maven jetty plugin is pretty awesome for Java web developers as it makes Java web application development much easier. In order to run your Servlet JSP based project, rather than packaging and creating a WAR file and deploying it into tomcat server, you can simply run mvn jetty:run and your web application start. It uses embedded Jetty Servlet container to run your Java web application.

5. maven-dependency-plugin


The Maven Dependency Plugin is another mandatory plugin to debug or understand a POM and how you get some dependency (transitively). This plugin has several goals but some of the most useful are following:
dependency:analyze - analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
dependency:tree - displays the dependency tree for this project
dependency:build-classpath tells Maven to output the path of the dependencies from the local repository in a classpath format to be used in java -cp. The classpath file may also be attached and installed/deployed along with the main artifact.

6. maven-jar-plugin


This is the plugin which creates a Java Archive (JAR) file from the compiled project classes and resources. You almost always use this plugin to create JAR files. the latest version of this plugin is 3.0.1

7. maven-war-plugin


This plugin creates a Web Archive (WAR) file from the compiled project classes, resources, and web.xml. You use this plugin while building Java web application as they are deployed into Servlet container like Tomcat or enterprise Server as WAR file.

8. maven-deploy-plugin


This plugin is responsible for uploading the project artifacts e.g. JAR, WAR, source code, Java docs etc to the internal remote repository. The current version of deploy plugin is 2.8.2 released in August 2014. See Maven Essentials to learn more about key maven concepts like local and remote repository.

9. maven-resource-plugin

This Maven resource plugin is responsible for copying of Java projects resources to the output directory. There are two different kinds of resources in Maven projects: main resources and test resources. The difference is that the main resources are used by the main production code while the test resources are associated with the test source code, which is only used while running unit test or integration tests.

10. spring-boot-maven-plugin

The Spring Boot maven plugin is one of the useful plugins to develop Java web application using Spring Boot library. It collects all the jars on the classpath and builds a single, runnable "├╝ber-jar", which makes it more convenient to execute and transport your service. It also searches for the main() method to flag as a runnable class, and most importantly it provides a built-in dependency resolver that sets the version number to match Spring Boot dependencies.


That's all about some of the essential Maven plugins for Java development. There are tens of Maven plugins but you don't use them always, these are the plugins which you are most likely to encounter and use them in your day to day Java development work. Knowing a little bit more about these maven plugins will not only help you to understand your pom.xml file but also how things work in Maven environment e.g. how your project gets compiled or how unit tests are run in Maven build environment. This knowledge also helps you to customize a particular phase of Maven lifecycle to suit your projects need.

PlatformIO - Arduino Alternative IDE for IoT integrated platform

When developing Arduino sketch,  we all use Arduino IDE, anyway, there are several Arduino alternative IDE. This alternative IDEs are useful and more user-friendly.
Arduino IDE is the first IDE we all use when approaching to Arduino development for the first time. It is simple and provides all the features to write, compile and upload the code to Arduino boards. It is based on Java and runs on Windows, OS X and Linux. Arduino IDE is a complete solution, anyway, it does not have all the features you could find in Eclipse or IntelliJ.

Best IOT Cloud Platform You should Know

I was looking for an Arduino alternative IDE that could provide a more “robust” IDE having, at the same time, all the features of Arduino IDE. This Arduino alternative IDE must be free of charge and open source. Even if there are several options, I focused my attention on PlatformIO.

Platformio is an interesting alternative IDE that provides almost all the features I was looking for.
First of all, it is opensource and you can find the source code at GitHub repository. Second, it is free to use and it has a large community that supports it.

Arduino alternative IDE: Platformio

  • C/C++ Code Completion
  • Multi-project
  • Theme support
  • Cross-platform support
  • Serial port monitor
  • Library management system
  • Continuous integration
I'm using PlatformIO to build #IoT projects! I found it at http://www.geekonjava.blogspot.com

How to build your first Arduino project

  • Create a new project
  • Open an existing project
  • Import an Arduino Project

Arduino Libraries management


This is IDE has a clean and easy-to-use interface, very attractive. It offers not only a visual IDE to develop IoT projects but it has a CLI (Command Line Interface). It is based on Python and runs on different OS like Windows, OS X and Linux.
The main features are:
This Arduino alternative IDE supports several boards like Arduino UNO, Arduino MKR1000 and in general Arduino development boards. Moreover, it supports Raspberry PI family and so on. So this is a complete solution to develop IoT projects in an easy and intuitive way. The interface is completely different compared to Arduino IDE.

You can read also : Zephyr - Tiny Linux OS for Internet of Things
Now it is time to start using PlatformIO. The best way to test is building a simple Arduino project.  Implementing a simple project helps us to evaluate this IoT IDE and, at the same time, we can check if it is a real improvement compared to Arduino IDE.
So the first step is the installation process that is very simple and straight. Once the IDE is installed, let us run the app. It takes a while before you can use it because the IDE starts an update/installing process:
platformio ide
After this process is completed, you have the PlatformIO (Arduino Alternative IDE) up and running:
arduino alternative ide
As you can notice the interface is very clean with all the most important commands on the left bar. We have several options:
In our case, we want to create a new project so let us click on the first item. After inserting the required fields (like the board we are using), the project is ready. You can consider the project like a folder where you can put your project files. We create a simple test file (testLed.cpp), with this content:
PlatformIO IDE alternative
The first thing, you should notice, is the code completion: this is a very useful feature. The syntax highlighting is also attractive and help to emphasize language keywords.
Now it is time to build and run our simple sketch:
PlatformIO arduino
One important aspect is the library management. As you know already Arduino IDE has its own library management system and you can use it to download libraries. PlatformIO has a different way to handle libraries.  You can access it using the Library Manager. Before installing a library, you have to find thelibrary id using the library registry. Opening the lib web page, you find a search area where you should insert the library name you are looking for:
arduino library manager
and the result is shown below:
platformio library registry
Now you have the library id and you use this id to install the library:
arduino install library
where 19 is the library id. The library is ready to use.
At the end of this post, you hopefully know an Arduino alternative IDE.

How to Detect Face in Android

Android detect face is an interesting topic that will be covered in this tutorial. It will use the camera to get the picture and then the app will draw some rectangle around the faces detected in the image. To do it we simply use the Android API like:

  • FaceDetector used to detect face in the bitmap
  • Face  object that contains information about face detected

So we have to make three steps in our apps:

  • Take the picture
  • Detect faces in the picture
  • Draws the rectangles around the faces detected

Take the picture with camera using Android

This step is quite simple because we have simply to invoke an intent and get ready to receive the result. The Intent is very simple:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_RETURN_CODE);
To retrieve the result (the picture taken) we have to override a method in our activity:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_RETURN_CODE) {
Bitmap cameraBmp = (Bitmap) data.getExtras().get("data");
}
}
At grey coded line we retrieve our picture using extra with data key.

ndroid Detect face in the picture


At this point, we use the API shipped with Android SDK since level 1. To implement our logic we create a custom component that extends ImageView, we call it FaceImageView.
public class FaceImageView extends ImageView {
...
}
To detect the faces, we have first convert the image in Bitmap in 556 format otherwise we can’t use the image as stated in API, so we have:
Bitmap tmpBmp = image.copy(Config.RGB_565, true);
Now we have our image in the right format, we create an instance of the FaceDetector:
FaceDetector faceDet = new FaceDetector(tmpBmp.getWidth(), tmpBmp.getHeight(), MAX_FACES);
passing the image width and image height and the number of faces we want to detect (in our case it is simple constant).
Now we invoke the findFaces method to detect the faces, as a result we expect an array of Face instance that must have the length equals to the number of faces we want to detect:
faceDet.findFaces(tmpBmp, faceList);
where faceList is our array.
Now we have to analyze each item in our array and get the result. We simply want to get the face midpoint and the eyes distance. We use these two information to draw the rectangle for each face detected:
for (int i=0; i < faceList.length; i++) {
Face face = faceList[i];
Log.d("FaceDet", "Face ["+face+"]");
if (face != null) {
Log.d("FaceDet", "Face ["+i+"] - Confidence ["+face.confidence()+"]");
PointF pf = new PointF();
face.getMidPoint(pf);
Log.d("FaceDet", "t Eyes distance ["+face.eyesDistance()+"] - Face midpoint ["+pf+"]");
RectF r = new RectF();
r.left = pf.x - face.eyesDistance() / 2;
r.right = pf.x + face.eyesDistance() / 2;
r.top = pf.y - face.eyesDistance() / 2;
r.bottom = pf.y + face.eyesDistance() / 2;
rects[i] = r;
}
}
At grey line we calculate the rectangle vertex and we store them in a RectF object. If we want to run the app we can use a real smartphone or avd configured in our dev environment. In this case be sure you have configured the camera to use:


Running the example and looking at the log we have:


We notice that the app detected one face while others are null because no more faces exist in the picture.

Draw rectangles around the faces detected

The last step is drawing rectangles around the faces detected. In this case we can use the information, retrieved before, in this way:
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint p = new Paint();
 
canvas.drawBitmap(image, 0, 0, p);
Paint rectPaint = new Paint();
rectPaint.setStrokeWidth(2);
rectPaint.setColor(Color.BLUE);
rectPaint.setStyle(Style.STROKE);
 
for (int i=0; i < MAX_FACES; i++) {
RectF r = rects[i];
if (r != null)
canvas.drawRect(r, rectPaint);
}
}
Hope it will help you in your existing project.

Twitter may be acquired by Saudi Prince

After Linkdien and Yahoo, Twitter may be acquired by Saudi's Prince.

Saudi Prince Al - Waleed Talal willing to buy

Last year, Twitter made ​​this way , but the deal had failed . According to Twitter reports Menhetton his office is looking to rent a place . Reports that Saudi Prince Al - Waleed Talal  and Ballmer are willing to buy Twitter . Twitter has not yet responded to the reports .


Twitter has poor economic situation at these day. This microblogging site is decide to rent their San Fransisco headquarter to face that trouble.

According to the sfgate brokerage firm Kresa twitter Headquarters from taking place is discussed in the rent . Twitter almost 183 642 square feet is thinking of hiring .

"We use office space more effectively and efficiently are considered . San Francisco in the mid-market area we are committed to its place . "
-Twitter spokesman
Saudi prince Alwaleed bin Talal declared that it had increased stake in Twitter to more than five-hitter. The up within the stake comes right when the appointment of Jack Dorsey as the new ceo. it's attention-grabbing to notice that the prince has previously been opposed to the appointment of Mr. Dorsey as the CEO, primarily due to his ceo status at square.

The Saudi have prince Alwaleed and Kingdom Holding currently owns 5.17% of the company after a $50 million investment within the micro-blogging website. The billionaire created his initial investment of $300 million within the company in 2011. The investment makes him the second-biggest capitalist in Twitter when Evan Williams, who owns 6.9% of the company. The Saudi fund is of the view that Twitter’s lows offer buying chance for investor to dive in.


Twitter's issues solved?

On Monday, the San Francisco-based company solved  its CEO problem by appointing Mr. Dorsey, Co-founder of Twitter as its new CEO. due to the actual fact that prince Alwaleed initially didn't approve of Mr. Dorsey, it makes us surprise what the real reason behind the rise in investment could be. it might be the case that the prince currently thinks that Mr. Dorsey has the capabilities to run two firms at a similar time. another reason may well be the introduction of the project "Moments" by the social platform, that is assumed to become huge within the returning years. The Saudi prince is understood for his smart investments and he very should be seeing some positives beginning from Twitter in future.

But Twitter failed to resolve their economic problem in upcoming time. It may be acquired by Saudi Prince Al - Waleed Talal  and Ballmer.

Scientist discovered new form of Light

Scientists from Imperial college, London have discovered a brand new form of light. This analysis offers a new way to produce a new form of light. Scientists say, it's attainable by binding light to a single electron by combining both properties.

new form of light discovered


It allows researchers to investigate quantum physical phenomena, that controls particles smaller than atoms, on a visible scale.

For instance, light, which normally travels in a straight line, would trace the surface of the material if it was bound to a single electron on it, following the electron’s path across the surface of the material. Conversely, electrons in an electrical circuit will normally stop when faced with a defect or imperfection in the conducting material, but with the aid of photons, “the electron would still be able to travel onwards.”

Generally, light collaborates with an entire host of electrons,which is present on the surface and inside the material. Scientists found, it's able to collaborate single electron on the surface by using theoretical physics. Theoretical physics is used to design light behavior and topological insulators. Topological insulators have recently discovered a class of materials.

Thus, it generates a coupling that brings a number of the properties of the light and also the electron. once light is bounded with an electron, it follows its path by seeking the surface of the material.
Dr. Vincenzo Giannini and colleagues design this interaction around a nanoparticle. This nanoparticle is formed of a topological stuff and nearly below 0.00000001 meters in diameter.



Their design shows, light is taking the property of the electron and circulating the particle. so the electron additionally taking on some of the properties of the light.

Artistic image of light trapped on the surface of a nanoparticle topological insulator. Credit: Vincenzo Giannini
When electrons are commonly traveling through electrical circuits, they will stop once faced with a defect. though scientists discovered, electrons are able to move further with the assistance of light even though there are imperfections on the surface.



If this can be used in photonic circuits, they will become a lot of strong and less vulnerable to disruption and physical imperfections.

“The results of this analysis can have a huge impact on the approach we conceive light. Topological insulators were discovered within the last decade. however they already providing us with new phenomena to study and new ways that to explore important ideas in physics.”
-Dr. Giannini

It should be possible to watch the phenomena he has modeled in experiments using current technology, and also the team is working with experimental physicists to make this a reality,” he added.

He believes, this new form of light could be scaled up. Thus, the phenomena are discovered much more simply.

Currently, quantum phenomena will only be seen once observing terribly small objects or objects that are super-cooled, however this might enable scientists to study these kinds of behavior at temperature.

How to Modify Nexus Launcher’s Appearance in Nova

Earlier nowadays the world was treated to a sneak peek at the new Nexus launcher that is believed to be coming with the 2016 Nexus phones. This new launcher additional a chevron to open the app drawer and a shortcut to Google currently at the top of the homescreen. Now due to some incredibly fast work from Corey Zonin anyone will have a really similar experience in Nova!


You can also see a short video we made here of the setup in action, running on a Huawei Mate 8 (with the display density tweaked to allow for more screen real estate).

Check this outHydrogen OS - Android Launcher


To start you will need the two Zooper widgets found here, Zooper Widget Pro ($2.99), Nova, and Polycon icon pack.

Setting up the widgets


  1. Install Zooper Widget
  2. Place attached .zw files in sdcard/ZooperWidget/Templates
  3. Add a 4×1 Zooper Widget to your homescreen on the top row
  4. Tap it to configure > select SD Card > select nexus_launcher_top
  5. Use the scaling options to adjust the size of the widget to fit your screen
  6. Back out of Zooper and that widget should be ready
  7. Next for the chevron above the dock
  8. Add a 1×1 Zooper Widget to your homescreen and center it horizontally right above your dock
  9. Tap it to configure > select SD Card > select nexus_launcher_drawer
  10. Back out of Zooper and that widget should be good to go
Create your ownApex Launcher Theme Tutorial

Adjusting Nova Settings

  1. Desktop
    1. Width padding > None
    2. Persistent search bar disabled
    3. Page indicator > None
  2. App & widget drawers
    1. App drawer style > Vertical
    2. Card background disabled
    3. Background > White at 10% transparency
    4. Enable fast scrollbar enabled
    5. Scroll accent color > teal
    6. Transition animation > Slide up
  3. Dock
    1. Dock Background
      1. Shape > Rectangle
      2. Content > Tint > White
      3. Transparency > 90%
    2. Dock icons > 5
  4. Gestures & inputs
    1. Swipe up > App Drawer
From here on you can tweak and play to your hearts content, tapping the Google logo in the clock widget will launch Google Now while tapping the date in the clock widget will open Google Calendar. Swiping up anywhere on the homescreen will open the app drawer and tapping on the chevron above the dock will open the app drawer

Try it out and let us know what you think in the comments below!

Make Badge(Item count) in Android [Tutorial]

In this tutorial we are aiming to see a way to create Badge (Item Count) to a android Application. Badge is really used to show number of notification, message,product count .We can see many android app use Badge to their Application these days. there's no cutoff way to do it we'll do it by coding ourself. during this application we are aiming to see a way to create Badge in Image Button and button.

Requirement 


  1. JDK 7.0 or Above
  2. Android Studio 2.0

Steps to Follow:

Inside Drawable  folder  create an xml file item_count  and  create a rectangle with 8dp  corner radius.

item_count.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="#f20000" />
<stroke
android:width="2dip"
android:color="#FFF" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
</shape>

To modify   activity_main.xml  add  Relativelayout , Buttons and text . your activity_main.xml  will be like below. And  add the required images in the Drawable folder for this layout .

activity_main.xml 

<?xml version="1.0" encoding="utf-8"?>
<!--Adding Badge (Item Count)/Notification Count to Android Button-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="match_parent"
 android:gravity="center_horizontal"
 android:orientation="vertical"
 android:padding="16dp">

 <RelativeLayout
 android:id="@+id/badge_layout1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<Button
 android:id="@+id/button1"
 android:layout_width="65dip"
 android:layout_height="65dip"
 android:background="@drawable/chat_icon" />
</RelativeLayout>

<TextView
 android:id="@+id/badge_notification_1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@id/relative_layout"
 android:background="@drawable/item_count"
 android:text="16"
 android:textColor="#FFF"
 android:textSize="16sp"
 android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
 android:id="@+id/badge2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginLeft="50dp"
 android:layout_toRightOf="@+id/badge_layout1">

 <RelativeLayout
 android:id="@+id/relative_layout1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">

 <Button
 android:id="@+id/myButton1"
 android:layout_width="65dip"
 android:layout_height="65dip"
 android:background="@drawable/email_icon" />
</RelativeLayout>

<TextView
 android:id="@+id/badge_notification_2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@id/relative_layout1"
 android:background="@drawable/item_count"
 android:text="21"
 android:textColor="#FFF"
 android:textSize="16sp"
 android:textStyle="bold" />
</RelativeLayout>
 
<RelativeLayout
  android:id="@+id/badge4"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_below="@+id/badge_layout1"
  android:layout_marginTop="50dp">
 
<RelativeLayout
  android:id="@+id/relative_layout3"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
 
 <Button
  android:id="@+id/myButton4"
  android:layout_width="wrap_content"
  android:layout_height="65dip"
  android:background="#4169E1"
  android:elevation="4dp"
  android:paddingLeft="50dp"
  android:paddingRight="50dp"
  android:text="Notification"
  android:textColor="#fff" />
</RelativeLayout>
 
<TextView
  android:id="@+id/badge_notification_4"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignLeft="@id/relative_layout3"
  android:background="@drawable/item_count"
  android:text="427"
  android:textColor="#FFF"
  android:textSize="16sp"
  android:textStyle="bold" />
 </RelativeLayout>
</RelativeLayout>
 And your MainActivity.java  is default content as  below

MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Now run your application  , you will see the screensot like  below :

Demo

Hope you enjoy and tutorial is helpful for your project.