Skip to content

Commit

Permalink
initial cut of Gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Sep 23, 2014
1 parent cbe9e9a commit 0aed6ac
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
31 changes: 31 additions & 0 deletions grails-gradle-plugin/build.gradle
@@ -0,0 +1,31 @@
apply plugin: 'groovy'
apply plugin: 'maven'

group = 'org.grails'

repositories {
maven { url "http://repo.spring.io/libs-release" }
mavenLocal()
mavenCentral()

}

dependencies {
compile gradleApi()
compile project(":grails-bootstrap"), {
exclude group:"org.fusesource.jansi", module:"jansi"
exclude group:"jline", module:"jline"
exclude group:"net.java.dev.jna", module:"jna"

// Ant
exclude group:"org.codehaus.groovy", module:"groovy-ant"
exclude group:"org.apache.ant", module:"ant"
exclude group:"org.apache.ant", module:"ant-launcher"
exclude group:"org.apache.ivy", module:"ivy"
exclude group:"org.apache.ant", module:"ant-trax"
exclude group:"org.apache.ant", module:"ant-junit"

exclude group:"org.codehaus.gant", module:"gant_groovy1.8"
}
compile "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
}
@@ -0,0 +1,56 @@
package org.grails.gradle.plugin.core

import grails.util.Environment
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.GroovyPlugin
import org.springframework.boot.gradle.SpringBootPlugin

class GrailsPlugin extends GroovyPlugin {

void apply(Project project) {
super.apply(project)

project.getPlugins().apply(SpringBootPlugin)


def projectDir = project.projectDir

def grailsSourceDirs = []
def excludedDirs = ['views', 'migrations', 'assets', 'i18n']
new File("$projectDir/grails-app").eachDir { File subdir ->
def dirName = subdir.name
if(!subdir.hidden && !dirName.startsWith(".") && !excludedDirs.contains(dirName)) {
grailsSourceDirs << subdir.absolutePath
}
}

grailsSourceDirs << "$projectDir/src/main/groovy"

def environment = Environment.current

println "ENVIRONMENT IS $environment"


project.sourceSets {
main {
groovy {
srcDirs = grailsSourceDirs
filter {
exclude "$projectDir/grails-app/conf/hibernate"
exclude "$projectDir/grails-app/conf/spring"
}
resources {
srcDirs = [
"$projectDir/grails-app/conf/hibernate",
"$projectDir/grails-app/conf/spring",
"$projectDir/grails-app/views",
"$projectDir/src/main/webapp"
]
}
}
}
}
}

}
@@ -0,0 +1 @@
implementation-class=org.grails.gradle.plugin.core.GrailsPlugin
5 changes: 4 additions & 1 deletion settings.gradle
Expand Up @@ -57,4 +57,7 @@ include 'grails-aether',
'grails-test-suite-web',

// Deprecated Compatibility Classes
'grails-compat'
'grails-compat',

// Gradle Plugin
'grails-gradle-plugin'

3 comments on commit 0aed6ac

@zyro23
Copy link
Contributor

@zyro23 zyro23 commented on 0aed6ac Oct 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think grails-app/conf could/should be used as a srcDir completely. maybe with excludes. using the 2.4.x branch, i found it very convenient to be able to place spring @Configuration classes into grails-app/conf/my/package/name, giving them a clear separation from regular src/(java|groovy) code

@burtbeckwith
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is partially, in that non-Groovy files there get copied from there to the classes directory by GrailsProjectPackager.packageConfigFiles(). But you can add extra directories under /src and they're treated as source directories; non-source files get copied to the classes directory and source files are compiled. You can even add multiple ones with self-documenting names like /src/configuration

@zyro23
Copy link
Contributor

@zyro23 zyro23 commented on 0aed6ac Oct 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see. missed the new File("$projectDir/grails-app").eachDir { ... } part. thanks for the quick feedback.

Please sign in to comment.