Prof. Robert Barro of Harvard has worked years on this topic, with his most recent estimates prepared with Charles Redlick in 2009. They find that military purchases reduce the size of the civilian economy, but the civilian reduction is less than the military expansion, so the net result is a larger economy.
Another way to look at it: some additional military resources come from the civilian business sector, but the rest comes from people and materials that would be not be engaged in the economy at all.
By the same logic, government spending on road building, scientific research and other projects could expand the economy, although in the process they might reduce the size of the private sector. Perhaps road building and scientific research would even expand the economy in the long term as they made labor and capital more productive.
However, government purchases are a minority of federal government spending. The rest consists largely of transfer payments and interest payments on the federal debt. For example, the federal government spent $3.9 trillion in calendar year 2011, of which $2.3 trillion was on transfer payments such as Social Security benefits, unemployment insurance and food stamps.
[...]The American Recovery and Reinvestment Act included purchases and transfers (as well as so-called tax credits, which are another story, discussed in a previous post). The transfers served to shrink the economy, while the purchases may have pushed to expand it.
On balance, that is why many Americans had trouble seeing much net economic expansion produced by the act.