Could n't create dummy project instance through the ecipse IDE


(Ramesh Pasham) #1

Hi Gradle Experts,

I am struggling to debug while developing the custom plugin on sts eclipse ide. They provided some jars in the sts gradle plugin. commons-collections-3.2.1.jar commons-collections-3.2.1-sources.jar gradle-base-services-1.2.jar gradle-core-1.2.jar gradle-core-1.2-sources.jar gradle-messaging-1.2.jar gradle-tooling-api-1.2.jar gradle-tooling-api-1.2-sources.jar gradle-wrapper-1.2.jar gradle-wrapper-1.2-sources.jar guava-11.0.2.jar jsr305-1.3.9.jar plugins README.txt slf4j-api-1.6.6.jar slf4j-simple-1.6.6.jar slf4j-simple-1.6.6-sources.jar

But while creating custom instance plugin as

final Project project = ProjectBuilder.builder().build()

the error coming like this

Exception in thread “main” org.gradle.api.internal.classpath.UnknownModuleException: Cannot locate JAR for module ‘gradle-core-impl’ in distribution directory ‘E:\Users\pramesh\Downloads\springsource\sts-3.1.0.RELEASE\plugins\org.springsource.ide.eclipse.gradle.core_3.1.0.201210040512-RELEASE’.

at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(DefaultModuleRegistry.java:136)

at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(DefaultModuleRegistry.java:108)

at org.gradle.api.internal.DynamicModulesClassPathProvider.findClassPath(DynamicModulesClassPathProvider.java:42)

at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:34)

at org.gradle.initialization.DefaultClassLoaderRegistry.(DefaultClassLoaderRegistry.java:44)

at org.gradle.api.internal.project.GlobalServicesRegistry.createClassLoaderRegistry(GlobalServicesRegistry.java:79)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:175)

at org.gradle.internal.service.DefaultServiceRegistry.access$300(DefaultServiceRegistry.java:47)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.create(DefaultServiceRegistry.java:336)

at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:240)

at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.getService(DefaultServiceRegistry.java:275)

at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.getService(DefaultServiceRegistry.java:215)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)

at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)

at org.gradle.internal.service.DefaultServiceRegistry$ParentServices.getService(DefaultServiceRegistry.java:441)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)

at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)

at org.gradle.api.internal.project.TopLevelBuildServiceRegistry.createRootClassLoader(TopLevelBuildServiceRegistry.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:175)

at org.gradle.internal.service.DefaultServiceRegistry.access$300(DefaultServiceRegistry.java:47)

at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.create(DefaultServiceRegistry.java:336)

at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:240)

at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.getService(DefaultServiceRegistry.java:275)

at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.getService(DefaultServiceRegistry.java:215)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)

at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)

at org.gradle.internal.service.DefaultServiceRegistry$ParentServices.getService(DefaultServiceRegistry.java:441)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)

at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)

at org.gradle.internal.service.DefaultServiceRegistry$NestedServices.getService(DefaultServiceRegistry.java:413)

at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)

at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)

at org.gradle.invocation.DefaultGradle.(DefaultGradle.java:63)

at org.gradle.testfixtures.internal.ProjectBuilderImpl.createProject(ProjectBuilderImpl.java:69)

at org.gradle.testfixtures.ProjectBuilder.build(ProjectBuilder.java:99)

at org.gradle.testfixtures.ProjectBuilder$build.call(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)

at com.cordys.tools.mb.gradle.MbvPlugin.main(MbvPlugin.groovy:44)

Why it is expecting gradle-core-imp in that location, actually it was not there it’s class path. Otherwise i can locate the Gradle installation folder to eclipse to access the libraries. But in their distribution also the module is not there.

Please help me on this.


(Luke Daley) #2

You’ll have to ask the Eclipse folks. For some reason Gradle thinks it’s running from a distribution at ''E:\Users\pramesh\Downloads\springsource\sts-3.1.0.RELEASE\plugins". This is pretty strange.

Is this source open that I can take a look at it?


(Ramesh Pasham) #3

Please see the code what am doing wrong. {

package com.cordys.tools.mb.gradle

import org.gradle.api.* import org.gradle.testfixtures.ProjectBuilder;

class MbvPlugin implements Plugin {

private MbvPluginExtention extention

@Override

public void apply(Project project) {

extention = project.extensions.create(‘mbv’, MbvPluginExtention, project)

project.task(‘mbvMain’, type :MbvMain).with {

srcFolder = extention.srcFolder

showLines = extention.showLines

ignoreMarker = extention.ignoreMarker

violationsFile = extention.violationsFile

outFile = extention.outFile

}

project.tasks.findByName(“mbvMain”).doFirst {

//Deleting the mbv folder

project.delete(‘build/reports/mbv’)

//making directory in project folder

project.mkdir(‘build/reports/mbv’)

}

}

static main(args){

final Project project = ProjectBuilder.builder().build()

project.apply(plugin : ‘mbv’)

assert project.tasks.findByName(‘mbvMain’)

}

}


(Luke Daley) #4

I can only guess that you are somehow getting Gradle from the Eclipse plugin in your runtime path. How are you getting the Gradle jars on your classpath?


(Ramesh Pasham) #5

Hi Luke, Eclipse gradle plugin itself pointing to the jars which are provided by them. \springsource\sts-3.2.0.RELEASE\plugins\org.springsource.ide.eclipse.gradle.core_3.2.0.201303060652-RELEASE\lib\*.jar


(Luke Daley) #6

They only ship the Jars necessary to run the Tooling API. You need the runtime jars.

I can’t recommend how to fix this as I don’t understand your project setup.