Package does not exist error for custom JavaCompile

I have a task called compilePlugin of type JavaCompile that is failing with the error ‘package does not exist’. I’m using eclipse and have gradle dependency management enabled. The java source I’m trying to build is located in src/main/java/com/abc/policy/export/plugin.

Here is the error:

[sts] ----------------------------------------------------- [sts] Starting Gradle build for the following tasks: [sts] compilePlugin [sts] ----------------------------------------------------- commons path: null Setting commons path to local: ../ABC_Implementation/ABCCommons/ :compilePluginC:\Development\wcnew\CC_Policy_Export\src\main\java\com\abc\policy\export\plugin\ package does not exist import;

Here is what the task looks like:

task compilePlugin(type:JavaCompile) {
description 'Compiles the plugin'
source 'src/main/java/com/abc/policy/export/plugin'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
classpath = fileTree(dir:'../ABC_Implementation/ABCCommons/', include: '*.jar')
destinationDir = file('build/plugin/classes')


I have printed out the classpath from this task, and it includes the jars that contain the packages the error is referencing. I do not know what else to try.

At first guess, I’d say you should remove the “source” property setting entirely. The default is “src/main/java”, and that looks appropriate for your situation.


Thank you for the suggestion. When I remove the explicit declaration of “source”, I no longer receive any errors, but my task does not produce any class files.

Then change the value to “src/main/java”.