Sorry Grails noob here.
I am looking at a project which has some references to JUnit in its test code. I am trying to figure out how JUnit is being added to the classpath. I go to the BuildConfig.groovy file and I see no explicit reference to JUnit.
The dependencies are:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
runtime 'postgresql:postgresql:9.0-801.jdbc4'
compile 'com.thoughtworks.xstream:xstream:1.4.2'
compile 'spy:spymemcached:2.8.9'
compile "org.grails:grails-webflow:$grailsVersion"
compile 'org.infinispan:infinispan-core:5.1.0.CR2'
}
The plugin dependencies are:
plugins {
test(":spock:0.7") {
exclude "spock-grails-support"
}
runtime ":jquery:1.7.2"
runtime ":resources:1.1.6"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
compile ":geoip:0.2"
compile ':cache:1.0.0'
compile ":quartz:1.0-RC9"
//compile ":quartz-monitor:0.3-RC2"
compile ":grails-melody:1.45"
compile ':webflow:2.0.0', {
exclude 'grails-webflow'
}
}
So any ideas on what could be bringing in the Junit jar or how I'd find out what it is?
Thanks.
JUnit is part of the grails packaging by default. You should be able to find junit jar in lib of grails bundle which you would have downloaded from grails.org in
GRAILS_HOME\lib\junit\junit\jars
You can also verify how it is added to the project by running grails dependency-report on the project and looking for junit jar in test scope.
The latest version of junit shipped with Grails 2.2.3 is junit-4.10.
Related
I am a newbie in the areas in Grails and Vaadin 8, and I’m having a bit of trouble trying to add widgets to my Vaadin/Grails application.
To begin, I created a grails/Vaadin app using the me.przepiora.vaadin-grails:web-vaadin8:0.3 profile. I edited the build.gradel file, as advised and
ran the command ”gradle wrapper --gradle-version 4.0” (again, as advised by the profile setup).
Here is my build.gradle after applying the edit:
apply plugin:"com.devsoap.plugin.vaadin"
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://dl.bintray.com/macprzepiora/gradle-plugins/" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "com.devsoap.plugin:gradle-vaadin-plugin:1.2.0.beta1-macprzepiora2"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.8"
}
}
version "0.1"
group "foobar"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "com.vaadin:vaadin-spring-boot-starter:2.+"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.5.Final"
compile "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "me.przepiora.vaadin-grails:web-vaadin8:0.3"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.8"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails:grails-web-testing-support"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
plugins {
id 'com.devsoap.plugin.vaadin' version '1.3.1'
}
assets {
minifyJs = true
minifyCss = true
}
The resulting grails/Vaadin app worked fine, displaying a button which , when pressed, displayed an error message.
I then tried to enhance the app slightly, by replacing the button with a Vaadin Tree, backup by a TreeData instance.
Unfortunately, when I did this, I got the error message:
“Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.vaadin.ui.Tree Check its component connector's #Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.”
After a google search I found something that appeared to be related at:
How do I fix 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.vaadin.addon.charts.Chart
Based on this, I added the line #Widgetset("AppWidgetset") to my GrailsUI class (the only class in my project that inherits from com.vaadin.ui.UI).
After doing this, I get a new runtime error:
“Failed to load the widgetset: ./VAADIN/widgetsets/AppWidgetset/AppWidgetset.nocache.js?1525623851485”
I feel so frustrated - it feels like i’m really close to a working application, if only I knew the magi incantation :-(
Environment
Grails 2.4.4
PostgreSQL 9.4
JDK 1.7
I've been trying to get this plugin to work. (I'm still a grails newbie, not to mention programming.)
I tried to do everything I can find out there but still get this untimate error message.
Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script
|Script 'DbReverseEngineer' not found, did you mean:
1) SetVersion
2) GenerateRestfulController
3) GenerateViews
4) GenerateController
5) DbmGenerateChangelog
Please make a selection or enter Q to quit:
This is what I have right not in my config files. (I've tried to change a lot of them, such as Hibernate, plugin version etc, but always end up with that message.)
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
mavenRepo "http://repo.grails.org/grails/repo/"
mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
runtime "org.postgresql:postgresql:9.4-1205-jdbc41"
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
compile ":postgresql-extensions:4.6.1"
compile ":jquery:1.11.1"
compile ":joda-time:1.5"
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1"// or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
runtime ":db-reverse-engineer:4.0.0"
}
Thanks in advance.
EDIT 1
So, I changed DbReverseEngineer.groovy under Script folder like this.
mergedConfig.driverClassName = dsConfig.driverClassName ?: 'org.postgresql.Driver'
mergedConfig.password = dsConfig.password ?: ''
mergedConfig.username = dsConfig.username ?: 'postgres'
mergedConfig.url = dsConfig.url ?: 'jdbc:postgresql://localhost:5432/myApp'
And I changed plugin and dependency per Burt's and Emmanuel's advice. And when I run grails db-reverse-engineer command I get this error.
Compilation error: startup failed:
Compile error during compilation with javac.
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/GenericResponseWrapper.java:203: error: method does not override or implement a method from a supertype
#Override
^
/home/Documents/Grails_Workspace/myApp/target/work/plugins/cache-1.1.8/src/java/grails/plugin/cache/web/filter/PageFragmentCachingFilter.java:389: error: cannot find symbol
contentType = response.getContentType();
^
symbol: method getContentType()
location: variable response of type HttpServletResponse
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
What are those errors mean and how can I get rid of it?
Thanks.
You've got the same plugin set up twice:
compile 'org.grails.plugins:db-reverse-engineer:4.0.0'
runtime ':db-reverse-engineer:4.0.0'
According to the plugin's page it should be configured as a compile time dependency:
compile "org.grails.plugins:db-reverse-engineer:4.0.0"
The plugin does have the command that's claimed to be missing. You can see it here. So you may need to refresh the dependencies by running:
grails refresh-dependencies
I am currently trying to build a Grails project using Gradle to easily integrate some repositories. I have created a new directory, and from said directory I have created the following build.gradle file as instructed from this site:
http://grails.github.io/grails-gradle-plugin/docs/manual/guide/introduction.html
buildscript {
repositories {
jcenter()
}
dependencies {
'org.grails:grails-gradle-plugin:2.1.0'
}
}
apply plugin: 'grails'
grails {
grailsVersion = '2.4.0' // Specifies the Grails version to use
groovyVersion = '2.3.1' // Specify the Groovy version to use (should match the version that ships with the above Grails version)
springLoadedVersion = '1.2.0.RELEASE' // Specify the Spring Loaded version to use
}
repositories {
jcenter()
grails.central() //Adds the Grails Central Repository for resolving Grails plugins (replaces grailsPlugins(), grailsCentral() from BuildConfig.groovy)
}
dependencies {
bootstrap 'org.grails.plugins:tomcat:7.0.50.1'
compile 'org.grails.plugins:scaffolding:2.0.2'
compile 'org.grails.plugins:cache:1.1.1'
runtime 'org.grails.plugins:hibernate:3.6.10.8' //or 'org.grails.plugins:hibernate4:4.3.1.1'
runtime 'org.grails.plugins:database-migration:1.3.8'
runtime 'org.grails.plugins:jquery:1.11.0'
runtime 'org.grails.plugins:resources:1.2.2'
//runtime 'mysql:mysql-connector-java:5.1.24'
//runtime 'org.postgresql:postgresql:9.3.1100-jdbc41'
//Additional resources capabilities
//runtime 'org.grails.plugins:zipped-resources:1.0.1'
//runtime 'org.grails.plugins:cached-resources:1.1'
//runtime 'org.grails.plugins:yui-minify-resources:0.1.5'
//Alternate to the resources plugin
//compile 'org.grails.plugins:asset-pipeline:1.5.0'
//Additional asset-pipeline capabilities
//compile 'org.grails.plugins:sass-asset-pipeline:1.5.1'
//compile 'org.grails.plugins:less-asset-pipeline:1.5.0'
//compile 'org.grails.plugins:coffee-asset-pipeline:1.5.0'
//compile 'org.grails.plugins:handlebars-asset-pipeline:1.0.0.3'
}
When I try to build using gradle init, I am confronted with this error:
FAILURE: Build failed with an exception.
Where:
Build file '/home/ian/grailsDir/deadness/build.gradle' line: 10
What went wrong:
A problem occurred evaluating root project 'deadness'.
Plugin with id 'grails' not found.
How can I get the Grails plugin? I am currently running Grails 2.5.0 and Gradle 2.4. I tried it with an earlier version of Grails as well.
The stacktrace is:
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'deadness'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:76)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'grails' not found.
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:110)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
at build_cgy5iob1jp300dugadkqvpnyl.run(/home/ian/grailsDir/deadness/build.gradle:10)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
... 35 more
Please, note that the following code...
dependencies {
'org.grails:grails-gradle-plugin:2.1.0'
}
...should be:
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.1.0'
}
This must solve the issue.
I am using Grails 2.2.4 and audit-trail plugin 2.0.3.
I previously installed the plugin using the deprecated "grails install-plugin" and it works. But now I try using BuildConfig. I have this configuration:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
build ":tomcat:$grailsVersion"
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
runtime ":audit-trail:2.0.3"
runtime ":spring-security-core:1.2.7.3"
}
But now the columns for createdBy, editedBy, createdDate and editedDate are not created in the database for domain with annotation #gorm.AuditStamp
My Config.groovy has this:
grails {
plugin{
audittrail{
createdBy.field = "createdBy"
editedBy.field = "editedBy"
createdDate.field = "createdDate"
editedDate.field = "editedDate"
}
}
}
Thank you
You need to add the plugin in compile scope
compile ":audit-trail:2.0.3"
so that the AST transformation would kick in at compile time to add the configured fields to the domain class.
I am getting some compilation error because of Grails not picking jars from Maven repository based on pom.xml file.
My BuildConfig.groovy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
//excludes "grails-plugin-log4j"
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
//excludes "grails-plugin-log4j"
pom true
repositories {
inherits true // Whether to inherit repository definitions from plugins
//grailsPlugins()
/// grailsHome()
// grailsCentral()
mavenCentral()
mavenLocal()
// These are for the hudson machine
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
// mavenRepo "/apps/profiler/ci/hudson/workspace/RMSPortal2/m2_repo"
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
// mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.5'
compile 'org.apache.activemq:activemq-core:5.3.0'
test 'org.objenesis:objenesis:1.2'
compile 'org.slf4j:slf4j-log4j12:1.6.6'
//compile "spring-security-config:3.0.1.RELEASE"
}
plugins {
compile ":spring-security-core:1.2.7.3"
compile ":spring-security-ui:0.2"
compile ":jquery-ui:1.8.15"
compile ":jqgrid:3.8.0.1"
compile ":famfamfam:1.0.1"
compile ":mail:1.0"
compile ":jms:1.2"
compile ":calendar:1.2.1"
compile ':gpars:0.3'
compile ":lang-selector:0.3"
compile ":crypto:2.0"
compile ":grails-melody:1.13"
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
//runtime ":resources:1.1.6"
runtime ":resources:1.2.RC2"
runtime ":export:1.5"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
test ":spock:0.6"
}
}
I am getting error like this:
Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 141 source files.
| Error Compilation error: startup failed:
/mycompany/dev/rmaddidev/wsmavenTest/pro/src/groovy/com/mycompany/rms/common/RMSExportService.groovy: 15: unable to resolve class org.xhtmlrenderer.pdf.ITextRenderer
# line 15, column 1.
import org.xhtmlrenderer.pdf.ITextRenderer
^
1 error
ITextRenderer class exist in core-renderer.jar i specified in maven pom as below.
if i add those jars in BuildConfig.groovy, then it working fine.
compile 'org.xhtmlrenderer:core-renderer:R8'
compile 'com.lowagie:itext:2.0.8'
And My Pom file:
<dependencies>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.8</version>
</dependency>
You can still use the standard grails commands as long as all your dependencies are referenced in the BuildConfig.groovy.
However, you probably don't want to maintain both the Maven POM and BuildConfig.groovy, unless you have some team members who don't want to use Maven.
Unless the project needs to be 'buildable' using both Maven and the standard Grails command line, avoid the BuildConfig.groovy at all costs, as well as the Grails command line.
Details
When using Maven, you need to do the following :
Do not set dependencies in BuildConfig.groovy, add them to your POM:
The dependencies block from your BuildConfig.groovy move to the POM(with the default implied type tag set to jar).
For non jar dependencies(plugins or non-binary plugins), you need to explicitly set the dependency type to zip in your pom.xml.
Also, remove the repositories block from your BuildConfig.groovy, and set the repositories in your POM.
Do not use the grails command line, use the Grails Maven goals, as implied by #dmahapatro.
When you decide to use Maven and Grails, it implies that you want avoid having settings in your BuildConfig.groovy.
Then you'd have your build settings(all if it were 100% possible) driven by the Maven POM.