<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gridshore &#187; intellij</title>
	<atom:link href="http://www.gridshore.nl/tag/intellij/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gridshore.nl</link>
	<description>A weblog about software engineering, Architecture, Technology an other things we like.</description>
	<lastBuildDate>Tue, 13 Dec 2011 15:36:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My first steps with Gradle: creating a multi module java web project and running it with jetty.</title>
		<link>http://www.gridshore.nl/2010/09/08/my-first-steps-with-gradle-creating-a-multi-module-java-web-project-and-running-it-with-jetty/</link>
		<comments>http://www.gridshore.nl/2010/09/08/my-first-steps-with-gradle-creating-a-multi-module-java-web-project-and-running-it-with-jetty/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 09:34:06 +0000</pubDate>
		<dc:creator>jettro</dc:creator>
				<category><![CDATA[groovy and grails]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[wrapper]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/?p=1077</guid>
		<description><![CDATA[<p>I am a experienced maven user. Sometime I love it, sometimes I hate it. I like it a lot better than ant, but in some situation you would like maven to be easier and more descriptive. The past year there was a lot of fuzz about Gradle. This would give you the best of [...]]]></description>
			<content:encoded><![CDATA[<p>I am a experienced maven user. Sometime I love it, sometimes I hate it. I like it a lot better than ant, but in some situation you would like maven to be easier and more descriptive. The past year there was a lot of fuzz about Gradle. This would give you the best of ant as well as the best of maven, and even more. My first encounter was not very positive, but I kept it in my mind to try it later with a more serious project. This blogpost is about that second more serious try. It will not teach the gradle experts anything, but it will be an easy introduction in to what gradle has to bring for people that are just interested in gradle.</p>
<p><span id="more-1077"></span><br />
<h2>Project structure</h2>
<p>The structure of the project is fairly straightforward, but big enough to demonstrate some of the features that gradle has to offer. It consists of two modules:</p>
<ul>
<li>App</li>
<li>Web-ui</li>
</ul>
<p>We are creating an <a href="http://www.axonframework.org">Axonframework</a> sample, the app contains the command handling and for now the query part as well. The web-ui contains the spring mvc app with the controllers and the authentication using the spring-security framework. For now we make use of an in memory database and we want to be able to start the application without a lot of hassle. Using jetty in this case.</p>
<p>The modules have some shared dependencies for testing and logging. We also want to centralize the definition of some dependency versions.</p>
<h2>Multi module gradle build</h2>
<p>Gradle was build with multi module support from the start. So what do you need to create a multi-module build. We need a settings.gradle that defines the available modules. Next to that we need the main build.gradle as well as the modules build.gradle. Oke you can do without the per module configuration, but in my case that was not the intention. Let us focus first on the main build.gradle.</p>
<h3>Main build.gradle</h3>
<p>The main build.gradle is used to define some of the versions of the dependencies. The following code block shows the complete script.</p>
<pre class="brush: groovy; title: ; notranslate">
axonVersion = &quot;0.6&quot;
springVersion = &quot;3.0.4.RELEASE&quot;
springSecurityVersion = &quot;3.0.3.RELEASE&quot;
slf4jVersion = &quot;1.5.8&quot;
sourceCompatibility = 1.6

subprojects {
    apply plugin: 'java'

    configurations {
        all*.exclude group: &quot;commons-logging&quot;, module: &quot;commons-logging&quot;
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        compile &quot;org.slf4j:jcl-over-slf4j:$slf4jVersion&quot;,
                &quot;org.slf4j:jul-to-slf4j:$slf4jVersion&quot;
        runtime &quot;org.slf4j:slf4j-log4j12:$slf4jVersion&quot;

        compile(&quot;log4j:log4j:1.2.15&quot;) {
            exclude group: &quot;com.sun.jdmk&quot;, module: &quot;jmxtools&quot;
            exclude group: &quot;com.sun.jmx&quot;, module: &quot;jmxri&quot;
            exclude group: &quot;javax.mail&quot;, module: &quot;mail&quot;
            exclude group: &quot;javax.jms&quot;, module: &quot;jms&quot;
        }

        testCompile 'junit:junit:4.7'
    }

    group = 'org.axonframework.samples.trader'
    version = '1.0-SNAPSHOT'
    sourceCompatibility = 1.6
}
</pre>
<p>As you can see, the script starts with the definition of the versions of dependencies. Than the script contains information for all the subprojects. You see we define the java plugin for all subprojects. Next to that the repositories and the dependencies are defined. Have a look at the mechanism to exclude transitive dependencies. For log4j we explicitly exclude some transitive dependencies. We also use a mechanism to exclude commons-logging from the complete build. Using the configurations hook we exclude it for all phases.</p>
<p>Finally we also define the group, version and source compatibility in the build configuration.</p>
<p>That is it, the following code block shows the required settings.gradle and after that we move on with the build.gradle of the app and web-ui subprojects.</p>
<pre class="brush: groovy; title: ; notranslate">
include &quot;app&quot;, &quot;web-ui&quot;
</pre>
<h3>Subprojects build.gradle</h3>
<p>The build.gradle for the app project is almost to easy to show. But I promised I would, so here we go:</p>
<pre class="brush: groovy; title: ; notranslate">
dependencies {
    compile &quot;org.axonframework:axon-core:$axonVersion&quot;

    compile &quot;org.hibernate:hibernate-entitymanager:3.4.0.GA&quot;,
            &quot;c3p0:c3p0:0.9.1&quot;,
            &quot;org.hsqldb:hsqldb:1.8.0.10&quot;

    compile &quot;org.springframework:spring-tx:$springVersion&quot;,
            &quot;org.springframework:spring-orm:$springVersion&quot;,
            &quot;org.springframework:spring-jdbc:$springVersion&quot;

    compile &quot;com.thoughtworks.xstream:xstream:1.3.1&quot;

    testCompile &quot;org.axonframework:axon-test:$axonVersion&quot;
}
</pre>
<p>The configuration only contains dependencies. I would like to be able to simplify the dependencies on the spring projects. Would be nice if I could group them somehow, like:</p>
<p>compile group:&#8221;org.springframework&#8221;, version:&#8221;$springVersion&#8221;, module:["spring-webmvc", "spring-aop"]</p>
<p>But the build config looks pretty clean. Now we move on to the creation of the war for the web project.</p>
<pre class="brush: groovy; title: ; notranslate">
apply plugin: 'war'

dependencies {
    compile project(':app')

    compile &quot;org.springframework:spring-webmvc:$springVersion&quot;,
            &quot;org.springframework:spring-aop:$springVersion&quot;

    compile &quot;org.springframework.security:spring-security-web:$springSecurityVersion&quot;,
            &quot;org.springframework.security:spring-security-config:$springSecurityVersion&quot;

    compile &quot;javax.validation:validation-api:1.0.0.GA&quot;,
            &quot;org.hibernate:hibernate-validator:4.0.2.GA&quot;

    runtime &quot;javax.servlet:jstl:1.1.2&quot;,
            &quot;taglibs:standard:1.1.2&quot;,
            &quot;opensymphony:sitemesh:2.4.2&quot;

    providedCompile &quot;javax.servlet:servlet-api:2.5&quot;
}
</pre>
<p>Again a pretty straightforward config. We use more types of dependencies. We now introduce the providedCompile. Jars that need not be included in the war should have this config for the dependency. Do mark that we have an apply plugin line at the top for creating the war. Finally have a look at the mechanism to show we have a dependency on another module of the project. We use the <strong>compile project (&#8216;:app&#8217;) </strong>to make the war include this created jar as well.</p>
<h2>Running with Jetty</h2>
<p>You think the jetty plugin for maven is easy, well check this out. We have to change only one word in the web project config. Look for the first line with <strong>apply plugin</strong>. Change the word war into jetty and you are done. Now you can run jetty with the following command from the root of the project:</p>
<p><em>gradle :web-ui:jettyRun</em></p>
<h2>The wrapper</h2>
<p>People that have gradle installed on their system can easily build the project and run jetty. But some people might not have gradle installed. You can help them to make it very easy. Gradle comes with a wrapper that downloads gradle and makes sure it&#8217;s on your path etc. The only thing the user needs to do is the following in the root of the project:</p>
<p><em>gradlew build</em></p>
<p>Pay attention to the &#8216;w&#8217; at the end of the gradle command. Next step is to start jetty. This is done with the same command as before with one change, the w at the end. To help your users with this, you need to do one thing. You have to add the following task to the main build.gradle. Than run gradle wrapper, checkin the generated files into your source control system. The gradlew script can be used by the people to build the project. Good stuff or not?</p>
<pre class="brush: groovy; title: ; notranslate">
task wrapper(type: Wrapper) {
    gradleVersion = '0.9-rc-1'
    jarPath = 'wrapper'
}
</pre>
<h2>Intellij integration</h2>
<p>Oke, this kinda hurts to say, but intellij support is not at a level that you would like to. At least that is what I could find out. You can easily run gradle builds from intellij. That is all nice. But I am really missing the dependency management part. Would be great to have support like for maven to setup your complete project. Wouldn&#8217;t it be great to have the import from external model feature for gradle as well? For now let us all vote for this issue, it might help:</p>
<p><a href="http://youtrack.jetbrains.net/issue/IDEA-57755">﻿http://youtrack.jetbrains.net/issue/IDEA-57755</a></p>
<p>I hope someone from jetbrains reeds this at thinks I am important enough to start creating this plugin <img src='http://www.gridshore.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>Performance</h2>
<p>The last remarks I want to make are about the performance of gradle. At the moment I have this build for maven as well as gradle and maven2 is twice as fast as gradle. I know work is being done on this. Gradle 0.9.1 will support a new feature that at least will speed up building the project of you have to do it a lot during the day. It will do something with a running gradle service that you can call each time you start a build. There are some items on the mailing list about this specific topic if you are interested.</p>
<p><a href="http://gradle.markmail.org/thread/xbqna6lowvsmm4ve">http://gradle.markmail.org/thread/xbqna6lowvsmm4ve</a></p>
<h2>Concluding</h2>
<p>Well that was part one of the experiment. I have not touched everything by a long run. Still I found out I like the configuration of gradle a lot better than I like maven. It is a lot cleaner and let&#8217;s you focus on the things that are important. I prefer groovy for this kind of work over xml. Still gradle has some ground to cover. For starters, tool integration. We must have something that makes working with intellij a lot better. In the future I will have a better look at plugins for release management and other stuff that I think is necessary for a good project build.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2010%2F09%2F08%2Fmy-first-steps-with-gradle-creating-a-multi-module-java-web-project-and-running-it-with-jetty%2F&amp;title=My%20first%20steps%20with%20Gradle%3A%20creating%20a%20multi%20module%20java%20web%20project%20and%20running%20it%20with%20jetty.&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2010/09/08/my-first-steps-with-gradle-creating-a-multi-module-java-web-project-and-running-it-with-jetty/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Upgrading my books-overview flex, BlazeDS, Spring security application</title>
		<link>http://www.gridshore.nl/2010/02/17/upgrading-my-books-overview-flex-blazeds-spring-security-application/</link>
		<comments>http://www.gridshore.nl/2010/02/17/upgrading-my-books-overview-flex-blazeds-spring-security-application/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 19:54:02 +0000</pubDate>
		<dc:creator>jettro</dc:creator>
				<category><![CDATA[Frontend Technology]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flex 3]]></category>
		<category><![CDATA[flex-mojos]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[Spring BlazeDS]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/?p=1005</guid>
		<description><![CDATA[<p>In March 2008 I started experimenting with flex and java integration. I wrote a lot of blog posts since than and even published an article on adobe.com. For most of my blog items I used a sample that is available on google code called books-overview. During the years the sample improved a lot. By [...]]]></description>
			<content:encoded><![CDATA[<p>In March 2008 I started experimenting with flex and java integration. I wrote a lot of blog posts since than and even published an article on adobe.com. For most of my blog items I used a sample that is available on google code called <a href="http://code.google.com/p/gridshore">books-overview</a>. During the years the sample improved a lot. By now the sample consists of Mate, BlazeDS, Spring BlazeDS and a lot of other spring technologies like spring security.</p>
<p>I was some time a go I had a look at the sample, since than a lot of people keep coming back to it. I still get questions about it. Therefore I decided to upgrade the sample. This blog post is about the upgrade I did which are mainly upgrades in versions of the libraries and the build configuration. Still I think it is worthwhile to have a look at it.</p>
<p><span id="more-1005"></span>
<p>Before I start with this blog post I need to warn you that I am not going to explain a lot of the internals. Please browse my other <a href="http://www.gridshore.nl/tag/flex3/">flex 3 blog items</a> to find out more.</p>
<h2>Library upgrade</h2>
<h3>The client (flex) side</h3>
<p>For the flex building I use <a href="http://mate.asfusion.com/">Mate</a>. I think mate is a nice framework, but it is not very active. Not many improvements are created. Still it does the job. I am also creating a flex sample for the <a href="http://www.axonframework.org">Axon Framework</a> using <a href="http://www.spicefactory.org/parsley/">Parsley</a>. Stay tuned for a blog post that is around the corner about this sample. I upgrade the mate to release 0.8.9</p>
<p>Another framework I use on the flex side is the <a href="http://www.springactionscript.org/">spring-actionscript</a> project. This project changed a lot since the last time I used it. I am now using version 0.8.1. This project is now split up into a few other modules. I did have a problem with the StringUtils class. This is in as3commons:as3commons-lang. By transitive dependecy you get 0.1 of this library. I had to upgrade to version 0.2 to make it work.</p>
<h3>The serverside</h3>
<p>I did not upgrade a lot on the serverside. I could have upgrade to spring 3, I&#8217;ll wait till it becomes the default for the spring blazeds integration project. They still use version 2.5.6, so I&#8217;ll stick with that. I did upgrade the Spring Blazeds Integration project to the latest release: 1.0.2.RELEASE.</p>
<h2>Building and developing</h2>
<p>The biggest change was in the maven configuration. Flex-mojos made a lot of improvements and is now tightly integrated with Intellij. To me that is incredibly important. My development speed with flex has enormously increased.</p>
<p>I use flex-mojos version 3.5.0. The configuration is now very easy. For the war project you just need to add the following plugin plus configuration:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;plugin&gt;
    &lt;groupId&gt;org.sonatype.flexmojos&lt;/groupId&gt;
    &lt;artifactId&gt;flexmojos-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;${flex-mojos.version}&lt;/version&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;goals&gt;
                &lt;goal&gt;copy-flex-resources&lt;/goal&gt;
            &lt;/goals&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;
</pre>
<p>Now let us have a look at the configuration of the swf file. Again it is pretty straightforward. You have to add the flex-framework as a dependency.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
    &lt;groupId&gt;com.adobe.flex.framework&lt;/groupId&gt;
    &lt;artifactId&gt;flex-framework&lt;/artifactId&gt;
    &lt;version&gt;${flex.sdk.version}&lt;/version&gt;
    &lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;
</pre>
<p>Finally we have to configure the flex-mojos compiler plugin.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;plugin&gt;
    &lt;groupId&gt;org.sonatype.flexmojos&lt;/groupId&gt;
    &lt;artifactId&gt;flexmojos-maven-plugin&lt;/artifactId&gt;
    &lt;version&gt;${flex-mojos.version}&lt;/version&gt;
    &lt;extensions&gt;true&lt;/extensions&gt;
    &lt;configuration&gt;
        &lt;debug&gt;true&lt;/debug&gt;
        &lt;configurationReport&gt;true&lt;/configurationReport&gt;
    &lt;/configuration&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.adobe.flex&lt;/groupId&gt;
            &lt;artifactId&gt;compiler&lt;/artifactId&gt;
            &lt;version&gt;${flex.sdk.version}&lt;/version&gt;
            &lt;type&gt;pom&lt;/type&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.adobe.flex.compiler&lt;/groupId&gt;
            &lt;artifactId&gt;asdoc&lt;/artifactId&gt;
            &lt;version&gt;${flex.sdk.version}&lt;/version&gt;
            &lt;classifier&gt;template&lt;/classifier&gt;
            &lt;type&gt;zip&lt;/type&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/plugin&gt;
</pre>
<p>The <strong>configurationReport</strong> parameter is used by intellij. This creates an xml file that intellij uses to set you compiler properties in intellij. Very nice.</p>
<h3>Repositories</h3>
<p>I also want to mention the additional repositories I configured. I added a repository for libraries coming from flex-mojos and another library for the spring-actionscript libraries.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;repository&gt;
    &lt;id&gt;flexmojos-repository&lt;/id&gt;
    &lt;url&gt;http://repository.sonatype.org/content/groups/flexgroup/&lt;/url&gt;
&lt;/repository&gt;
&lt;repository&gt;
    &lt;id&gt;yoolab.org-releases&lt;/id&gt;
    &lt;url&gt;http://projects.yoolab.org/maven/content/repositories/releases&lt;/url&gt;
    &lt;releases&gt;
        &lt;enabled&gt;true&lt;/enabled&gt;
    &lt;/releases&gt;
&lt;/repository&gt;
</pre>
<p>The only library I still cannot find online is Mate. Therefore I added it to my google code repository. Please do the same thing if you need it for your own project. Do not use my repository because I will reach my maximum bandwidth and then I have to take it away again.</p>
<p>If you want to check out the state of the project while I was writing this blog, use the following tag:</p>
<p><a href="http://code.google.com/p/gridshore/source/browse/#svn/tags/books-overview-1.0.0">http://code.google.com/p/gridshore/source/browse/#svn/tags/books-overview-1.0.0</a></p>
<p>Hope this is helpfull when exploring my sample, feel free to post remarks, improvements and questions.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2010%2F02%2F17%2Fupgrading-my-books-overview-flex-blazeds-spring-security-application%2F&amp;title=Upgrading%20my%20books-overview%20flex%2C%20BlazeDS%2C%20Spring%20security%20application&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2010/02/17/upgrading-my-books-overview-flex-blazeds-spring-security-application/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Doing grails, yes I like it</title>
		<link>http://www.gridshore.nl/2009/11/09/doing-grails-yes-i-like-it/</link>
		<comments>http://www.gridshore.nl/2009/11/09/doing-grails-yes-i-like-it/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 07:30:54 +0000</pubDate>
		<dc:creator>jettro</dc:creator>
				<category><![CDATA[groovy and grails]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[google appengine]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[intellij]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/?p=920</guid>
		<description><![CDATA[<p>Last week I attended a groovy &#038; grails training by SpringSource. My first introduction into grails is about 2 years a go. I attended a talk at the spring experience. Back than I liked it, tried it, but did not really use it. By now a lot has changed, most of all very good [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gridshore.nl/wp-content/uploads/F0720E8F-2336-4FEE-BB96-7F8FA9B9FD9C.jpg" alt="F0720E8F-2336-4FEE-BB96-7F8FA9B9FD9C.jpg" border="0" width="134" height="117" align="left" />Last week I attended a <a href="http://www.springsource.com/training/grv001">groovy &#038; grails training</a> by SpringSource. My first introduction into grails is about 2 years a go. I attended a talk at the spring experience. Back than I liked it, tried it, but did not really use it. By now a lot has changed, most of all very good tool integration by <a href="http://www.jetbrains.com/idea/nextversion/">intellij</a>. Last week I had the change to go to a training, now I am motivated to start using grails more often.</p>
<p>This post I will talk you through a grails application I have created for a project of mine. I also take you through some of the things I learned last week. Finally I&#8217;ll show you that you can create a google app engine application using grails. There are ways to create grails applications, I&#8217;ll show you how to do it using the latest intellij 9 beta release.</p>
<p><span id="more-920"></span><br />
<h2>Training</h2>
<p>As mentioned in the introduction I attended the spring source groovy and grails training. The training was given by Peter Ledbrook, author of <a href="http://www.manning.com/gsmith/">grails in action</a>. I am not going to give a detailed description of the training. I did like the training, it gave a good overview of the possibilities of grails as well as the groovy language. And yes, I am now very interested in the options of groovy. Especially for creating web based applications with grails, groovy just shines. Not sure when I should use groovy and when normal java. Have to explore to find out. Some of the things I liked about groovy are:</p>
<ul>
<li>Assignment of parameters that are evaluated immediately ${age} or when used ${->age}</li>
<li>Using negative indexes in arrays: [1 .. -2] strips of the first and last item from an array</li>
<li>Groovy truth, explicit use of values in a comparison. null, 0, &#8220;&#8221; and [] are all false in a comparison</li>
<li>Closures, still hard to determine when to use a closure and when a method. But closures are used very often in groovy.</li>
<li>Out of the box test integration with things like: MockFor, Expando, and as a plugin GMock.</li>
</ul>
<p>Of course we learned a lot more than this, check the training or the book yourself if you want more. Next up was grails. I did look at grails before at grails, but tool support was pretty limited back than, and the plugins were not really widely available. A lot has changed since than. SpringSource came out with grails support in SpringSource Tool Suite, and Intellij has grails support as well. To be honest, intellij was much more productive than STS. Actually STS was almost not useable. Since it was the first release with grails support it will most probably improve the coming releases. Intellij worked very nice out of the box (I did use the beta version of intellij 9. Some of the features I liked during the training are:</p>
<ul>
<li>Gorm, I must mention this Groovy/Grails Object Relational Mapping framework first. This is very important for grails and why it is so productive. I just love these dynamic finders (more later).</li>
<li>Plugin architecture, the easy of installtion and usage of plugins is very nice. I like the db-util plugin for its simplicity and the help when working with internal memory databases. A killer plugin during development.</li>
<li>Scaffolding, for auto responding to CRUD like operations.</li>
<li>flash parameter to be used for adding something to the session for just one request. Ideal for passing messages.</li>
<li>Using templates, ideal for doing ajax calls and reuse of small view elements.</li>
</ul>
<p>Oke time to get our hands dirty, next up is a short introduction in the sample I am going to create. Than some code (which is acutally not that much)</p>
<h2>The application to create</h2>
<p>For a customer at <a href="http://www.jteam.nl">JTeam</a>, we have a large amount of servers that we need to prepare. The actual preparation is mostly done by the hosting provider. Sometime we have no idea what the status is of some servers. We started to use an excel sheet to communicate the status among our team. This is not ideal and I decided to create a small grails application for this. It&#8217;s all very basic, but useable.</p>
<p>Every server has a status, some comments and an external ip address. Each server is also part of a number of vlans and belongs to an environment (dev,test,accep,prod).</p>
<h2>The code</h2>
<p>The code is available online at github. Yes I know, it is not at google code. I got extra motivated to start using git since the training. Peter was working so flexible with his source code, I want that too. The best way to learn something is by doing it. Therefore I create a git repository at github. You can find out more at the following url. There is a very easy way to download the complete source code without using git, check the page.</p>
<p><a href="http://github.com/jettro/MyServerPark">http://github.com/jettro/MyServerPark</a></p>
<h2>The basics</h2>
<p>Starting a grails project is very well documented on the grails website. Except for one controller, the OverviewController, all controllers use: def scaffold = true. Which means I don&#8217;t write any code. Also not view components. I did create some domain classes that have relationships with each other. The next sections cover the different elements of the application.</p>
<h3>The domain model</h3>
<p><img src="http://www.gridshore.nl/wp-content/uploads/DomainModelServerpark.png" alt="DomainModelServerpark.png" border="0" width="555" height="376" align=" center" /></p>
<p>Some things to know about the domain model:</p>
<ul>
<li>belongsTo is used to declare a relationship of many-to-one, the next line gives an example for Comment. This gives the comment a property server.</li>
<p>static belongsTo = [server:Server]</p>
<li>The comment class also gives meta data about the mapping and the type used for the database as well as constraints. In the example we create a field for larger amounts of text.</li>
<pre class="brush: groovy; title: ; notranslate">
class Comment {
    String name
    String content

    static belongsTo = [server:Server]

    static mapping = {
        content type: &quot;text&quot;
    }

    static constraints = {
        name(blank:false, maxSize:50)
        content(blank:false, widget:&quot;textarea&quot;)
    }
}
</pre>
<li>The previous code block also shows one of the things that might be a bit strange. With <strong>widget:&#8221;textarea&#8221;</strong> you indicate the type of field to be used at the front end. Might be a bit strange in a domain model.</li>
<li>A one-to-many relationship is also easy to implement, check the following line from Environment:</li>
<p>static hasMany = [servers:Server]
</ul>
<p>Check the code for more examples of relationships.</p>
<h3>Scaffolding controllers and views</h3>
<p>Grails makes use of scaffolding, this can be static and dynamic. In the static case, code is being generated and can be altered. The dynamic case is evaluated runtime. In this project I tried to use dynamic scaffolding as much as possible. Usability might not always be what you want. In that case you should use static scaffolding or create something yourself. I managed to do well with the scaffolding on dynamic (except for the google app engine sample). But let us focus on the customer controller.</p>
<h2>The overview controller</h2>
<p>Grails makes use of convention over configuration. This is also true for controllers and views. The overview controller listens to the /overview url and points to the overview.gsp file. The following code block gives the complete OverviewController groovy class.</p>
<pre class="brush: groovy; title: ; notranslate">
class OverviewController {
    def show = {
        redirect(uri:&quot;/server/show/${params.id}&quot;)
    }

    def comments = {
        def currentServer = Server.findById(params.id.toLong())
        def allComments = Comment.withCriteria {
            server {
                eq(&quot;id&quot;,currentServer.id)
            }
        }
        render(template:&quot;/shared/comment&quot;,model:[comments:allComments, server:currentServer])
    }

    def index = {
        def environments = Environment.list()
        [environments:environments]
    }
}
</pre>
<p>There are three methods in the controller. The show does a redirect to the show method of the server controller. The index returns list of all environments and uses the view index.gsp. The comments method is a different cup of thee. This responds to an ajax call and returns a fragment. focus on the last line for now. You can see we use the render call. This makes use of a template. Using the render call, we obtain the html and push it back to the client. The section about views will give a bit more detail. Next up are the dynamic finders</p>
<h3>Dynamic finders</h3>
<p>The previous code block gives a few examples of finders. In index we obtain all the environments with <strong>Environment.list()</strong>. This is the most basic finder. Another finder is in the comments method. There we obtain the server by an id. The call is findServerById and you provided an id. Another calls could be: findByFunction, findByFunctionLike &#8220;%database%&#8221;, findByFunctionIlike &#8220;%DataBase%&#8221;. You can also make combinations with And/Or and multiple parameters. Pretty cool.</p>
<p>The comments method also shows the Criteria API for looking up all comments for a specific server. These type of queries, limited by a related item, are not supported by the dynamic finders.</p>
<h3>Gsp for views</h3>
<p>Creating the views is not very hard. If you want to learn how it works, I suggest generating the scaffolding views. I want to focus on something that is just a little bit more advanced. Ajax calls. In my project I want to obtain all comments for a server using an ajax call. In the overview page we use a special tag from grails, the remoteLink. This tag does an ajax call to the server and prints the result in the div with provided id.</p>
<p>&lt;g:remoteLink action=&#8221;comments&#8221; params=&#8221;[id:server.id]&#8221; update=&#8221;comments&#8221;&gt;comments&lt;/g:remoteLink&gt;</p>
<p>As you can see, we provide the <strong>server.id</strong> and we update the div with id <strong>comments</strong>.</p>
<p>This does not work out of the box, you must specify the prototype javascript library to be included. You can do this in the file:</p>
<p>views > layouts > main.gsp</p>
<p>Add the following line:</p>
<p>&lt;g:javascript library=&#8221;prototype&#8221; /&gt;</p>
<p>Now everything should be fine and you can test the application. A command like grails run-app should be enough.</p>
<h2>Documentation</h2>
<p>If you want more information about grails, try the following references:</p>
<ul>
<li><a href="http://grails.org/doc/1.1.x/">http://grails.org/doc/1.1.x/</a></li>
<li><a href="http://groovy.codehaus.org/groovy-jdk/">http://groovy.codehaus.org/groovy-jdk/</a></li>
<li><a href="http://www.manning.com/gsmith/">http://www.manning.com/gsmith/</a></li>
<li><a href="http://www.jetbrains.com/idea/nextversion/index.html">http://www.jetbrains.com/idea/nextversion/index.html</a></li>
<li><a href="http://www.springsource.com/training/grv001">http://www.springsource.com/training/grv001</a></li>
<li><a href="http://www.springsource.com/products/sts">http://www.springsource.com/products/sts</a></li>
</ul>
<h2>Grails and google app engine</h2>
<p>Grails uses plugins for all additional functionality. There is also a plugins available for google app engine. There is already good documentation available for this plugin. Therefore I keep this short. The following code block shows the commands. For more information, check the website of the plugin:</p>
<p><a href="http://grails.org/plugin/app-engine">http://grails.org/plugin/app-engine</a><br />
<br/></p>
<pre>
# grails create-app share-this
# grails uninstall-plugin hibernate
# grails install-plugin app-engine
choose jpa when asked
# export APPENGINE_HOME=&lt;path to your sdk install of google app engine&gt;
# grails app-engine run
# grails set-version 1
# grails app-engine package
# $APPENGINE_HOME/bin/appcfg.sh update ./target/war
# grails install-plugin gorm-jpa
</pre>
<p>Than I used intellij to create some domain classes and controllers. Take the following into consideration.</p>
<ul>
<li>Put domain classes in a package or it won&#8217;t work</li>
<li>Put Controller classes in the same package</li>
<li>generate views, the auto scaffolding seems not to work.</li>
</ul>
<p>You can look at the result here : <a href="http://share-this.appspot.com/">http://share-this.appspot.com/</a>. It could well be that the app does not start the first time, a refresh might help. I&#8217;ll have a look at this in the future. There is a problem with the CPU consumption and my grails application.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2009%2F11%2F09%2Fdoing-grails-yes-i-like-it%2F&amp;title=Doing%20grails%2C%20yes%20I%20like%20it&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2009/11/09/doing-grails-yes-i-like-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java on Google app engine with intelliJ</title>
		<link>http://www.gridshore.nl/2009/04/08/java-on-google-app-engine-with-intellij/</link>
		<comments>http://www.gridshore.nl/2009/04/08/java-on-google-app-engine-with-intellij/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:19:02 +0000</pubDate>
		<dc:creator>jettro</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google appengine]]></category>
		<category><![CDATA[intellij]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/?p=737</guid>
		<description><![CDATA[<p>This is a short post about the new java support for google appengine. The Basic steps are described very well at google, check the getting started manual. Here I just describe my experiences with my first java based application for google appengine. I concentrate on the usage of intellij. In coming posts I will [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gridshore.nl/wp-content/uploads/appengine-silver-120x30.gif" alt="appengine-silver-120x30.gif" border="0" width="120" height="30" align="left" />This is a short post about the new java support for google appengine. The Basic steps are described very well at google, check the <a href="http://code.google.com/appengine/docs/java/gettingstarted/">getting started manual</a>. Here I just describe my experiences with my first java based application for google appengine. I concentrate on the usage of intellij. In coming posts I will create the same application as the one I used for my previous post: <a href="http://www.gridshore.nl/2008/10/09/using-google-appengine/">using google appengine</a>.</p>
<p><span id="more-737"></span><br />
<h2>Quick intro</h2>
<p>For an eclipse user there are other steps to get things done. There is something like a plugin that might work depending on other plugins that you have installed and some eclipse magic. Sorry, I am a non believer. I prefer another IDE.</p>
<p>So for the non eclipse guys you need to download a zip file with all the resources you need to start working with the new sdk. I create a symbolic link to the downloaded version, that way it is easy to change for future releases.</p>
<p><code>ln -s appengine-java-sdk-1.2.0/ appengine-java-sdk</code></p>
<p>As the getting started suggest, you can now test your infrastructure with one of the provided demo&#8217;s.</p>
<p><code>./appengine-java-sdk/bin/dev_appserver.sh appengine-java-sdk/demos/guestbook/war/</code></p>
<p>Open your browser and go to the link <a href="http://localhost:8080/">http://localhost:8080/</a>. You should see the following screen.</p>
<div style="text-align:center;"><img src="http://www.gridshore.nl/wp-content/uploads/screendump-google-demoapp.png" alt="Screendump_google_demoapp.png" border="0" width="300" height="190" /></div>
<p>Oke, time to take the next step. The structure for an application is the same as for a web archive. There is a catch, you cannot use the war file itself, you need the exploded directory. Luckily it is very easy to do this with maven or with Intellij. Those eclipse users that are still reading this post have an easier life. They can use the wizard from the google plugin. I start off with a normal intellij java project with a web facet.</p>
<p>Google app engine works with servlets, so we need to create a servlet, we also need to add this servlet to the web.xml. Since the code I used is at the google tutorial, I&#8217;ll not repeat it here.</p>
<p>Google appengine needs an additional xml configuration file. This file is called <em></em> and it looks like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
    &lt;application&gt;&lt;/application&gt;
    &lt;version&gt;1&lt;/version&gt;
&lt;/appengine-web-app&gt;
</pre>
<p>Next step in intelliJ is to make the module, you can find the exploded war in the folder out > exploded > GoogleAppEngineGuestbookWeb. Using this exploded folder you can start the appengine. We need a runner in intellij. This is not very hard to do.There are two important steps. The first step is to create a library that you add to your module. This library contains one jar file : <strong>appengine-tools-api.jar</strong>. You can find this jar in the distribution of google appengine you downloaded. If you do not know how to add a library, open the module settings (apple: command + <img src='http://www.gridshore.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Create a new library and when asked say yes to add it to your module. The screen should look like the following image.</p>
<div style="text-align:center;"><img src="http://www.gridshore.nl/wp-content/uploads/intellij-configure-library.png" alt="Intellij_configure_library.png" border="0" width="400" height="261" /></div>
<p>Next up is configuring a runner. Create a runner of type <strong>Application</strong>. Now use the script <strong>dev_appserver.sh</strong>, that you can find in the distribution of google appengine in the bin folder. We need to set the environment variables, the program parameters and the main class.</p>
<h3>Main class</h3>
<p><code>com.google.appengine.tools.KickStart</code></p>
<h3>Program parameters</h3>
<p><code><br />
com.google.appengine.tools.development.DevAppServerMain<br />
out/exploded/GoogleAppEngineGuestbookWeb<br />
</code></p>
<p>Check the second parameter, this is the location of the exploded war file that intellij creates for you.</p>
<h3>Environment variables</h3>
<p><code><br />
SDK_LIB=YOUR_GOOGLE_APPENGINE_HOME/appengine-java-sdk/lib<br />
SDK_CONFIG=YOUR_GOOGLE_APPENGINE_HOME/appengine-java-sdk/config/sdk<br />
</code></p>
<p>The screen for configuring your runner now looks like this</p>
<div style="text-align:center;"><img src="http://www.gridshore.nl/wp-content/uploads/intellij-configure-runner.png" alt="Intellij_configure_runner.png" border="0" width="600" height="363" /></div>
<p>That is about it, now you can run the application. After running, the output in the console is:</p>
<p><code><br />
2009-04-08 23:53:44.332 java[3557:10b] [Java CocoaComponent compatibility mode]: Enabled<br />
2009-04-08 23:53:44.333 java[3557:10b] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000<br />
The server is running at http://localhost:8080/<br />
</code></p>
<p>Now you can point your browser to the following url : <a href="http://localhost:8080/guestbook">http://localhost:8080/guestbook</a> and <strong>Hello world</strong> should be yours.</p>
<h2>Deployment</h2>
<p>Before you can upload, you need to register yourself with google. If you already have an appengine account, you can request the java beta admittance. After that create a new google appengine application in your domain. That&#8217;s it, remember the name of the app you just registered because you need it in the next step.</p>
<p>Next up is the actual deployment, this is not a very complicated process. You can use the same directory that you use for the test server. Be sure to change the file <strong>appengine-web.xml</strong>. Add your name of the application to the application tag. If your using intellij do not forget to make the module. In my case this application name is doingjava. Now all you need during the upload is your google account name and password. Next is the command to do the actual upload</p>
<p><code><br />
./appengine-java-sdk/bin/appcfg.sh update PATH_TO_YOUR_INTELLIJAPP/out/exploded/GoogleAppEngineGuestbookWeb<br />
</code></p>
<p>In my case you can check if it works on the following url: <a href="http://doingjava.appspot.com/guestbook">http://doingjava.appspot.com/guestbook</a>.</p>
<h2>Conclusion</h2>
<p>This is not a conclusion on the usage of google appengine and java. For me it was an exercise to create a project in intellij and be able to use the google mock webapp runner. This seems to work nicely. The future will bring more posts about google appengine which now support java.</p>
<p>I do want to stress this is not a best practice, I advise to use an ant script that you can get from google at the following url. <a href="http://code.google.com/appengine/docs/java/tools/ant.html">http://code.google.com/appengine/docs/java/tools/ant.html</a></p>
<h2>Some important url&#8217;s</h2>
<ul>
<li><a href="http://www.gridshore.nl/2008/10/09/using-google-appengine/">http://www.gridshore.nl/2008/10/09/using-google-appengine/</a></li>
<li><a href="http://appengine.google.com/">http://appengine.google.com/</a></li>
<li><a href="http://code.google.com/appengine/docs/java/gettingstarted/">http://code.google.com/appengine/docs/java/gettingstarted/</a></li>
<li><a href="http://code.google.com/appengine/docs/java/tools/ant.html">http://code.google.com/appengine/docs/java/tools/ant.html</a></li>
</ul>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2009%2F04%2F08%2Fjava-on-google-app-engine-with-intellij%2F&amp;title=Java%20on%20Google%20app%20engine%20with%20intelliJ&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2009/04/08/java-on-google-app-engine-with-intellij/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>JetBrains Teamcity &#8211; your continuous build to the next level</title>
		<link>http://www.gridshore.nl/2008/02/05/jetbrains-teamcity-your-continuous-build-to-the-next-level/</link>
		<comments>http://www.gridshore.nl/2008/02/05/jetbrains-teamcity-your-continuous-build-to-the-next-level/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 20:30:30 +0000</pubDate>
		<dc:creator>jettro</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[intellij]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/02/05/jetbrains-teamcity-your-continuous-build-to-the-next-level/</guid>
		<description><![CDATA[<p>As a lot of you, I am working on larger projects with more than 10 developers, most of the time there are some offshore resources as well. Of course we are using continuous integration, we program our unit tests and run them on every build. Still it happens that people do a mvn clean [...]]]></description>
			<content:encoded><![CDATA[<p><img height="44" style="margin: 5px; float: left" width="124" alt="" src="http://www.gridshore.nl/wp-content/logo.gif" />As a lot of you, I am working on larger projects with more than 10 developers, most of the time there are some offshore resources as well. Of course we are using continuous integration, we program our unit tests and run them on every build. Still it happens that people do a mvn clean install before checking in and after checking in the build fails. Now Teamcity offers a very nice way to execute a build before the actual commit takes place. And you know what, it actually works. When everybody uses the pre-commit build on server, you can also have a look at pending changes. So you know what is coming, and therefore can anticipate on merge problems or test conflicts.</p>
<p>Some of the things I like so far:</p>
<ul>
<li>Support for multiple runners like ant and maven2 but also some .Net things.</li>
<li>Good integration with version control system, able to see change sets, who did what, etc.</li>
<li>Very nice and intuitive interface.</li>
<li>Historical view on all builds including results like build log and test results.</li>
<li>Good integration with IntelliJ (there is also a plugin for eclipse but I have not tested it yet). With the plugin you can execute builds, watch pending changesets, initiate a remote pre-commit build. This is integrated with the source control plugin, so you can push the button run pre-commit while in the same screen as you were before. The image below gives you a nice view of the running build (if you put on your glasses).</li>
</ul>
<p><img height="233" style="margin: 5px" width="600" alt="" src="http://www.gridshore.nl/wp-content/screenteamcityplugin.jpg" /></p>
<p>The next image gives you an impression of the build overview screen. You can see a difference between builds initiated on the server and the ones initiated from intellij. The ones from intellij have a small pictogram of a person below the build number.</p>
<p><img height="407" style="margin: 5px" width="700" alt="" src="http://www.gridshore.nl/wp-content/screenteamcitywebsite.jpg" /></p>
<p>The best part, you can use Teamcity free of charge with some limitations in the amount of builders, or agents (3) and the amount of users (20). Still this gives you an excellent opportunity to do a test drive.</p>
<p>If you want more information or want to try it out yourself, go to the following website: <a href="http://www.jetbrains.com/teamcity/">http://www.jetbrains.com/teamcity/</a></p>
<p style="color:#008;text-align:right;"><small><em>Powered by</em> <a href="http://www.qumana.com/">Qumana</a></small></p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F02%2F05%2Fjetbrains-teamcity-your-continuous-build-to-the-next-level%2F&amp;title=JetBrains%20Teamcity%20-%20your%20continuous%20build%20to%20the%20next%20level&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/02/05/jetbrains-teamcity-your-continuous-build-to-the-next-level/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

