I am creating a custom task that needs to execute a rest service.
I declare jersey as dependency in buildSrc/build.gradle but is being ignore at compilation causing java compile error on task class:
Task Class:
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
public class PackageBuilder extends DefaultTask {
@Input
public String userid;
@Input
public String source;
@Input
public String name;
@Input
public String version;
@Input
public String summary;
@Input
public String packageDescription;
@Input
public String url;
@Input
public String changelog;
@TaskAction
void start() {
Client client = ClientBuilder.newClient();
}
}
build.gradle:
apply plugin: "groovy"
apply plugin: "java"
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile gradleApi()
compile localGroovy()
compile 'org.glassfish.jersey.core:jersey-client:2.4.1'
}
Error Message:
:buildSrc:compileJava buildSrc/src/main/java/br/com/project/gradle/PackageBuilder.java:8: error: package javax.ws.rs.client does not exist import javax.ws.rs.client.Client;
^ buildSrc/src/main/java/br/com/project/gradle/PackageBuilder.java:9: error: package javax.ws.rs.client does not exist import javax.ws.rs.client.ClientBuilder;
^ buildSrc/src/main/java/br/com/project/gradle/PackageBuilder.java:42: error: cannot find symbol
Client client = ClientBuilder.newClient();
^
symbol:
class Client
location: class PackageBuilder buildSrc/src/main/java/br/com/project/gradle/PackageBuilder.java:42: error: cannot find symbol
Client client = ClientBuilder.newClient();
^
symbol:
variable ClientBuilder
location: class PackageBuilder 4 errors :buildSrc:compileJava FAILED
FAILURE: Build failed with an exception.
-
What went wrong: Execution failed for task ‘:compileJava’. > Compilation failed; see the compiler error output for details.
-
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I apreciate any thoughts. Tks in advance.