If I understand correctly, you want something like:
T = 4
model = Model()
@variable(model, x[1:T], Bin)
@variable(model, 1 <= S <= T, Int)
@variable(model, D >= 0, Int)
# x[t] == 1 if S <= t <= S + D???
This type of formulation is quite difficult to work with.
There are a few alternative formulations, one example is something like:
T = 4
model = Model()
# start and stop are monotonic {0, 1} variables that begin at 1 and drop to 0
# at some point. The job starts when start => 0, and it stops when stop => 0.
@variable(model, start[1:T], Bin)
@variable(model, stop[1:T], Bin)
@constraint(model, [t=2:T], start[t-1] >= start[t])
@constraint(model, [t=2:T], stop[t-1] >= stop[t])
# We can work out the activity of each job by looking at the difference. When
# they are both 1, the job hasn't started yet. When they are both 0, the job has
# stopped.
@expression(model, x[t=1:T], stop[t] - start[t])
@expression(model, D, sum(x)) # The duration is sum(x)
@expression(model, S, sum(start)) # starting block is the sum of start
# With a constraint that the duration cannot be negative.
@constraint(model, D >= 0)
You could also look into set partitioning formulations. If you search “job shop scheduling” you should be able to find a large number of papers that are similar to your problem.