Friday, 24 August 2018

How to sort content of a file based on multiple columns in UNIX


For e.g.

We have below data in a file and we want to sort based on the date.
We can sort this by :
 1st sort based on YYYY   ( -k 4n ) Sort 4th column based on number
 2nd sort based on MON    (-k 3M)  Sort 3rd column based on Month
 3rd sort based on DD
 4th sort based on TIME

test.txt
--------
Sun,  20  Aug 2018 23:11:10 GMT   1.0.0-MASTER-20180801-171
Wed, 22  Mar 2019 22:11:10 GMT  1.0.0-20180823-263
Mon, 22  Apr 2018 21:11:10 GMT  1.0.0-20180823-265
Wed, 28  Feb 2018 21:11:09 GMT  1.0.0-20180823-263
Tue,  28  Feb 2018 21:11:10 GMT   1.0.0-20180823-263
Wed, 21  Jan 2020 23:11:10 GMT  1.0.0-20180823-243


sort -k 4n -k 3M -k 2n -k 5n test.txt > sortedTest.txt


Thursday, 23 August 2018

How to deploy an external artifact to repository in pom.xml


We can use "maven-deploy-plugin" to upload any artifact to repository from a location by pom.xml.
By this we can upload any artifact without uploading the generated artifacts, also without install/deploy goal.

....
</plugins>
....
<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <executions>
        <execution>
            <id>deploy-file</id>
            <phase>clean</phase> <!-- The phase in which you want to upload the file to Repository . In this case "mvn clean " goal will upload the artifact.-->
            <goals>
                <goal>deploy-file</goal>
            </goals>
            <configuration>
<repositoryId>maven-public</repositoryId>  <!-- This is the id which contains the user/pass to connet to Nexus. This will be under "servers" section in settings.xml -->
                <file>C:\Users\bismayam\Desktop\poc.jar</file>
                <url>http://<host>:<port>/nexus/content/repositories/test-releases/</url>
                <groupId>testGroup</groupId>
                <artifactId>testArtifact</artifactId>
                <version>1.0</version>
                <packaging>jar</packaging>
            </configuration>
        </execution>
    </executions>
</plugin>
</plugins>

Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...