Recently, i got a task where licensing was required to be added. I have done such tasks using ant in the past but this time I was supposed to use maven. Some quick search made it clear that maven provides a plugin to do such activities but the documentation was not upto the mark (or i can say it was a bit confusing or too generic). To save other people from such situation I am going to demonstrate it using a simple example.

Lets suppose you want to have licensing information given below in all java files of your project:

/**
 * Copyright (C) 2014 My Coaching Company. All rights reserved This software is the confidential
 *  and proprietary information of My Coaching Company. You shall not disclose such confidential
 * information and shall use it only in accordance with the terms of the license agreement you 
 * entered into with My Coaching Company.
 *  
 */

Here are steps to do so:

1. Create a txt file named License.txt and place it in parallel with pom.xml and make sure that your license file should not contain comments like /** ... */. It should look like,


 Copyright (C) 2014 My Coaching Company. All rights reserved This software is the confidential      and proprietary information of My Coaching Company. You shall not disclose such confidential        information and shall use it only in accordance with the terms of the license agreement you entered    into with My Coaching Company.
 
2. Add following snippet to pom.xml

  <properties>
        <license.dir>${basedir}</license.dir>
  </properties>

3. Now add plugin configuration for adding license to java files in maven project,

<!-- License information -->
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.10.b1</version>
<configuration>
<header>${license.dir}/license.txt</header>
<properties>
<project>
${project.name}
</project>
<founder>${project.organization.name}</founder>
<year>${project.inceptionYear}</year>
<website>${founder-website}</website>
</properties>
<includes>
<include>src/main/java/**</include>
<include>src/test/java/**</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mycila</groupId>
<artifactId>licenses</artifactId>
<version>1</version>
</dependency>
</dependencies>
</plugin>

4. Now you are all set to fire the command 
     mvn license:format
 This will add license information on top of java code.


Note: If you have projects under subproject something like
   
 project ---|
                 | --> sub-project
                 | --> sub-project2

then you are required to add following snippet into the pom.xml of sub-projects:

<properties>
    <license.dir>${project.parent.basedir}</license.dir>
</properties>

I hope this should help lots of developers around. This is one of the most simple usage of this plugin for more please refer to the official site.



0

Add a comment

Its a common requirement that we have to keep backup and restore data/indexes of solr. Although latest versions of solr makes life a lot easier. I will explain how to do it in solr 4.x, taking simplest use case. Follow the below steps:

For Backup

Open browser and type this command in address bar

http://localhost:8983/solr/my_core/replication?command=backup&location=/tmp/backup_1&numberToKeep=1

here "my_core" is name of solr core and location is absolute path to directory where you want to create backup. in this case backup files will be created under /tmp/backup_1

For Restoration

Open Admin UI and unload my_core core from "core admin" tab.

Now manually copy the files backup files created under /tmp/backup_1 to /path-to-solr-data/my_core/data/index.

Multithreading has always been an area of interest for most of the developers. They have been trying hard to find out the most optimal strategy to solve this problem. In the past various attempts have been made to standardize such solutions. Especially with the rise of new problem domains like Big Data, real time analytics etc. new challenges have been introduced.

Recently, i got a task where licensing was required to be added. I have done such tasks using ant in the past but this time I was supposed to use maven. Some quick search made it clear that maven provides a plugin to do such activities but the documentation was not upto the mark (or i can say it was a bit confusing or too generic). To save other people from such situation I am going to demonstrate it using a simple example.

Concurrency sparked widespread interest in functional programming. Multithreaded programming, requiring synchronized access to shared, mutable state, is the assembly language of concurrency.

Immutable values make synchronization unnecessary. Mutating state is never completely avoidable. We will examine two higher-level abstractions that provide “principled” ways to manage mutable state in thread-safe ways:

i. Actors ii. Software Transactional Memory.

Functional languages provide a core set of common data structures with combinatory operations that are very powerful for working with data. Functional algorithms emphasize declarative structure, immutable values, and side-effect-free functions. We already think of lists, maps, etc. as “collections,” all with a set of common methods.

1.       Do not repeat yourself (DRY) – check if you have added something to CPD reports. CPD can be easily taken from tools like PMD.

2.       Take care about methods:

·         Do not create methods for “side effects”. They can drive you crazy in case of bugs.

·         Methods shouldn’t be doing multiple things.

·         Try to switch over to “switch” statement rather than nested “if”.

·         Make sure methods use abstractions rather than concretions.

·         Use fewer arguments.

Around two years back I was introduced to some concepts like Big Data, Distributed Computing, NoSQL and Guava api. This lead to my introduction to the term “Functional Programming”. At that time I just parked this term and continued with my interest in NoSQL space but as my work and interest grew in these areas, more I heard about benefits for using this style. A couple of weeks back I got chance to spend time on it.

Functional programming, in its “purest” sense, is rooted in how functions, variables, and values actually work in mathematics, which is different from how they typically work in most programming languages.  In functional programming, programs are executed by evaluating expressions, in contrast with imperative programming where programs are composed of statements which change global state when executed. Functional programming typically avoids using mutable state.
Blog Archive
About Me
About Me
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.