Grails 3 : console plugin not coming up in production mode - grails

Grails console plugin page is not coming up nothing gets rendered on the UI only when application is run on production environment either via run-app or as a war file deployed on embedded tomcat.
Grails version - 3.2.4
build.gradle looks like this:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
....
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.13.1"
...
}
}
version "0.1"
apply plugin: "asset-pipeline"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
....
runtime 'org.grails.plugins:grails-console:2.0.9'
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.13.1"
....
}
Any thoughts whats going wrong here?

By default the plugin is disabled in production for obvious reasons (an attacker could do anything to your app) - but if you understand the risk and secure it you can re-enable it. Checkout the documentation here https://github.com/sheehan/grails-console#security

Related

Could not resolve all files for configuration gradle build

I want tagsoup jar as dependency for one of my test case which reads a html.
In my build.gradle I have done these changes
asciidoctorj {
version = '1.5.4'
}
repositories {
maven {
url "http://mvn-nexus.my.company:8081/nexus/content/groups/public/"
}
mavenCentral()
}
compile(
'org.codehaus.groovy:groovy-all:2.4.14',
'org.codehaus.groovy.modules.http-builder:http-builder:0.7',
'org.apache.httpcomponents:httpclient:4.5.2',
'org.apache.httpcomponents:httpmime:4.5.2',
'commons-cli:commons-cli:1.2',
'ant:ant:1.7.0',
'com.cloudbees:groovy-cps:1.19',
'org.codehaus.gpars:gpars:1.2.1'
)
testCompile(
'junit:junit:4.12',
'org.codehaus.groovy:groovy-all:2.4.14',
'org.spockframework:spock-core:1.1-groovy-2.4',
'org.mockito:mockito-core:2.12.0',
'com.athaydes:spock-reports:1.4.0',
'org.slf4j:slf4j-api:1.7.13',
'org.slf4j:slf4j-simple:1.7.13',
'com.lesfurets:jenkins-pipeline-unit:1.0',
'org.ccil.cowan.tagsoup:1.2.1'
)
varsCompile sourceSets.main.output
}
But I get the following error in my jenkins build while building this project
What went wrong:
Could not resolve all files for configuration ':testCompileClasspath'.
Could not find org.ccil.cowan.tagsoup:0.9.7:.
Required by:
project :
What am I missing?
You miss the artefact name. Try :
'org.ccil.cowan.tagsoup:tagsoup:1.2.1'

repo.grails.org - cert expired

Can't build my project any more because the repo certificate has expired. I've tried using --offline but it still seems to try to hit the url and fails. Any thoughts on an alternative?
build.gradle...
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
This has been reported here, watch the report for progress info: https://github.com/grails/grails-core/issues/11082
You can temporarily change https to http, but be sure to revert that change ASAP once the cert issue is resolved.
I have the same problem, a workaround is to use http instead of https in build.gradle file
buildscript {
repositories {
mavenLocal()
maven { url "http://repo.grails.org/grails/core" }
}
....
}
repositories {
mavenLocal()
maven { url "http://repo.grails.org/grails/core" }
}

IntelliJ IDEA: Gradle indexing files - infinite loop

