General Motors Co. (GM.N) plans to invest $170 million to continue manufacturing parts at a Canadian plant that was slated to close in December.

The facility in Oshawa, Ontario will focus on stamping, and sub-assembly for GM and other auto companies. The Detroit-based carmaker also plans to convert part of the plant to a test track for autonomous and advanced technology vehicles. About 300 of almost 3,000 jobs will be maintained, with potential for more in the coming years.

The shift to autonomous vehicle technology “embeds” the Oshawa facility into the overhaul of an industry that’s shifting to electric cars and gearing up for self-driving vehicles. GM also employs people in Toronto and in nearby Markham, Ontario to develop the next generation of cars.

“We are integrating into the future of our business,” GM Canada President Travis Hester told reporters in Toronto Wednesday, adding the company sees “significant” opportunity for growth.

The announcement is a partial reprieve for the Oshawa plant, once the largest in Canada that employed about 21,000 people. The factory, located about 60 kilometers (40 miles) east of Toronto, currently builds the Chevrolet Impala and Cadillac XTS cars, both of which are being discontinued. It also does finishing work on pickup trucks built in Fort Wayne, Indiana under a program that’s slated to end this year.

Canada’s auto industry has been in decline for years as manufacturers shift production to cheaper jurisdictions in the southern U.S. and Mexico. In addition to the shutdown in Oshawa, which has been churning out cars and trucks for more than a century, Fiat Chrysler Automobiles NV is slated to cut a line at its minivan plant in Windsor, Ontario this fall.

“I’m not leaving here celebrating today,” said Jerry Dias, head of union Unifor. ”I’m here understanding we made the best of a poor situation.”

GM Canada will offer relocation services to Oshawa employees seeking jobs at some of its other Ontario operations, along with enhanced retirement packages, and financial support in transitioning workers out of the company, according to a company statement.