| [a7cde4d] | 1 | usePlugin 'groovy' |
|---|
| 2 | usePlugin 'maven' // Maven plugin to install artifact in local Maven repo. |
|---|
| 3 | |
|---|
| 4 | sourceCompatibility = '1.6' |
|---|
| 5 | targetCompatibility = '1.6' |
|---|
| 6 | |
|---|
| 7 | manifest.mainAttributes("Main-Class" : "org.mindscratch.mrhakibook.ParseMain") |
|---|
| 8 | |
|---|
| 9 | def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath |
|---|
| 10 | repositories { |
|---|
| 11 | // Use local Maven repo location. We don't need this if we only want to install |
|---|
| 12 | // an artifact, but we do need it if we want to use dependencies from the local |
|---|
| 13 | // repository. |
|---|
| 14 | mavenRepo urls: localMavenRepo |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | // Project configuration: |
|---|
| 18 | version = '1.0-SNAPSHOT' |
|---|
| 19 | group = 'org.mindscratch.mrhakibook' |
|---|
| 20 | |
|---|
| 21 | // The following line is not necessary. Default the install tasks depends on the |
|---|
| 22 | // jar task, but this means no tests and checks are executed when we use the |
|---|
| 23 | // install task. The following line makes the install tasks depend on the build task |
|---|
| 24 | // and now all tests and checks are done before install is executed. |
|---|
| 25 | install.dependsOn ':build' |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | repositories { |
|---|
| 29 | mavenCentral() // Define Maven central repository to look for dependencies. |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | dependencies { |
|---|
| 33 | groovy 'org.codehaus.groovy:groovy:1.6.7' // group:name:version is a nice shortcut notation for dependencies. |
|---|
| 34 | testCompile 'junit:junit:4.7' |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | task initProject(description: 'Initialize project directory structure.') << { |
|---|
| 39 | // Default package to be created in each src dir. |
|---|
| 40 | def defaultPackage = 'org/mindscratch/mrhakibook' |
|---|
| 41 | |
|---|
| 42 | ['java', 'groovy', 'resources'].each { |
|---|
| 43 | // convention.sourceSets contains the directory structure |
|---|
| 44 | // for our Groovy project. So we use this struture |
|---|
| 45 | // and make a directory for each node. |
|---|
| 46 | convention.sourceSets.all."${it}".srcDirs*.each { dir -> |
|---|
| 47 | def newDir = new File(dir, defaultPackage) |
|---|
| 48 | logger.info "Creating directory $newDir" // gradle -i shows this message. |
|---|
| 49 | newDir.mkdirs() // Create dir. |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | } |
|---|