Building wealth generally means long-term investing. That's holding great businesses for a long time, letting earnings grow and dividends accumulate for years. A diverse portfolio of great stocks can set you up for a comfortable retirement -- maybe even retiring a millionaire.

The industrial and energy sectors can be a great place to look because these companies are foundations for the economy. Stocks like ExxonMobil (XOM -2.78%), Lockheed Martin (LMT -0.75%), and Caterpillar (CAT 1.59%) have strong fundamentals and long-term growth opportunities to deliver long-term results.

Here is what you need to know.

1. An energy titan

ExxonMobil is one of the world's largest energy companies. It works primarily in oil and gas, exploring for and extracting fossil fuels from the ground and refining and selling them to market. Exxon's been a stalwart for decades and has raised its dividend for 41 consecutive years. That is a testament to the company's ability to navigate the ups and downs when oil and gas prices fluctuate.

Renewable energy sources have grown and improved enough that society could reach a point where demand for fossil fuels peaks. Some experts believe that peak could arrive by 2030. However, it's still very premature to write off ExxonMobil, which is seeing near-record cash profits due to high oil prices.

Additionally, Exxon's size will enable it to scoop up smaller competitors as the industry steadily shrinks and condenses. It recently agreed to acquire Pioneer Natural Resources, an oil and gas exploration company, for $59.5 billion in stock. The deal adds $20 billion in annual revenue to Exxon's $364 billion over the past 12 months. Investors can feel good about the company's stability and dividend moving forward.

2. A leading defense company

Lockheed Martin is a critical partner for the U.S. government. The company is behind developing and constructing some of America's most cutting-edge weapons, aircraft, and defense systems. You can almost think of Lockheed Martin as a publicly traded extension of the U.S. government. It contributes more than 70% of Lockheed's annual revenue. Most of its business involves branches of the military and NASA.

Being so intertwined with the government has its pros and cons. The good news is that Lockheed Martin is an innovator and supplier for America's defense, with an entrenched relationship that spans many decades.

Lockheed Martin has competition, but it seems there's always enough to go around for all of America's defense contractors. Investors probably don't have to worry about the stability of Lockheed Martin's business, which, in addition to its close government ties, often works on multiyear contracts that give the company a predictable revenue stream. On the other hand, government spending can fluctuate, and budget cuts could directly impact Lockheed Martin's growth prospects.

For better or for worse, America is hugely influential in the broader global political scene. Conflicts in Europe and the Middle East require resources and that our country keep its defenses sharp. In other words, Lockheed Martin's business could remain strong.

3. Building the future

Caterpillar, known for its signature yellow paint color, builds massive machinery. The company's products range from small bulldozers to huge Earth-moving vehicles for construction and mining. One could argue that global construction is an evergreen industry with almost endless demand. The world is constantly building new, demolishing old, and mining for the resources that will power our present and future needs.

The company has played a role in serving those needs for a long time. Caterpillar has paid and raised its dividend for 30 consecutive years, meaning it's continued putting more money in shareholders' pockets despite the ups and downs of the economy, including a global pandemic and the Great Recession. Caterpillar has competition, but its combination of a global footprint, powerful brand, and ability to integrate complementary revenue streams like servicing and finance has proven effective at growing Caterpillar's business profitability.

Despite Caterpillar doing nearly $65 billion in annual sales, there is plenty of room for long-term growth. The global construction market is worth more than $14 trillion today and will likely continue growing over the coming years. Caterpillar has plenty of room to repeat its winning recipe and enjoy steady long-term growth, making the stock a potential winner for years to come.