I'm developing a web application, using Grails 2.2.3 with Ember.js (rc3). I'm using IntelliJ IDEA 12.1 Utlimate as IDE and also the IntelliJ TeamCity CI Server - everything's on Windows 7 Professional SP1. Now I wanted to use Gradle 1.7 to better organize my build tasks (combining Grails, Grunt, testing and so on...) and I expected paradise but all I got was hell...
As soon as I started to use the gradle.build file and started JetGradle in IntelliJ IDEA it started to scan and index files over and over (actually it is still running now - 14 hours and counting), the IDE is blocked and I can't do anything... it's really frustrating.
If it's of any interest, here's my gradle.build:
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.tasks.Exec
import org.grails.gradle.plugin.GrailsTask
buildscript {
repositories {
maven { url "http://my.company.archiva:8080/repository/internal" }
maven { url "http://repo.grails.org/grails/repo" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT",
"org.grails:grails-bootstrap:2.2.3"
}
}
apply plugin: "grails"
apply plugin: "base"
repositories {
maven { url "http://my.company.archiva:8080/repository/internal" }
maven { url "http://repo.grails.org/grails/repo" }
}
grails {
grailsVersion "2.2.3"
}
configurations {
all {
exclude module: "commons-logging"
exclude module: "xml-apis"
exclude module: "grails-plugin-log4j"
exclude module: "slf4j-log4j12"
}
test {
exclude module: "groovy-all"
}
compile {
exclude module: "hibernate"
}
compileOnly
}
dependencies {
compile("com.my.company:grails-custom-plugin1:0.1.7#zip")
compile("com.my.company:grails-cusotm-plugin:0.2#zip")
compile("com.my.company:backendapi:1.1")
compile("org.mozilla:rhino:1.7R4")
compile("io.netty:netty:3.3.1.Final")
compile("com.google.protobuf:protobuf-java:2.4.1")
compile("org.grails.plugins:cache:1.0.1")
compileOnly "org.grails:grails-plugin-tomcat:$grails.grailsVersion" // No tomcat-*.jar in the war
bootstrap "org.codehaus.groovy:groovy-all:2.0.5"
}
/*
GRADLE Wrapper
*/
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}
/*
GRUNT Section
*/
task npm(type: Exec) {
group = "Build"
description = "Installs all Node.js dependencies defined in package.json"
workingDir "web-app"
commandLine = ["npm.cmd", "install"]
inputs.file "package.json"
outputs.dir "node_modules"
}
task production(type: GruntTask) {
gruntArgs = "prod"
}
class GruntTask extends Exec {
private String gruntExecutable = Os.isFamily(Os.FAMILY_WINDOWS) ? "grunt.cmd" : "grunt"
private String switches = "--no-color"
private String workDir = "web-app"
String gruntArgs = ""
public GruntTask() {
super()
this.setExecutable(gruntExecutable)
this.workingDir(workDir)
}
public void setGruntArgs(String gruntArgs) {
this.args = "$switches $gruntArgs".trim().split(" ") as List
}
}
/*
WAR creation
*/
task war(type: GrailsTask) {
command "war"
env "prod"
}
Is anybody out there who is able to help me? I searched the internet up and down but it seems that either nobody is using the combination of Grails, Ember.js, Gradle, IntelliJ IDEA or everything is dead simple and I'm just to stupid to use the tools...
I don't recommend to use the Gradle integration in IDEA 12 as it's too limited. (IDEA 13 will be better.) Instead you can use Gradle's "idea" plugin to generate IDEA files. Not sure how well all of this works together with Grails. Grails' own build tool is deeply integrated with the rest of Grails, and from what I've heard, using anything else means to make compromises. (I don't have first-hand experience though.) There have been plans for Grails to switch over its built-in build tool to Gradle one day.
PS: I'd search the IDEA issue tracker and file an issue if there is none.

How to tell Grails to use Gradle for dependencies resolution

