From my understanding it seems to be a somewhat modern notion that military jihad is only halal when it is in self-defense. I'm wondering if that narrative has any backing in pre-modern fiqh; while it's easy to find opinions that consider jihad for the purpose of conquest to be a communal obligation, I can't find anyone that says that this is haram in principle.
Note that I'm not talking about scholars that say the ummah has to keep the peace treaties it enters into, as the caliph can decide whether or not to conclude such a treaty, making that optional and not a principled stance. I'm asking for legal opinions that conclude that war for purposes other than self-defense is haram in principle.
Question: Which pre-modern scholars (say, before the 19th century CE), if any, considered jihad for purposes other than self-defense to be haram in principle?