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.