Issues compiling gradle code in Eclipse

I am trying to write a java custom task within an existing project.

package oracle.anttasks.test;

import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;

public class GreetingTask {

@TaskAction
public void greet() {
   System.out.println ("hello from GreetingTask in another project");
}

}

I have added the gradle core jar in the classpath as I was initially getting an error for the import statement.

The code doesnt show any error but when i try to compile the project. I get an error:

[javac] D:\GitRepo\fabuildtasks\main\java\oracle\anttasks\test\GreetingTask.java:3: package org.gradle.api does not exist
[javac] import org.gradle.api.DefaultTask;
[javac] ^
[javac] D:\GitRepo\fabuildtasks\main\java\oracle\anttasks\test\GreetingTask.java:4: package org.gradle.api.tasks does not exist
[javac] import org.gradle.api.tasks.TaskAction;

Can someone please help me get resolve this?

Thanks!

Hi,

I recently wrote a plugin in Java as well - does your dependency section show something like:

dependencies {
	...
	compile gradleApi()
	...
}

Also [quote=“vishaldesai, post:1, topic:15005”]
The code doesnt show any error but when i try to compile the project. I get an error:
[/quote]

how do you try to compile the project, e.g.:

gradle build

?

or are you trying to compile it within eclipse?

Regards