How to schedule resources in parent tasks for as long as the subtasks last

17 views
Skip to first unread message

Roelant Ossewaarde

unread,
May 31, 2026, 6:47:31 AMMay 31
to TaskJuggler Users
Hi all,

Consider the situation where there is an academic project that runs for a few years. One of the subprojects runs for a short period of time. I'd like to schedule a resource to provide oversight over the tasks in the subproject.  

When I use the following code, the resource workpackageManager is scheduled for the duration of the project, not for the duration of wp0. With the following code:

task project "Project" {
  task wp0 "First workpackage" {
    task oversight "Workpackage management"{
      start ${projectstart}
      allocate workpackageManager
      limits {  weeklymax 1h {resources workpackageManager} }
    }
    task task1 "Task 1" {
      allocate Scientist1
      length 1w
    }
    task task2 "Task 2" {
      depends !x
      allocate Scientist1
      length 1w
    }
  }

See the attached Gantt chart. Obviously, oversight for that work package should end whenever that work package concludes (and not whenever the project concludes). 

A relative end date for the oversight task would be helpful ("end task2{onend}"), but onend does not yield the date that "end" wants as an argument. 

I could in theory specify the end date after inspecting whatever the scheduler decided the end date of the subtasks should be, but there surely must be a less manual way?

Kind regards,

Roelant.


Screenshot 2026-05-31 at 12.23.22.png

Michael Howe

unread,
Jun 1, 2026, 12:26:19 PMJun 1
to taskjugg...@googlegroups.com
Hi
Gemini chewed over this for some time and answered:

The issue here is that your `oversight` task is open-ended on its back end. Because it only has a `start` date specified and no explicit `length`, `duration`, or `effort`, TaskJuggler leaves the task unbounded. By default, it will stretch to the end of the parent container—in this case, the entire project.

To fix this, you need to turn `oversight` into a **hammock task**. A hammock task dynamically stretches its duration to exactly fill the space between two specific boundaries without needing an explicit length.

Since TaskJuggler 3, you can create a hammock task by defining a **Start-to-Start** dependency and an **End-to-End** dependency. You do this using the `{ onstart }` and `{ onend }` attributes.

Here is how you can update your code to tie the `oversight` task strictly to the duration of `wp0`.

```taskjuggler

task project "Project" {
  task wp0 "First workpackage" {
   
    task oversight "Workpackage management"{
      # Start-to-Start dependency: Starts exactly when task1 starts
      depends !task1 { onstart }
     
      # End-to-End dependency: Ends exactly when task2 ends
      depends !task2 { onend }

     
      allocate workpackageManager
      limits { weeklymax 1h {resources workpackageManager} }
    }
   
    task task1 "Task 1" {
      start ${projectstart}

      allocate Scientist1
      length 1w
    }
   
    task task2 "Task 2" {
      depends !task1 # Corrected !x to !task1
      allocate Scientist1
      length 1w
    }
  }
}

```

### **Why this works:**

1. **Moved the Start Date:** I moved `start ${projectstart}` from the `oversight` task to `task1`. This establishes `task1` as the true anchor point for the work package.
2. **Dynamic Start (`onstart`):** `depends !task1 { onstart }` tells TaskJuggler that `oversight` cannot start until `task1` starts.
3. **Dynamic End (`onend`):** `depends !task2 { onend }` tells TaskJuggler that `oversight` must finish when `task2` finishes.

Because `oversight` has no explicit duration of its own, the scheduler naturally stretches it to fill the gap between the start of `task1` and the end of `task2`.

---

**Best Practice Note:** If your work package is going to grow beyond just two tasks, it is highly recommended to use **milestones** to bracket the work. You can create a `start_ms` milestone and an `end_ms` milestone, have your tasks flow between them, and simply tie your `oversight` hammock task to those two milestones. This way, you won't have to rewrite the oversight dependencies every time you add a new final task to the work package.

Mike

--
You received this message because you are subscribed to the "TaskJuggler Users" group.
To post to this group, send email to taskjugg...@googlegroups.com
To unsubscribe from this group, send email to
taskjuggler-us...@googlegroups.com
For more information about TaskJuggler visit http://www.taskjuggler.org
---
You received this message because you are subscribed to the Google Groups "TaskJuggler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taskjuggler-us...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/taskjuggler-users/789aafc4-2e1c-4906-acbf-184b19106db1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages