Circular dependency


(Firas Fafi) #1

Hello, I have redefined the sourceSets like this below:

sourceSets{
  main{
    java.srcDirs=[
      'backend',
      'shared',
      'dashboard_web',
      'gwt_common',
      'surveys-backend',
      'widgety'
    ]
    output.classesDir=file("$buildDir/war/WEB-INF/classes")
    compileClasspath= sourceSets.main.output+ configurations.runtime
    runtimeClasspath= output+compileClasspath
    }
}

When I run thie compileJava task it cause’s this error:

FAILURE: Build failed with an exception.
  * What went wrong:
Circular dependency between the following tasks:
:classes
\--- :compileJava
     \--- :classes (*)
  (*) - details omitted (listed previously)

Thank you for your help


(Firas Fafi) #2

The problem is in these lines:

compileClasspath= sourceSets.main.output+ configurations.runtime
    runtimeClasspath= output+compileClasspath

I think I have to remove these lines


(Perryn Fowler) #3

Indeed, that first line says that the classpath used when compiling the main sourceset should contain the output from compiling the sourceset; which is a circular dependency.

What were you trying to acheive?


(Firas Fafi) #4

Thank you Perryn for your answer. Actually I try to build a project using gradle, I try to define sourceSets like this:

sourceSets
{myproject{
{
java.srcDir
[//...
]
}
}

Then I create a gwt compile task

task gwtcompile( type:JavaExec){
  inputs.source sourceSets.myproject.java.srcDirs
  outputs.dir "$buildDir/war/WEB-INF/classes"
  outputs.upToDateSpec = new org.gradle.api.specs.AndSpec()
    main="com.google.gwt.dev.Compiler"
  classpath{
    [
       sourceSets.myproject.java.srcDirs,
      sourceSets.myproject.output.classesDir,
      sourceSets.myproject.runtimeClasspath,
      configurations.gwt
    ]
  }
  args
  [
    "com.myproject.FrontEnd",
    "-style",
    "PRETTY",
    "-localWorkers",
    "5",
    "-war",
    "$buildDir/war/WEB-INF/classes",
    "-logLevel",
    "DEBUG"
  ]
    jvmArgs "-Xmx1024M"
  jvmArgs "-Xss1024k"
  jvmArgs "-Djava.awt.headless=true"
  }

But gradle fail to compile successfully using this task. So I change my mind by following an tutorial that use the default configurations (SourceSets Main…) Finally, I haven’t succeed yet finding solutions for gwt compiling for my custom sourceSets. Any suggestions?