# Circular dependency between tasks. Cycle includes \[task ':javadoc', task ':javadoc'\]

**URL:** https://discuss.gradle.org/t/circular-dependency-between-tasks-cycle-includes-task-javadoc-task-javadoc/4484
**Category:** Old Forum Archive
**Created:** [June 24, 2012, 8:26am UTC](https://discuss.gradle.org/t/circular-dependency-between-tasks-cycle-includes-task-javadoc-task-javadoc/4484 "2012-06-24T08:26:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jkuperus](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jkuperus/32/691_2.png) [@jkuperus](https://discuss.gradle.org/u/jkuperus)
#### Post date: [June 24, 2012, 8:26am UTC](https://discuss.gradle.org/t/circular-dependency-between-tasks-cycle-includes-task-javadoc-task-javadoc/4484/1 "2012-06-24T08:26:00Z")

</div>

I am working on developing a plugin that

1. Adds a sourceset,

2. Compiles this sourceset,

3. Adds the compiled classes to a jar 4. Specifies the jar file as the artifact of a custom configuration

In a project I am using to try this plugin out my main configuration depends on the artifact in my custom configuration, like this :

```gradle
compile project(path: ':',
configuration: 'service')

```

But now when I run gradle javadoc, I get the following error :

Circular dependency between tasks. Cycle includes [task ‘:javadoc’, task ‘:javadoc’]

Does anyone have any idea why this happens ?

The plugin source can be viewed at : [https://github.com/jelmerk/liferay-gradle-plugin/blob/master/src/main/java/nl/orange11/liferay/ServiceBuilderPlugin.java](https://github.com/jelmerk/liferay-gradle-plugin/blob/master/src/main/java/nl/orange11/liferay/ServiceBuilderPlugin.java)

My full test script looks like this :

```gradle
buildscript {
    repositories {
  mavenLocal()
  mavenCentral()
    }
    dependencies {
        classpath group: 'nl.orange11.liferay', name: 'liferay-plugin', version: '0.0.1-SNAPSHOT'
    }
}
  buildscript {
   configurations.classpath.resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
  apply plugin: 'liferay-portlet'
apply plugin: 'liferay-servicebuilder'
  repositories {
    mavenLocal()
    mavenCentral()
}
  dependencies {
    providedCompile 'javax.servlet:servlet-api:2.5'
    providedCompile 'javax.servlet.jsp:jsp-api:2.1'
    providedCompile 'com.liferay.portal:portal-service:6.1.0'
    providedCompile 'com.liferay.portal:util-java:6.1.0'
    providedCompile 'com.liferay.portal:util-bridges:6.1.0'
    providedCompile 'com.liferay.portal:util-taglib:6.1.0'
              compile project(path: ':',
configuration: 'service')
          serviceCompile 'com.liferay.portal:portal-service:6.1.0'
}
  liferay {
 appServerDirName = '/Users/jkuperus/Development/Projects/liferay_6_1_ga1/build/portal/apache-tomcat/'
}
  servicebuilder {
 jalopyInputFileName = file('jalopy.xml')
}

```

---

<div class="post-metadata">

### Author: ![jkuperus](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jkuperus/32/691_2.png) [@jkuperus](https://discuss.gradle.org/u/jkuperus)
#### Post date: [June 28, 2012, 9:29am UTC](https://discuss.gradle.org/t/circular-dependency-between-tasks-cycle-includes-task-javadoc-task-javadoc/4484/2 "2012-06-28T09:29:00Z")

</div>

I actually did a bit of debugging and the problem is in the way the JavaPlugin sets up the javadoc task

Basicallly it does this :

```gradle
Javadoc javadoc = project.getTasks().add(JAVADOC_TASK_NAME, Javadoc.class);
....
addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);

```

Where addDependsOnTaskInOtherProjects looks like this

```gradle
private void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn, String otherProjectTaskName,
                                                 String configurationName) {
        Project project = task.getProject();
        final Configuration configuration = project.getConfigurations().getByName(configurationName);
        task.dependsOn(configuration.getTaskDependencyFromProjectDependency(useDependedOn, otherProjectTaskName));
    }

```

This means that you always get a circular dependency if you depend on an artifact in another configuration of the same project

Does anyone have a solution for this ? It feels kind of like a bug to me, or at least something thats not configurable enough

---

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [June 28, 2012, 1:39pm UTC](https://discuss.gradle.org/t/circular-dependency-between-tasks-cycle-includes-task-javadoc-task-javadoc/4484/3 "2012-06-28T13:39:00Z")

</div>

It’s uncommon to depend on a configuration from the same project in this way. Can you get around this? Otherwise, a potential hack is to overwrite the ‘javadoc’ task’s task dependencies. (Probably the Java plugin should be smart enough not to make the Javadoc task depend on itself.) Not sure if this will be the only problem though.
