This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
static main(args){ | |
run( new File("src/main/resources/dsl.groovy")) | |
} | |
static run(File file){ | |
Script script = new GroovyShell().parse(file.text) | |
Message mes = new Message() | |
script.metaClass = createEMC(script.class,{ | |
ExpandoMetaClass emc -> | |
emc.hello = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.xml.MarkupBuilder | |
def writer = new StringWriter() | |
def xml = new MarkupBuilder(writer) | |
xml.example() { | |
person(name: 'hoge', type: 'hage'){ | |
city('Tokyo') | |
remarks('特に無し') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileTree(dir: 'src/main', includes: ['**/*.java','**/*.groovy']).each {File file -> | |
def path = relativePath(file.path) | |
def kind = path.split(/\./).toList().last() | |
def taskName = path - "src/main/${kind}/" - ".${kind}" | |
taskName = taskName.replaceAll('/','.') | |
task "$taskName"(type: JavaExec, dependsOn: classes){ | |
group = "Run" | |
description = "Run the $taskName program($kind)" | |
main = taskName | |
classpath sourceSets.main.output + sourceSets.main.runtimeClasspath |