I'm trying to setup a grails project with gradle but i came a problem, i can't make grails to use gradle for dependencies resolution. If i config the dependencies in gradle build file and run gradle grails-run-app, it always report can't find classes in dependencies jars.
When i cut and paste the dependencies into grails BuildConfig.groovy and everything is ok.
How to tell Grails to use Gradle for dependencies resolution?
I paste my build.gradle file here, Any suggestion?
apply plugin: 'grails'
apply plugin: 'java'
apply plugin: 'jetty'
version "1.0-SNAPSHOT"
buildscript {
repositories {
mavenCentral()
mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'
}
dependencies {
classpath 'com.connorgarvey.gradle:gradle-grails-wrapper:1.0'
}
}
grails {
version '2.2.3'
}
repositories {
mavenLocal()
mavenCentral()
mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'
}
dependencies {
compile 'org.modeshape.bom:modeshape-bom-embedded:3.3.0.Final'
compile 'postgresql:postgresql:9.1-901.jdbc4'
compile 'javax.jcr:jcr:2.0'
compile 'org.modeshape:modeshape-jcr:3.3.0.Final'
}
I would recommend using the grails-gradle-plugin instead.
UPDATED ANSWER, cleanup and usage of bootstrap scope to exclude Tomcat jars from war.
General info
I followed a presentation from Luke Daley (aka alkemist) on Youtube at gr8conf 2013. I was able to create a small POC and Gradle seems to work fine with Grails 2.2.3.
Gradle build file
buildscript {
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT',
'org.grails:grails-bootstrap:2.2.3'
}
}
version='0.0.1'
apply plugin: 'grails'
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
grails {
grailsVersion '2.2.3'
version '2.2.3'
}
configurations {
all {
exclude module: 'commons-logging'
exclude module: 'xml-apis'
}
test {
exclude module: 'groovy-all'
}
compile {
exclude module: 'hibernate'
}
}
dependencies {
compile( "org.grails:grails-crud:$grails.grailsVersion",
'org.grails:grails-gorm:1.3.7')
bootstrap "org.grails:grails-plugin-tomcat:$grails.grailsVersion"
}
Send a text.... ;) Kidding.
You must include a version of the 'grails-bootstrap' artifact in the
'classpath' configuration. You should also add whichever Grails
artifacts you need. 'grails-crud' and 'grails-gorm' will give you
everything you need for a standard Grails web application.
Have a look at the plugin docs.

Gradle / Grails application

I have been trying to configure Gradle to manage a Grails project for a couple of hours with no success. The suggestions I've found here on Stack Overflow and elsewhere on the Internet didn't work for me.
Could you please give me up-to-date directions on how to configure a Gradle+Grails project? Ideally it should relate to the current versions of Grails (2.1.0) and Gradle (1.1).
BuildScript
import org.grails.gradle.plugin.GrailsTask
buildscript {
repositories {
mavenCentral()
mavenRepo name: "grails", url: 'http://repo.grails.org/grails/repo'
}
dependencies {
classpath "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT"
}
}
repositories {
mavenCentral()
mavenRepo name: "grails", url: 'http://repo.grails.org/grails/repo'
}
version = "1.0"
grailsVersion = "2.1.0"
apply plugin: "grails"
dependencies {
['dependencies', 'resources', 'core', 'hibernate', 'plugin-datasource', 'plugin-domain-class', 'plugin-tomcat', 'plugin-services'].each { plugin ->
compile "org.grails:grails-$plugin:2.1.0"
}
bootstrap "org.codehaus.groovy:groovy-all:1.8.6"
}
GRAILS_TASK_PREFIX = "grails-"
if (name.startsWith(GRAILS_TASK_PREFIX)) {
project.task(name, type: GrailsTask) {
command "${name - GRAILS_TASK_PREFIX}"
}
}
Initialize
Then you can do gradle init to initialize the project structure
Commands
Use gradle grails-[grails script] to execute your grails commands. For example: gradle grails-run-app is equivalent to grails run-app
Hope this helps!
Update
This seems to work for Grails 2.3.2:
buildscript {
repositories {
mavenCentral()
maven { url 'http://repo.grails.org/grails/repo' }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT"
}
}
repositories {
mavenCentral()
maven { url 'http://repo.grails.org/grails/repo' }
}
version = "1.0"
apply plugin: "grails"
apply plugin: 'idea'
grails {
grailsVersion = "2.3.2"
}
dependencies {
['dependencies', 'core', 'spring', 'web', 'plugin-datasource', 'plugin-domain-class', 'plugin-controllers', 'plugin-services'].each { plugin ->
compile "org.grails:grails-$plugin:2.3.2"
}
compile 'org.grails.plugins:tomcat:7.0.42'
compile 'org.grails.plugins:hibernate:3.6.10.3'
compile 'com.h2database:h2:1.3.173'
bootstrap "org.codehaus.groovy:groovy-all:2.1.9"
}
A note, throws Exception when generating Grails wrapper, but gradle init seems to initialize the project structure properly otherwise. And, gradle grails-run-app seems to work fine too.

Resources