Tuesday, 16 June 2015

Create Package by Maven


Create the assembly.xml and call it from pom.xml.

assembly.xml
-----------------

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd">
<id>assembly</id>
  <formats>
    <format>jar</format>
  </formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>

<fileSet>
<outputDirectory>product/template-topologies</outputDirectory>
<directory>${env.HOME}/workspace/src/main/java/topologies</directory>
<includes>
<include>*.topology</include>
<include>**/*.*.topology</include>
</includes>
<fileMode>744</fileMode>
</fileSet>

 </fileSets>

 </assembly>



Main Pom.xml
------------------

    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.5.5</version>
        <dependencies>
          <dependency>
            <groupId>your.group.id</groupId>
            <artifactId>my-assembly-descriptor</artifactId>
            <version>1.0-SNAPSHOT</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <!-- This is where we use our shared assembly descriptor -->
              <descriptorRefs>
                <descriptorRef>assembly.xml</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>

Monday, 15 June 2015

How to execute scripts(.ksh,.sh stc) by maven

Use Maven exec plugin to execute the script.
In <executable> you can specify the type of file.
In <workingDirectory> provide the path to the script file.
In <arguments> provide the script file name and any parameter used inside the script.

       <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                         <execution>
                            <id>createSymLinks</id>
                            <phase>install</phase>
                            <goals>
                              <goal>exec</goal>
                                                        </goals>
                            <configuration>
                                      <executable>ksh</executable>
                                      <workingDirectory>${env.HOME}/config/src
                                      </workingDirectory>
                                      <arguments>
                                                  <argument>create_links.ksh</argument>
                                                  <argument>${BUILD_VERSION}</argument>
                                       </arguments>
                            </configuration>
                         </execution>
                   </executions>
        </plugin>

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...