Java/ groovy build order error?

Given a Java interface (

public interface Formatter {
   Object parse(String text) throws ParseException;

in a .java file and an abstract Groovy class (AbstractFormatter.groovy)

abstract class AbstractFormatter implements Formatter, Serializable {
    abstract protected Object stringToValue(String text) throws ParseException;
 abstract protected String valueToString(Object value) throws ParseException;
   Object parse(String text) {
  return stringToValue(text)

running a build under Linux and Windows from the command line results in an error:

AbstractFormatter.groovy: 59: The return type of java.lang.Object parse(java.lang.String) in com.metaficient.core.objectmodel.formatters.AbstractFormatter is incompatible with [Ljava.util.Formatter$FormatString; parse(java.lang.String) in java.util.Formatter
. At [59:2]
@ line 59, column 2.
    Object parse(String text) {
  1 error

I did some experiments using Groovy 1.8.6 to compile the files manually, and it seems that this happens when the .java interface file is not compiled before the .groovy file. This happens on Linux and Windows from the command line, but NOT on Mac OS X, or when running under the gradle -gui option.

The build file is:

import java.text.SimpleDateFormat
  // apply plugin: 'eclipse'
apply plugin: 'groovy'
  version = hasProperty('versionID') ? versionID : new SimpleDateFormat('yyyyMMdd').format(new Date())
  repositories {
 flatDir {
  dir 'src/main/lib'
 flatDir {
  dir 'src/test/lib'
  dependencies {
 groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.6'
 compile ':castor:1.2',
     testCompile group: 'junit', name: 'junit', version: '4.8.2',

If I change the .java file to .groovy, it now works.

This is gradle 1.2, Sun java 1.6.0_35 and groovy 1.8.6 on Suse Linux and Windows 7 (under both Windows cmd and a Cygwin shell)

Groovy imports ‘java.util.*’ by default. Looks like the Groovy compiler interprets ‘implements Formatter’ to mean ‘implements java.util.Formatter’ and then goes astray. You should be able to solve the problem with an explicit import of your ‘Formatter’ interface (even if it’s in the same package). I don’t think the problem is related to Gradle.