Jggug 2010 330 Grails 1.3 観察

1,761 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,761
On SlideShare
0
From Embeds
0
Number of Embeds
27
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Jggug 2010 330 Grails 1.3 観察

  1. 1. JGGUG japan grails/groovy user group def speaker = new Cast(name:”T.Yamamoto”,version:”G*-2010-03-30”)
  2. 2. 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
  3. 3. 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()
  4. 4. 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
  5. 5. 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()" }
  6. 6. @Test // test void () { assertEquals 0,0 } //@Test test void test OK () { shouldFail{ asdsdagdrgasf } }
  7. 7. @Ignore // JUnit4 void () { assertEquals 0,0 } @Test(timeout=2000L) // JUnit4 void () { Thread.sleep(3000) assertEquals 0,0 } }
  8. 8. import org.junit.* import static org.junit.Assert.* class SomeTest { ! //... ... }
  9. 9. grails.project.dependency.resolution = { ! pom true ! .. }
  10. 10. %grails maven-install ! %grails maven-deploy !
  11. 11. groupId group String group = 'jp.xmldo.grails' "org.grails.plugins" def version = '0.1'
  12. 12. % 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" } }
  13. 13. grails.project.dependency.resolution = { plugins { runtime 'jp.xmldo.grails:example-wiki:0.1' } }
  14. 14. 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 ' }
  15. 15. plugins { runtime( ':weceem:0.8' ) { transitive = false } runtime ':searchable:0.5.4' }
  16. 16. 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 }
  17. 17. class Item { static mapping = { priceWithTax formula: 'price * 1.05' // } String name Float price Float priceWithTax //... ... }
  18. 18. 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 (’ % ‘)
  19. 19. def list = Item.shippedInThree { and { lt 'price',20000F } }
  20. 20. <g:join in="['Grails', 'Groovy', 'Gradle']" delimiter="_"/> Grails_Groovy_Gradle % ./gradlew clean assemble
  21. 21. |-- 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.
  22. 22. Grails/Groovy http://www.jggug.org/

×