Wednesday, March 24, 2010

google-code-prettify

I found another syntax highlighting tool. Check google-code-prettify out!.
I followed instructions from one of Philip Johnson's article.

Insert following lines to your <head/> element.

<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"/>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"/>


Make sure the prettyPrint() function invoked on load of your body tag.

<body onload="prettyPrint()">


Put your source codes between
<pre><code class="prettyprint">
and
</code></pre>
tag like follows.

<pre><code class="prettyprint linenums lang-java">/**
 * A class prints \"hello, world!\".
 *
 * @author Jin Kwon
 */
public class Hello {
    public static void main(String[] args) {
        System.out.println("hello, world!");
    }
}</code></pre>
Note that I had to put the first comment line("/**") to the end of the starting <pre ...>tag for the 'linenums' class works correctly.

And you will get following output.
/**
 * A class prints \"hello, world!\".
 *
 * @author Jin Kwon
 */
public class Hello {
    public static void main(String[] args) {
        System.out.println("hello, world!");
    }
}

I can't say that google-code-prettify is better than Alex Gorbatchev's SyntaxHighlighter.

Check latest dependencies and plugins with Maven

You can check the latest version of each dependency and plugin in your pom. See Versions Maven Plugin.
No additional settings are required. Just run built in goals like this.

$ mvn versions:display-dependency-updates
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'versions'.
[INFO] ------------------------------------------------------------------------
[INFO] Building test
[INFO] task-segment: [versions:display-dependency-updates]
[INFO] ------------------------------------------------------------------------
[INFO] [versions:display-dependency-updates {execution: default-cli}]
[INFO] artifact junit:junit: checking for updates from central
[INFO] No dependencies in Dependencies are using the newest version.
[INFO]
[INFO] The following dependencies in Dependencies have newer versions:
[INFO] junit:junit ........................................... 3.8.1 -> 4.8.1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Wed Mar 24 20:19:29 KST 2010
[INFO] Final Memory: 25M/255M
[INFO] ------------------------------------------------------------------------

$ mvn versions:display-plugin-updates
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'versions'.
[INFO] ------------------------------------------------------------------------
[INFO] Building test
[INFO] task-segment: [versions:display-plugin-updates]
[INFO] ------------------------------------------------------------------------
[INFO] [versions:display-plugin-updates {execution: default-cli}]
[INFO]
[INFO] The following plugin updates are available:
[INFO] maven-clean-plugin ....................................... 2.2 -> 2.4
[INFO] maven-compiler-plugin .................................. 2.0.2 -> 2.1
[INFO] maven-deploy-plugin ...................................... 2.4 -> 2.5
[INFO] maven-install-plugin ..................................... 2.2 -> 2.3
[INFO] maven-jar-plugin ......................................... 2.2 -> 2.3
[INFO] maven-resources-plugin ................................. 2.3 -> 2.4.2
[INFO] maven-surefire-plugin .................................. 2.4.3 -> 2.5
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING] maven-clean-plugin .......................... (from super-pom) 2.4
[WARNING] maven-deploy-plugin ......................... (from super-pom) 2.5
[WARNING] maven-install-plugin ........................ (from super-pom) 2.3
[WARNING] maven-jar-plugin ............................ (from super-pom) 2.3
[WARNING] maven-resources-plugin .................... (from super-pom) 2.4.2
[WARNING] maven-surefire-plugin ....................... (from super-pom) 2.5
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Wed Mar 24 19:35:48 KST 2010
[INFO] Final Memory: 25M/255M
[INFO] ------------------------------------------------------------------------