"He is all of thirty-one" meaning
Quoting the OED:
all of
as much as (often used ironically of an amount or quantity considered small by the speaker):
the show lasted all of six weeks
As per the above definition, the usual phrase used is something along the lines of:
He was all of fifteen when he sneaked into the army.
She was all of eighteen when she completed her master's degree.
When used with age, the phrase customarily indicates that a person is/was too young or mature for something, or doing something unexpected for that age.
In the case of the lyrics (from "Universal Soldier" by Donovan), it needs to be taken in context:
He's five foot-two, and he's six feet-four,
He fights with missiles and with spears.
He's all of thirty-one, and he's only seventeen,
He's been a soldier for a thousand years.
This essentially appears to be an antiwar song and seems to state something along the lines of "violence begets violence", "there is no end to war", and so on. The lyricist is trying to say that all types of soldiers have been fighting wars through the ages using a variety of weapons, and there's still no end to it.
He's all of thirty-one, and he's only seventeen,
To get his point across, he purposely uses "all of thirty-one"--a phrase normally used to describe younger soldiers--to indicate that even at that age, a soldier is way too young for war. He then contrasts this with a seventeen year old who is also fighting in some war. In other words, the 'Universal Soldier' represents all the soldiers throughout human history.
'All of thirty-one' would normally mean he's definitely, or even at least, thirty-one, but here, of course, it means that the seventeen-year old only seems it.
I've always interpreted this line a little differently than Luke and Barrie. Since the song is about the "universal soldier," I imagined that "all of 31" referred to seasoned officers, while "only 17" alluded to newly-enlisted privates - it's a paradox intended to capture the full range of soldiers one might find on the battlefield.
That's why this same soldier can be "5 foot 2" and "6 feet 4."
But there's plenty of room for interpretation; that's why EL&U usually discourages song lyrics. I don't want to start a war over this.