Search This Blog

Friday, July 4, 2014

Solve Line encoding(unix/windows) problems in Git branches through Eclipse

There are some possibilities when people work on the same Git hub project in unix and windows. During this time most of us face the problem with Line encoding, Even though there are no changes to the branch, we will observe the entire file has been changed. This is so cumbersome to look at each and individual file and check what actual content is modified.

There are 2 fixes fir this;
  • Fix the IDE settings for file encoding and line delimiters
  • Configure Git to automatically do the conversion for you

Tuesday, June 10, 2014

Increase conversion time for xtext parsing - Time out error

When dealing with complex Xtext, some times you end up with the below error.
error(10): internal error: org.antlr.tool.Grammar.createLookaheadDFA(Grammar.java:864): could not even do k=1 for decision 135
Increasing the amount of memory available to the JVM is the first thing you will have to do when dealing with complex grammars. That however doesn't help in this case. That's because this error is due to a timeout inside the ANTLR generator (which converts xtext to antlr) which by default kicks in after 1000ms. After that ANTLR gives up on creating a DFA for your grammar and you may end up with the error message above.

Monday, June 2, 2014

Auto Merging of Git Branches through Jenkins

Two Git branches can be merged and pushed to remote as a part of the build process. This is possible with Jenkins Git plugin with just 2-3 steps configuration. Lets see that in detail.

  • Create/configure a job in Jenkins
  • In Source code management configure the git repository and the integration branch.
    • While merging Test4 branch into Test3 branch; integration branch is Test4 and the Branch to merge to is Test3

Thursday, May 29, 2014

Replace characters Using ANT

There is an inbuilt task given in ant library called 'replaceregexp'. This task is used to check about a specific pattern i.e. a regular expression and replace them with a different pattern in a single file or set of files.

Replace in a set of files

<replaceregexp match="test" replace="replacedTest" flags="gm" byline="false">
            <fileset dir="${sf.srcdir}" includes="*.txt" />
</replaceregexp>
The above task will look at all the files ending with extension 'txt' in the source directory given as 'sf.srcdir' in the properties file. In all those files, it tries to find the pattern 'test' and replaces with pattern 'replacedTest'

Fail an ANT build if a property is not set

Any number of properties can be used in ANT build.xml. They can be environment variables or variables set in a properties file.

There is an ability to check if required properties are set or not i.e. included or not in the properties file. Also we can match them to a regular expression to see of they are empty or matching as per the requirement. If they do not match the requirement, the build can be made to fail. There is a fail task provided by the ant library to fail the build. Add this as first task before adding any cutom tasks.

Including Properties File

You can include a properties file or environmental variables in build.xml in the below way
    <property file="build.properties"/>
    <property environment="env"/>


Tuesday, May 13, 2014

Copy files from Local to remote using ssh

In order to copy files from local to a remote system using ssh, there should be an  authorized user with a pem file. And also for that particular user in the remote system, there should be proper permissions for the destination.

Remote System

  • Login to the remote server using putty or through powershell.
  • Navigate to the destination folder
            > cd <destination>
  • Change the permissions using the below command
            > chmod -R 777 *