Tuesday, 14 January 2014

Java - re-using test classes across different projects | modules | packages

Reference:
http://blog.frankel.ch/re-use-your-test-classes-across-different-projects

In the POM.xml of the project|module that you have your testing code in src/test/java, include this plugin:
<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The test artifact is stored side-by-side with the main artifact once deployed in the repository. Note that the configured test-jar is bound to the install goal. E.g:
[your project|module name]/src/main/
[your project|module name]/src/test/


In the other project|module POM.xml, include this dependency:
<dependency>
  <groupId>com.rookiegeek.foobar</groupId>
  <artifactId>foo-bar</artifactId>
  <version>1.0.0</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

The type has to be test-jar instead of simply jar in order to Maven to pick the attached artifact and not the main one. Also, note although you could configure the dependency with a classifier instead of a type, the current documentation warns about possible bugs and favor the type configuration.

Monday, 16 December 2013

How to list and sort directories by size in Linux/Unix

Had a brain freeze and forgot how to list all files within a directory and sort by size - google returned me this awesome gem:
du -k | sort -nr | more

Or human readable output:
du -sh

http://snippets.aktagon.com/snippets/86-how-to-list-and-sort-directories-by-size-in-linux-unix

Thursday, 7 November 2013

CQ component - disable target in context menu

http://aemfaq.blogspot.com.au/2013/05/how-to-disable-target-context-menu-in.html

The "target" option in the context menu of a CQ component can be hidden/disable by setting cq:editConfig/cq:disableTargeting to true.


In code level:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:dialogMode="floating"
    jcr:primaryType="cq:EditConfig" cq:disableTargeting="{Boolean}true"/>


Reference: http://forums.adobe.com/message/5334713

Wednesday, 23 October 2013

Cygwin - finding out what package to install

http://www.trueblade.com/knowledge/finding-which-cygwin-package-contains-a-particular-file

Cygwin's cygcheck utility for finding out package needed:
cygcheck -p strings.exe

This will tell you that strings.exe is in binutils. If you know that it's an executable you're looking for, it's best to add the ".exe" extension. If you look for just "strings", you get a list of 144 packages that contain a file with the word "strings" in the filename.