JGGUG
                                             japan grails/groovy user group




def speaker = new Cast(name:”T.Yamamoto”,version:”G*-2010-03-30”)
class A {
                   static class B {}
                 }
                 new A.B()




boolean called = false
Timer timer = new Timer()
timer.schedule(new TimerTask() {
  void run() {
    called = true
  }
}, 0)
sleep 100
assert called
import   @Grab
@Grab(group='net.sf.json-lib',
      module='json-lib', version='2.3',
      classifier='jdk15')
import net.sf.json.groovy.*


         @Grab
@Grab('net.sf.json-lib:json-lib:2.3:jdk15')
def builder =
   new net.sf.json.groovy.JsonGroovyBuilder()
assert new File('foo.bar') == new File('example.txt')




Caught: Assertion failed:

assert new File('foo.bar') == new File
('example.txt')
       |                   |  |
       foo.bar             |  example.txt
                           false
import grails.test.*
import org.junit.*   //
//                     Test   OK
//       XxxxxTests
class ItemTest extends GrailsUnitTestCase {
    @Before void initialize() {
      super.setUp()  //
         println "initialize()"
     }

     @After void goodby() {
       super.tearDown()  //
         println "goodby()"
     }
@Test //                test
void                        () {
    assertEquals 0,0
}
//@Test         test
void test              OK      () {
    shouldFail{
      asdsdagdrgasf
    }
}
@Ignore // JUnit4
    void              () {
        assertEquals 0,0
    }

    @Test(timeout=2000L) // JUnit4
    void                   () {
        Thread.sleep(3000)
        assertEquals 0,0
    }
}
import org.junit.*
import static org.junit.Assert.*
class SomeTest {

! //...   ...
}
grails.project.dependency.resolution = {
 ! pom true
! ..
}
%grails maven-install
!
%grails maven-deploy
!
groupId                   group
String group = 'jp.xmldo.grails'

                      "org.grails.plugins"


def version = '0.1'
% grails maven-deploy --repository=myRepo




grails.project.dependency.distribution = {
  remoteRepository(id:"myRepo",
    u r l : " f i l e : / / 1 2 7 . 0 . 0 . 1 / U s e r s / t y a m a / m y r e p o s / m a v e n 2 / ")
}



grails.project.dependency.distribution = {
  remoteRepository(id:"myRepoScp",
    u r l : " s c p : / / 1 0 . 2 1 1 . 5 5 . 6 / v a r / w w w / h t m l / m y r e p o ") {
        authentication username:"tyama",
                                      privateKey:"${userHome}/.ssh/id_dsa"
    }
}
grails.project.dependency.resolution = {
  plugins {
    runtime 'jp.xmldo.grails:example-wiki:0.1'
  }
}
weceem
def dependsOn = [
    searchable:'0.5.4 > *',
    quartz:'0.4.1 > *',
]




            excludes
      plugins {
      ! ru n t i m e ( ' : w e c e e m : 0 . 8 ' ) {
      ! ! ex c l u d e s " s e a r c h a b l e "
      ! }
      ! ru n t i m e ' : s e a r c h a b l e : 0 . 5 . 4 '
      }
plugins {
  runtime( ':weceem:0.8' ) {
    transitive = false
  }
  runtime ':searchable:0.5.4'
}
def item = Item.get(1)
assert !item.isDirty() //     false
item.properties = params
if (item.isDirty()) {
   //
}




def item = Item.get(1)
assert !item.isDirty() //     false
item.properties = params
if (item.isDirty('name')) {
   //        name
}
class Item {
  static mapping = {
    priceWithTax formula: 'price * 1.05' //
    }

    String name
    Float price
    Float priceWithTax
    //...   ...
}
Grails-1.2                 :
   static namedQueries = {
     shippedInThree {
       def now = new Date()
       lt 'shipped', now + 3
     }
   }



def list = Item.shippedInThree.list(max: 10, offset: 5)
def list = Item.shippedInThree.count()
d e f l i s t = I t e m . s h i p p e d I n T h r e e . f i n d A l l B y N a m e L i k e (’ % ‘)
def list = Item.shippedInThree {
  and {
    lt 'price',20000F
  }
}
<g:join
  in="['Grails', 'Groovy', 'Gradle']"
  delimiter="_"/>

       Grails_Groovy_Gradle




% ./gradlew clean assemble
|--   application.properties
|--   grails-app
|--   plugins
|     |-- exampleHongo ←
|     |   |--plugin.xml ← 1.2.x
|     |-- exampleShibuya ←
% grails run-app
Welcome to Grails 1.2.1 - http://grails.org/
 ..   ..
