Wednesday, April 17, 2013

Maven - How to Replace a Token with the value

If you need to replace the Token with the value in a jar you can use the below plugins. This example would replace the token for all the files which is given in a particular location.

 <build>
  <plugins>
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
     <execution>
      <phase>initialize</phase>       
       <goals>
       <goal>read-project-properties</goal>
      </goals>
      <configuration>
       <files>
        <file>../../maven_config.properties</file>
       </files>
      </configuration>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
     <execution>
      <id>prepare-jar</id>
      <phase>clean</phase>
      <goals>
       <goal>jar</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.2</version>
    <executions>
     <execution>
      <phase>compile</phase>
      <goals>
       <goal>replace</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <includes>
      <include>target/classes/**/*.xml</include>
      <include>target/classes/**/*.properties</include>
     </includes>
     <token>@@portalname@@</token>
     <value>${portal.name}</value>
    </configuration>
   </plugin>
  </plugins>
 </build>

If you need to replace the Token with the value in a war you can use the below plugins. Below example would illustrate how to replace the token and value in a one file.


 <build>
  <plugins>
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
     <execution>
      <goals>
       <goal>read-project-properties</goal>
      </goals>
      <configuration>
       <files>
        <file>../../maven_config.properties</file>
       </files>
      </configuration>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.0.1</version>
    <executions>
     <execution>
      <id>prepare-war</id>
      <phase>prepare-package</phase>
      <goals>
       <goal>exploded</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.2</version>
    <executions>
     <execution>
      <phase>prepare-package</phase>
      <goals>
       <goal>replace</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <file>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml</file>
     <replacements>
      <replacement>
       <token>@@portalname@@</token>
       <value>${portal.name}</value>
      </replacement>
     </replacements>
    </configuration>
   </plugin>
  </plugins>
 </build>

Friday, April 12, 2013

Maven - Copy Artifact in to a separate location

  • Create a Maven config file in the eclipse workspace.  maven_config.properties
  • Add the following key and value maven.output.build.path=/maven-dependency-plugin/target/test
  • Add the following two plugins to the Maven POM file.


   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
     <execution>
      <phase>initialize</phase>
      <goals>
       <goal>read-project-properties</goal>
      </goals>
      <configuration>
       <files>
        <file>../maven_config.properties</file>
       </files>
      </configuration>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.7</version>
    <executions>
     <execution>
      <id>copy</id>
      <phase>package</phase>
      <goals>
       <goal>copy</goal>
      </goals>
      <configuration>
       <artifactItems>
        <artifactItem>
         <groupId>${project.groupId}</groupId>
         <artifactId>${project.artifactId}</artifactId>
         <version>${project.version}</version>
         <type>jar</type>
         <overWrite>true</overWrite>
         <outputDirectory>${maven.output.build.path}</outputDirectory>
        </artifactItem>
       </artifactItems>
      </configuration>
     </execution>
    </executions>
   </plugin>
  • Run the targets package or install

Thursday, April 11, 2013

Postgre 9.1 Installation

Use the below command to install the postgre
  
   sudo apt-get install postgresql-9.1  
    
Connect to the DB using PgAdmin III

Reset the password
Connect to the postgre DB in a terminal
 sudo -u postgres psql
    
reset the password

 \password postgres

Eclipse Juno - Showing and hiding menu items and toolbar buttons


You can choose to hide menu items and toolbar buttons and then show them again.

Hiding a menu item or toolbar button

To hide a menu item or toolbar button:
  1. Switch to the perspective that you want to configure.
  2. Select command link Window > Customize Perspective....
  3. Open the Menu Visibility or Tool Bar Visibility tab.
  4. Find the item you want to hide. You can do this two ways:
    • Expand the menu or toolbar hierarchy to find the item you want to hide.
    • Click the Filter by command group check box to see a list of command groups which contribute items, and choose the command group the item you wish to hide. Then navigate to the item in the hierarchy in the Structure tree.
  5. Hover over the item to get additional information:
    • a description of what the item does
    • the name of the command group which contributes the item (click the link in this item to switch to the Command Groups Availability tab with the appropriate command group selected).
    • any key bindings associated with the command the item performs (click the link in this item to open the Keys page of the Preferences dialog with the command selected, if possible).
    • if the item is dynamic, a preview of its current appearance (dynamic items are listed as [Dynamic]).
  6. Uncheck the check box next to the item. Uncheck a menu to hide all its children.
  7. Click OK to cause the changes to take effect.
Using the tooltip which appears over items, you can navigate to the Command Group Availability tab and make the entire command group unavailable if you wish to remove all menu items, toolbar buttons and keybindings of all commands contributed by the command group.

Showing a menu item or toolbar button

To show a menu item or toolbar button, you can follow the same instructions as hiding one, except check the check box instead of unchecking it.
If an item you want to make visible is grayed out, this is because the command group which contributes it is not available. You need to make it available before you can show or hide items it contributes. You can do this by hovering over the item, and clicking the command group link in the tooltip which appears.

Friday, March 22, 2013

Useful Maven Plugins


  1. Apache Maven - Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. http://maven.apache.org/plugins/index.html
  2. Mojo - The Mojo project is a collection of plugins for Apache Maven 2 & 3 http://mojo.codehaus.org/plugins.html
  3. http://www.packtpub.com/article/useful-maven-plugins-part1
  4. http://nayidisha.com/techblog/useful-maven-plugins
  5. http://www.ibm.com/developerworks/java/library/j-5things13/index.html
  6. http://repository.ow2.org/nexus/content/sites/ow2-utilities/mergeproperties-maven-plugin/plugin-management.html
  7. http://evgeny-goldin.com/blog/maven-plugins-released/
Other Plugins
  • maven-replacer-plugin - https://code.google.com/p/maven-replacer-plugin
  • properties-maven-plugin

Thursday, March 21, 2013

Integrate VersionOne with the Eclipse IDE

I have explained how to  Track your modified files with Eclipse MyLin in previous blog. This Blog will explain how to connect to the VersionOne through eclipse. If you have already followed the Track your modified files with Eclipse MyLin then it is easy to Integrate with the VersionOne.

Lets see how we can configure VersionOne through the MyLin very easily.

  • Click the New Task Down Arrow key and select "Add Repository"

  • Click "Install More Connectors"


  • Select VersionOne

  • Once the plug-in is installed select the VersionOne from the "New Task" Drop Down Menu and  Enter the Version one lo-gin details. Once the credentials are entered click "Validate Settings" to ensure the success connection to the VersionOne System

  • If you have logged in to the system successfully then you can see all the tasks in the "Task List"


  • Open the assigned task and start working on it. Select Activate Task and then it will track all the modified files and assigned to the relevant task.
  • Add Comments in to the Task
  • Change the Actions, Attache Context and Submit to theVersionOne


  • Attach Screenshots and modified file list

  • Track the working hours , Schedule time, estimate dates



  • View Modified Files


  • Check the Modified tasks in the VersionOne Web tool. 











Friday, March 8, 2013

How to upload Artifact to the repository server

If you need to upload the artifact while you install to the local repository, follow the below steps.

1. Add the following setting in the setting.xml file which is in the local repository

    
      archiva.internal
      [UN]
      [PW]
    
  


2. In the POM file add the following settings

  
   archiva.internal
   Internal Release Repository
   [URL For the internal repository path]
  
 
Note : ID of the both files should be same

3. Run the following goal mv deploy

Please ensure upload rights is given in the relevant repository server

For exmple, if your using Apache Archiva then deployment user needs the Role 'Repository Manager' for each repository that you want to deploy.