IntelliJ mavenLocal Warning in Grails BuildConfig - grails

This warning started showing in IntelliJ :
'mavenLocal' in 'org.codehaus.groovy.grails.resolve.config.RepositoriesConfigurer' cannot be applied to '()'
Here's the relevant snippet from BuildConfig.groovy.
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenRepo "https://mycompany.artifactoryonline.com/mycompany/repo"
mavenCentral()
}
Environment:
OSX 10.6.8
Grails 2.0.3
IntelliJ 11.1.2

The mavenLocal method in RepositoriesConfigurer is defined like this:
void mavenLocal(String repoPath) {
...
}
So yes, mavenLocal expects a path, but is happy with getting null, which means to use the default repository path (.m2/repository under users home directory).
As I understand it, mavenLocal() resolves to calling mavenLocal(null) in this case.
mavenLocal should probably be changed to
void mavenLocal(String repoPath = null) {
...
}
to make it more obvious that the repoPath is optional, and get rid of the warning in IntelliJ

Related

Fail to resolve spring-security-ldap 2.0.1 into Grails 2.4.4

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

Grails can't load maven-publisher

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.

Grails global config/dependency resolution

I'm behind a firewall that doesn't allow me to download from grailsCentral or mavenCentral. But there is one specific public maven repository that IT lets me download from (say 'repo.maven.apache.org'). Is there a way to configure grails with a global configuration? Or more specifically to use a repository globally?
Excerpt from BuildConfig.groovy
grails.project.dependency.resolution = {
inherits 'global'
log 'warn'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
mavenRepo 'http://repo.grails.org/grails/libs-releases'
// Normally I would add this line to every project
//mavenRepo 'http://repo.maven.apache.org/maven2/'
}
...
Is there a way that I can create a file like ~/.grails/BuildConfig.groovy that has content like the following?
grails.global.dependency.resolution = {
repositories {
mavenRepo 'http://repo.maven.apache.org/maven2/'
}
}
Then this repo would be used for every project.:)
I was able to do this using the method posted by #ak-tech (Thank you!)
in ~/.grails/settings.groovy
grails.project.dependency.resolution = {
repositories {
mavenRepo 'http://repo.maven.apache.org/maven2'
}
}
I believe that if you change BuildConfig.groovy in {your-grails-installation-dir}\src\grails\grails-app\conf\BuildConfig.groovy the way you want, then every time you run
grails> create-app myApp
you should get the BuildConfig.groovy with the changes you want.

Grails 2.0 depedencies NoClassDefFound issue

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

Grails - attempting to include HTPPBuilder - Linkage error

When I run grails install-dependency, I get this.
java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for
a different type with name "org/xml/sax/SAXParseException"
What's wrong? I've not used grails dependency management before, and this is rather cryptic.
repositories {
grailsPlugins()
grailsHome()
mavenLocal()
mavenCentral()
}
dependencies {
runtime 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'
}
Looks like an xml-apis clash,
Try
dependencies {
runtime 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'{
excludes 'xml-apis'
}
}

Resources