Permalink
Browse files

initial commit

  • Loading branch information...
1 parent c806b91 commit 61b2ecf99452c4e1b11c4406884f9dfd28dbc948 Karol Balejko committed Oct 29, 2012
View
@@ -0,0 +1,14 @@
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/groovy"/>
+ <classpathentry kind="src" path="grails-app/conf"/>
+ <classpathentry kind="src" path="grails-app/controllers"/>
+ <classpathentry kind="src" path="grails-app/domain"/>
+ <classpathentry kind="src" path="grails-app/services"/>
+ <classpathentry kind="src" path="grails-app/taglib"/>
+ <classpathentry kind="src" path="test/integration"/>
+ <classpathentry kind="src" path="test/unit"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="web-app/WEB-INF/classes"/>
+</classpath>
View
@@ -0,0 +1,8 @@
+.settings
+.svn
+target
+web-app/WEB-INF/
+*.iml
+*.ipr
+*.iws
+.idea/
View
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>modules-manager</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.springsource.sts.grails.core.nature</nature>
+ <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,17 @@
+class ModulesManagerGrailsPlugin {
+ def version = "0.1.0"
+ def grailsVersion = "2.0 > *"
+ def dependsOn = [:]
+ def pluginExcludes = [
+ "grails-app/views/error.gsp"
+ ]
+ def title = "Resources Modules Manager Plugin"
+ def author = "Karol Balejko"
+ def authorEmail = "kb@groovydev.com"
+ def description = 'Create resources modules from maven central dependencies.'
+ def documentation = "http://grails.org/plugin/modules-manager"
+
+ def license = "APACHE"
+ def organization = [ name: "GroovyDev", url: "http://groovydev.com/" ]
+ def scm = [ url: "https://github.com/groovydev/modules-manager-grails-plugin" ]
+}
View
@@ -1,2 +1,39 @@
-modules-manager-grails-plugin
-=============================
+Modules Manager Grails Plugin
+==============================
+
+Usage
+=====
+
+Define js & css dependency.
+
+grails-app/config/BuildConfig.groovy :
+
+ ...
+ dependencies {
+ compile 'org.webjars:bootstrap:2.1.1'
+ compile 'org.webjars:backbonejs:0.9.2'
+ compile 'org.webjars:jquery-mobile:1.2.0'
+ }
+ ...
+
+Create resources modules
+
+ grails refresh-modules
+
+Manager will create config/Modules**Resources.groovy and js/css files in web-app/modules/
+
+To force override re-create resources modules
+
+ grails refresh-modules --force
+
+
+Note
+====
+
+Module manager support resource
+
+
+History
+=======
+
+0.1.0 Initial version
View
@@ -0,0 +1,4 @@
+#Grails Metadata file
+#Mon Oct 29 14:43:26 CET 2012
+app.grails.version=2.1.0
+app.name=modules-manager
@@ -0,0 +1,20 @@
+grails.project.work.dir = 'target'
+
+grails.project.dependency.resolution = {
+
+ inherits 'global'
+ log 'warn'
+
+ repositories {
+ grailsCentral()
+ mavenCentral()
+ }
+
+ plugins {
+ build(":tomcat:$grailsVersion",
+ ":release:2.0.4",
+ ":rest-client-builder:1.0.2") {
+ export = false
+ }
+ }
+}
@@ -0,0 +1,6 @@
+log4j = {
+ error 'org.codehaus.groovy.grails',
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
+}
@@ -0,0 +1,43 @@
+dataSource {
+ pooled = true
+ driverClassName = "org.h2.Driver"
+ username = "sa"
+ password = ""
+}
+hibernate {
+ cache.use_second_level_cache = true
+ cache.use_query_cache = false
+ cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
+}
+// environment specific settings
+environments {
+ development {
+ dataSource {
+ dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
+ url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
+ }
+ }
+ test {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
+ }
+ }
+ production {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
+ pooled = true
+ properties {
+ maxActive = -1
+ minEvictableIdleTimeMillis=1800000
+ timeBetweenEvictionRunsMillis=1800000
+ numTestsPerEvictionRun=3
+ testOnBorrow=true
+ testWhileIdle=true
+ testOnReturn=true
+ validationQuery="SELECT 1"
+ }
+ }
+ }
+}
@@ -0,0 +1,13 @@
+class UrlMappings {
+
+ static mappings = {
+ "/$controller/$action?/$id?"{
+ constraints {
+ // apply constraints here
+ }
+ }
+
+ "/"(view:"/index")
+ "500"(view:'/error')
+ }
+}
View
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Grails Runtime Exception</title>
+ <meta name="layout" content="main">
+ <link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css">
+ </head>
+ <body>
+ <g:renderException exception="${exception}" />
+ </body>
+</html>
View
@@ -0,0 +1,18 @@
+<plugin name='modules-manager' version='0.1.0' grailsVersion='2.0 &gt; *'>
+ <author>Karol Balejko</author>
+ <authorEmail>kb@groovydev.com</authorEmail>
+ <title>Resources Modules Manager Plugin</title>
+ <description>Create resources modules from maven central dependencies.</description>
+ <documentation>http://grails.org/plugin/modules-manager</documentation>
+ <type>ModulesManagerGrailsPlugin</type>
+ <resources />
+ <repositories>
+ <repository name='grailsCentral' url='http://grails.org/plugins' />
+ <repository name='http://repo.grails.org/grails/core' url='http://repo.grails.org/grails/core/' />
+ <repository name='mavenCentral' url='http://repo1.maven.org/maven2/' />
+ </repositories>
+ <dependencies />
+ <plugins />
+ <runtimePluginRequirements />
+ <behavior />
+</plugin>
@@ -0,0 +1,91 @@
+import org.apache.commons.lang.StringUtils
+
+includeTargets << grailsScript("_GrailsInit")
+includeTargets << grailsScript("_GrailsArgParsing")
+
+refreshModules = {forceOverride->
+
+ def workDir = "${grailsSettings.projectWorkDir}/packagemanager"
+
+ grailsSettings.compileDependencies.each {jarfile->
+
+ ant.unjar (src: jarfile, dest: workDir) {
+ patternset excludes: "**/*.min.css **/*.min.js **/*-min.css **/*-min.js"
+ }
+
+ // webjars.org support
+
+ def deps = []
+ def resourcesUrls = []
+ def artifactId
+
+ if (new File("${workDir}/META-INF/resources/webjars").exists()) {
+
+ // parse pom
+ new File(workDir).eachFileRecurse {file->
+ if (!file.file || file.name != 'pom.xml') return
+ def pom = new XmlParser().parse(file)
+ artifactId = pom.artifactId.text()
+ pom.dependencies.findAll {
+ deps << it.dependency.artifactId.text()
+ }
+ }
+
+ new File("${workDir}/META-INF/resources/webjars").eachFileRecurse {file->
+ if (file.file) {
+
+ def relpath = StringUtils.removeStart(file.path, "${workDir}/META-INF/resources/webjars/")
+
+ def resourcePath = relpath
+ def webjarsMatcher = resourcePath =~ /([^\/]+)\/([^\/]+)\/(.+)/
+ if (webjarsMatcher.matches()) {
+
+ def module = webjarsMatcher.group(1)
+ def version = webjarsMatcher.group(2)
+ def path = webjarsMatcher.group(3)
+
+ if (!artifactId) {
+ artifactId = module
+ }
+
+ if (forceOverride || !new File("${grailsSettings.baseDir}/web-app/modules/${artifactId}/${path}").exists()) {
+ ant.copyfile(src: file, dest: "${grailsSettings.baseDir}/web-app/modules/${artifactId}/${path}")
+ event('CreatedFile', ["${grailsSettings.baseDir}/web-app/modules/${artifactId}/${path}"])
+ if (StringUtils.endsWithAny("modules/${artifactId}/${path}", ['.js','.css'] as String[])) {
+ resourcesUrls << "modules/${artifactId}/${path}"
+ }
+ }
+ }
+ }
+ }
+
+ def resourceDSLFilepath = "${grailsSettings.baseDir}/grails-app/conf/Modules${StringUtils.capitalise(artifactId)}Resources.groovy"
+
+ def templ = "modules = {\n"
+ templ += " '${artifactId}' {\n"
+ if (deps) {
+ templ += " dependsOn '${deps.join()}'\n"
+ }
+ resourcesUrls.each {
+ templ += " resource url: '${it}'\n"
+ }
+ templ += " }\n"
+ templ += "}\n"
+
+ if (forceOverride || !new File(resourceDSLFilepath).exists()) {
+ ant.echo(file:resourceDSLFilepath,message: templ)
+ event('CreatedFile', [resourceDSLFilepath])
+ }
+ }
+
+ ant.delete(dir: workDir)
+ }
+
+}
+
+target(main: "Refresh resources modules") {
+ depends(parseArguments)
+ refreshModules(argsMap.force)
+}
+
+setDefaultTarget(main)
View
@@ -0,0 +1,10 @@
+//
+// This script is executed by Grails after plugin was installed to project.
+// This script is a Gant script so you can use all special variables provided
+// by Gant (such as 'baseDir' which points on project base dir). You can
+// use 'ant' to access a global instance of AntBuilder
+//
+// For example you can create directory under project tree:
+//
+// ant.mkdir(dir:"${basedir}/grails-app/jobs")
+//
@@ -0,0 +1,5 @@
+//
+// This script is executed by Grails when the plugin is uninstalled from project.
+// Use this script if you intend to do any additional clean-up on uninstall, but
+// beware of messing up SVN directories!
+//
View
@@ -0,0 +1,10 @@
+//
+// This script is executed by Grails during application upgrade ('grails upgrade'
+// command). This script is a Gant script so you can use all special variables
+// provided by Gant (such as 'baseDir' which points on project base dir). You can
+// use 'ant' to access a global instance of AntBuilder
+//
+// For example you can create directory under project tree:
+//
+// ant.mkdir(dir:"${basedir}/grails-app/jobs")
+//

0 comments on commit 61b2ecf

Please sign in to comment.