I am trying to add maven-publisher to a Grails (2.3.6) plugin like so:
dependencies {
compile 'org.mongodb.morphia:morphia:0.107'
compile ":maven-publisher:0.8.1"
}
When I run grails compile I get:
| Error There was an error loading the BuildConfig: Bad artifact coordinates
:maven-publisher:0.8.1, expected format is <groupId>:<artifactId>[:<extension>[
:<classifier>]]:<version> (Use --stacktrace to see the full trace)
What's going on here?
Do not use the maven-publisher plugin. It's old and deprecated. Use the release plugin - it should already be in your plugin's BuildConfig.groovy. If not, here's how it should look (after removing unnecessary cruft):
grails.project.work.dir = 'target'
grails.project.dependency.resolution = {
inherits 'global'
log 'warn'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.mongodb.morphia:morphia:0.107'
}
plugins {
build ':release:3.0.1', ':rest-client-builder:1.0.3', {
export = false
}
}
}
As #dmahapatro said in his comment, jar dependencies go in the dependencies block, and plugin dependencies go in the plugins block.
Note also that you should keep the export = false setting so the plugin is available locally for your use, but doesn't leak into the containing application as an unnecessary transitive dependency.
Related
Please help! I had a problem installing spring-security-ldap 2.0.1 into my Grails 2.4.4.
My BuildConfig.groovy is like such:
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
mavenRepo "http://repo.spring.io/milestone"
mavenRepo "http://repo.grails.org/grails/repo"
}
dependencies {
compile "org.grails.plugins:spring-security-ldap:2.0.1"
}
And during resolve the following error is shown:
Error | Resolve error obtaining dependencies: Could not find artifact org.grails.plugins:spring-security-ldap:jar:2.0.1 in grailsCentral (https://repo.grails.org/grails/plugins)
It's not a connection/proxy issue cause other dependencies was resolved with no problem.
Anyway to resolve this? Any info/help much appreciated!
Please change dependency from
dependencies {
compile "org.grails.plugins:spring-security-ldap:2.0.1"
}
To
dependencies {
compile 'org.grails.plugins:spring-security-ldap:3.0.2'
}
You can check repo of grails core spring-security-ldap plugin.
Updated:
plugins {
compile ":spring-security-ldap:2.0.1"
}
Please refer this link to other configuration
Above uses Grails 2.X and likely won't work with 3.X
Hope this will helps you
I want to use the Grails 3 Cookie plugin (http://plugins.grails.org/plugin/ctoestreich/cookie). In my build.gradle I have these entries here:
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
[...]
compile 'org.grails.plugins:grails-cookie:2.0.5'
[...]
}
But when running gradle build, he's got problems looking up that dependency:
> Could not resolve all dependencies for configuration ':runtime'.
> Could not find org.grails.plugins:grails-cookie:2.0.5.
Searched in the following locations:
file:/home/marp/.m2/repository/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
file:/home/marp/.m2/repository/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
https://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
https://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
https://repo1.maven.org/maven2/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.pom
https://repo1.maven.org/maven2/org/grails/plugins/grails-cookie/2.0.5/grails-cookie-2.0.5.jar
Required by:
project :
Do I need to include an other maven repo? Or is the plugin just gone?
Instead compile 'org.grails.plugins:grails-cookie:2.0.5'
use compile 'org.grails.plugins:cookie:2.0.5'
also you can set cookie expiration configuration in application.yml file
Example-grails.plugins.cookie.cookieage.default: 43200
repo of dependency
Hope it helps you
According to this (at the time of writing), 2.0.3 appears to be the newest version on the repo.grails.org repo:
http://repo.grails.org/grails/core/org/grails/plugins/grails-cookie/
change your dependency to:
compile 'org.grails.plugins:cookie:2.0.3'
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 trying to use the gradle-grails-plugin to build an existing (small) Grails project. Should this work? What is the relationship between the dependencies in build.gradle and the ones specified in buildConfig.groovy?
In any event, I have two projects, so the topmost build.gradle file is in the parent directory and looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.2.0.RC1"
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
and then the build.gradle in the Grails project looks like:
apply plugin: "grails"
repositories {
grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}
grails {
grailsVersion = '2.4.4'
groovyVersion = '2.3.9'
springLoadedVersion '1.2.0.RELEASE'
}
dependencies {
bootstrap "org.grails.plugins:tomcat:7.0.55.3"
compile 'org.grails.plugins:asset-pipeline:3.0.1'
compile 'org.grails.plugins:scaffolding:2.1.2'
compile 'org.grails.plugins:cache:1.1.8'
runtime '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'
}
However, when I run ./gradlew war, I get back:
Caused by: java.long.ClassNotFoundException: grails.artefact.Service
Can anyone shed some light on this? There are practically no references to that via Google, it seems to be a Grails 3.x class? Also, I am using Java 1.7.
Class grails.artefact.Service is indeed accessible from v3.0 of grails framework - as can be seen here.
With the following statement grailsVersion = '2.4.4' v2.4.4 is specified to be used and it all looks ok. What spoils the build is the following dependencies entry:
compile 'org.grails.plugins:asset-pipeline:3.0.1'
In this package there is a class asset/pipeline/grails/AssetProcessorService that imports the mentioned grails.artefact.Service which isn't loaded at runtime (probably because of v2.4.4 used).
Unfortunately I can't suggest any solution apart from the trivial like excluding this dependency. I am not a grails developer nor have I set the environment up.
Hopes that helps somehow.
I've got a problem with NoClassDefFound exception in Grails 2.0 when I tried to use library from external JAR.
I've checked that declared JARs are inside of created WAR, also grials dependecies-report do not marks any issues with that.
Locally added JARs or downloaded from Maven repo seems no difference. I've also tried to clean IVY cache and clean grails project without success.
Did you got any ideas how to fix it?
BuildConfig.groovy (part of)
grails.project.dependency.resolution = {
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()
mavenLocal()
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 {
compile ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
runtime ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
}
...
}
LibraryController.groovy
import com.google.gdata.client.youtube.YouTubeService
import com.google.gdata.data.youtube.VideoEntry
import com.google.gdata.util.ServiceException
class LibraryController {
private YouTubeService service
private static final API_URL = "http://gdata.youtube.com/feeds/api/videos/"
def index = {
service = new YouTubeService("app")
}
}
Exception
Class
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeServiceClass
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeService
NoClassDefFoundError is not the same as ClassNotFoundException. Getting a ClassNotFoundException means the class isn't there, so you have a straightforward jar/dependency problem. NoClassDefFoundError means that the specified class was found, but that a class that it references wasn't found. It's a much more frustrating issue to track down because the JVM doesn't tell you what's missing.
You need to make sure that you have all of the dependencies of the class that's failing to load, and all of their dependencies, etc.
You have all your dependencies declared both in compile and runtime scope. Each dependency should be declared only once. If you declare a dependency in compile scope, it will also be available runtime. Since you need this class for compilation, you should keep com.google.gdata:gdata-youtube:2.0 under 'compile', and remove it from 'runtime'
A description of the available scopes, taken from the user documentation:
build: Dependencies for the build system only
compile: Dependencies for the compile step
runtime: Dependencies needed at runtime but not for compilation (see above)
test: Dependencies needed for testing but not at runtime (see above)
provided: Dependencies needed at development time, but not during WAR deployment