How to get grails plugin version from app?
Details: my app is also a grails plugin.
When I set version, using
grails set-version 0.5
I can't get value using grailsApplication.metadata['app.version']
because value is updated in my FooBarGrailsPlugin.groovy class
The application.properties file remains unchanged.
Tks.
When I run set-version, my class change from:
class FooBarGrailsPlugin {
def version = 0.1
}
to
class FooBarGrailsPlugin {
def version = 0.5
}
The following code will print out the name and version of all plugins installed in an app
applicationContext.getBean('pluginManager').allPlugins.each {plugin ->
println "${plugin.name} - ${plugin.version}"
}
Related
In a fresh grails 4.0.4 application the settings of
grails:
views:
gsp:
codecs:
expression: none
seem to be ignored when deployed as a war file in a Tomcat 8.5.39. (JVM 11.0.7+10-post-Ubuntu-2ubuntu218.04)
Adding this
<head>
...
<script>
var foo = ${[a:23, b:42, c:666] as grails.converters.JSON};
</script>
</head>
to the generated grails-app/views/index.gsp shows up as
var foo = {"a":23,"b":42,"c":666};
when running grails run-app or even grails prod run-app(!), but is encoded as
var foo = {"a":23,"b":42,"c":666};
in the packaged (grails prod war) deployed war file.
The build.gradle was unmodified, except for changing
compile "org.grails.plugins:cache"
to this
compile("org.grails.plugins:cache") {
exclude module:'groovy-all'
}
Is this a bug or am I using the codecs settings wrong? Maybe there is a plugin overwriting this settings (like here https://github.com/grails/grails-core/issues/10722) but i cannot find any other yml files. Any help is appreciated!
It works like a charm in Grails 4.0.3. Seems it is broken in Grails 4.0.4 ...
Maybe the problem came with the new Groovy Page Compiler Task. The config file (aka application.yml) variable here is never used. But that's only an assumption after quick investigation with too little coffee ;-)
Workaround or my preferred way (still working in Grails 4.0.4)
Some helper TagLib like this:
import grails.converters.JSON
class FooTagLib {
static defaultEncodeAs = [taglib:'none']
static namespace = "foo"
def json = { attrs, body ->
out << raw(attrs.data as JSON)
}
}
Usage:
var foo = <foo:json data="[a:23, b:42, c:666]"/>
I'm trying to create an iOS Titanium Module using a pre-compiled CommonJS module. As the README file says:
All JavaScript files in the assets directory are IGNORED except if you create a
file named "com.moduletest.js" in this directory in which case it will be
wrapped by native code, compiled, and used as your module. This allows you to
run pure JavaScript modules that are pre-compiled.
I've created the file like this:
function ModuleTest(url){
if(url){
return url;
}
}
exports.ModuleTest = ModuleTest;
I'm using the 5.1.2.GA SDK (also tried with 5.3.0.GA) and I can build the module successfully either with python build.py or titanium build --platform iOS --build-only.
Then, in my test app doing:
var test = require('com.moduletest');
var url = new test.ModuleTest('http://url');
Gives me this error:
undefined is not a constructor.
I've been trying a lot of alternatives but nothing seems to work and I didn't find any help on documentation about pre-compiled JS modules for iOS. Actually, the same process works great for Android!
Do you have some idea why?
My environment:
XCode 7.3.1
Operating System
Name - Mac OS X
Version - 10.11.5
Architecture - 64bit
# CPUs - 8
Memory - 16.0GB
Node.js
Node.js Version - 0.12.7
npm Version - 2.11.3
Appcelerator CLI
Installer - 4.2.6
Core Package - 5.3.0
Titanium CLI
CLI Version - 5.0.9
node-appc Version - 0.2.31
Maybe this is something related to my Node version or appc CLI, not sure =/
Thank you!
There are 2 solutions.
1) Don't put it in assets, but in the /app/lib folder as others have mentioned.
2) wrap it as an actual commonjs module, like the module I wrote
In both cases, you can just use require('modulename'). In case 2 you will need to add it to the tiapp.xml file just like any other module.
The path of your file will come in /modules/commonjs/modulename/version/module.js or something similar. My linked module will show you the requirements and paths needed.
I use a slightly different pattern that works excellent:
First a small snippet from my "module":
Stopwatch = function(listener) {
this.totalElapsed = 0; // * elapsed number of ms in total
this.listener = (listener != undefined ? listener : null); // * function to receive onTick events
};
Stopwatch.prototype.getElapsed = function() {
return this.totalElapsed;
};
module.exports = Stopwatch;
And then this is the way I use it:
var StopWatch = require('utils/StopWatch');
var stopWatch = new StopWatch(listenerFunction);
console.log('elapsed: ' + stopWatch.getElapsed());
I try to add a PayPal button in my grails 3 app.
I haven't found any howto's for grails 3 so I tried one for grails 2
(https://grails.org/wiki/PayPal%20Plugin).
Step 1) Install the plugin.
In grails 2:
grails install-plugin paypal
This is not working in grails 3. However there is an install command, but this doesn't accept paypal as parameter.
So I added
dependencies {
.
.
.
compile 'com.paypal.sdk:paypal-core:1.6.9'
compile 'com.paypal.sdk:buttonmanagersdk:2.6.106'
}
to my build.gradle.
Is this the wrong way to add the paypal plugin ?
Step 2) configure constants.
In grails 2 edit Config.groovy:
environments {
production {
grails.paypal.server = "https://www.paypal.com/cgi-bin/webscr"
grails.paypal.email = "example#business.com"
grails.serverURL = "http://www.grails.org"
}
development {
grails.paypal.server = "https://www.sandbox.paypal.com/cgi-bin/webscr"
grails.paypal.email = "testpp_1211202427_biz#g2one.com"
grails.serverURL = "http://812.99.101.131"
}
}
Config.groovy is not used in Grails 3 so I added the following to application.yml
environments:
development:
grails.paypal.server : https://www.sandbox.paypal.com/cgi-bin/webscr
grails.paypal.email : example#business.com
grails.serverURL : http://www.grails.org
Do i have to configure this elsewhere ?
Step 3) Create the PayPal button.
This should be the same in grails 2 and 3
add:
<paypal:button
itemName="name"
itemNumber="theNumber"
transactionId="theTransactionId"
amount="1337,00"
discountAmount="0"
buyerId="theId"
/>
To the gsp file.
Do i have to include the paypal taglib (it's not included in the example) ?
When I test my app I got
<paypal:button
itemName="name"
itemNumber="theNumber"
transactionId="theTransactionId"
amount="1337,00"
discountAmount="0"
buyerId="theId"
/>
in my html.
What do I have to do to get my PayPal button working ?
regards Kai
Is it possible to find out what versions of the various plugins that are in my war / class loader at runtime? The reason I want to do this so that I can be 100% sure at runtime what version of what is in production.
I see a mechanism in this thread: Obtain Grails plugin version at runtime
But was wondering how I would get this in a GSP? Also, this does not give me the jar versions. Thanks
Can't get it for jars but to display in GSP, do...
controller:
class MetaController {
def pluginManager
def plugins
def index() {
log.debug(">>index()")
// retrieve them all...
plugins = pluginManager.allPlugins.collect { plugin ->
log.debug("Plugin: ${plugin.name}, Version: ${plugin.version}")
return "Plugin: ${plugin.name}, Version: ${plugin.version}"
}
plugins.sort()
[plugins: plugins]
}
}
View...
...
<g:each in="${plugins}" var="p">
<li>${p}</li>
</g:each>
I want to use fontawesome plugin in grails.
I have added in build config compile :font-awesome-resources:4.0.3.1 to add plugin.I have added
customBootstrap
{
dependsOn 'font-awesome'
resource url: 'css/bootstrap.css'
resource url: 'js/bootstrap.js' resource url: 'css/bootstrap-fixtaglib.css'
}
in applicationresource.groovy but when i run the application get error
ERROR resource.ResourceProcessor - Unable to load resources Message: No such property: pluginManager for class: org.springframework.web.context.support.XmlWebApplicationContext.Please provide solution.
I am not sure whether this is a configuration issue with migration from earlier grails versions or if font-awesome has not been migrated completely to grails 2.4.x. But I encountered this as well.
As a short (dirty) workaround, you can replace the code that causes the problem directly on the plugin.
File (replace X with your project name):
~/.grails/2.4.2/projects/X/plugins/font-awesome-resources-4.0.3.1/grails-app/conf/FontAwesomePluginResources.groovy
Replace lines 3 and 4 with:
def pluginManager = grails.util.Holders.pluginManager
def lesscssPlugin = pluginManager.getGrailsPlugin('lesscss-resources') || pluginManager.getGrailsPlugin('less-resources')
And give it a go.