The inplace plugin at [/works/experiment/20100330/tokyo/plugins/exampleHongo]
does not have a plugin.xml. Please run the package-plugin command inside the
plugin directory.
Grails/Groovy
http://www.jggug.org/

Jggug 2010 330 Grails 1.3 観察

  • 1.
    JGGUG japan grails/groovy user group def speaker = new Cast(name:”T.Yamamoto”,version:”G*-2010-03-30”)
  • 8.
    class A { static class B {} } new A.B() boolean called = false Timer timer = new Timer() timer.schedule(new TimerTask() { void run() { called = true } }, 0) sleep 100 assert called
  • 9.
    import @Grab @Grab(group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15') import net.sf.json.groovy.* @Grab @Grab('net.sf.json-lib:json-lib:2.3:jdk15') def builder = new net.sf.json.groovy.JsonGroovyBuilder()
  • 10.
    assert new File('foo.bar')== new File('example.txt') Caught: Assertion failed: assert new File('foo.bar') == new File ('example.txt') | | | foo.bar | example.txt false
  • 14.
    import grails.test.* import org.junit.* // // Test OK // XxxxxTests class ItemTest extends GrailsUnitTestCase { @Before void initialize() { super.setUp() // println "initialize()" } @After void goodby() { super.tearDown() // println "goodby()" }
  • 15.
    @Test // test void () { assertEquals 0,0 } //@Test test void test OK () { shouldFail{ asdsdagdrgasf } }
  • 16.
    @Ignore // JUnit4 void () { assertEquals 0,0 } @Test(timeout=2000L) // JUnit4 void () { Thread.sleep(3000) assertEquals 0,0 } }
  • 17.
    import org.junit.* import staticorg.junit.Assert.* class SomeTest { ! //... ... }
  • 20.
  • 21.
  • 22.
    groupId group String group = 'jp.xmldo.grails' "org.grails.plugins" def version = '0.1'
  • 23.
    % grails maven-deploy--repository=myRepo grails.project.dependency.distribution = { remoteRepository(id:"myRepo", u r l : " f i l e : / / 1 2 7 . 0 . 0 . 1 / U s e r s / t y a m a / m y r e p o s / m a v e n 2 / ") } grails.project.dependency.distribution = { remoteRepository(id:"myRepoScp", u r l : " s c p : / / 1 0 . 2 1 1 . 5 5 . 6 / v a r / w w w / h t m l / m y r e p o ") { authentication username:"tyama", privateKey:"${userHome}/.ssh/id_dsa" } }
  • 24.
    grails.project.dependency.resolution = { plugins { runtime 'jp.xmldo.grails:example-wiki:0.1' } }
  • 25.
    weceem def dependsOn =[ searchable:'0.5.4 > *', quartz:'0.4.1 > *', ] excludes plugins { ! ru n t i m e ( ' : w e c e e m : 0 . 8 ' ) { ! ! ex c l u d e s " s e a r c h a b l e " ! } ! ru n t i m e ' : s e a r c h a b l e : 0 . 5 . 4 ' }
  • 26.
    plugins { runtime( ':weceem:0.8' ) { transitive = false } runtime ':searchable:0.5.4' }
  • 30.
    def item =Item.get(1) assert !item.isDirty() // false item.properties = params if (item.isDirty()) { // } def item = Item.get(1) assert !item.isDirty() // false item.properties = params if (item.isDirty('name')) { // name }
  • 31.
    class Item { static mapping = { priceWithTax formula: 'price * 1.05' // } String name Float price Float priceWithTax //... ... }
  • 32.
    Grails-1.2 : static namedQueries = { shippedInThree { def now = new Date() lt 'shipped', now + 3 } } def list = Item.shippedInThree.list(max: 10, offset: 5) def list = Item.shippedInThree.count() d e f l i s t = I t e m . s h i p p e d I n T h r e e . f i n d A l l B y N a m e L i k e (’ % ‘)
  • 33.
    def list =Item.shippedInThree { and { lt 'price',20000F } }
  • 35.
    <g:join in="['Grails','Groovy', 'Gradle']" delimiter="_"/> Grails_Groovy_Gradle % ./gradlew clean assemble
  • 36.
    |-- application.properties |-- grails-app |-- plugins | |-- exampleHongo ← | | |--plugin.xml ← 1.2.x | |-- exampleShibuya ← % grails run-app Welcome to Grails 1.2.1 - http://grails.org/ .. .. The inplace plugin at [/works/experiment/20100330/tokyo/plugins/exampleHongo] does not have a plugin.xml. Please run the package-plugin command inside the plugin directory.
  • 45.