There’s never an ideal time to antagonize the world’s largest army. But this week — when China is seething over perceived American aggression — is a particularly bad moment to rile up Beijing.

Yet that’s exactly what the US Republican Party is doing. At its ongoing convention in Cleveland, led by nominee Donald Trump, the party is doubling down on China bashing.

According to the new Republican platform, China is guilty of “cultural genocide,” “barbaric population control” and a state-backed “hostile takeover” of American businesses.

Worse yet, China’s military is growing more intimidating thanks to — you guessed it — the “complacency of the Obama regime.”

This bluster comes at an extremely tense moment in US-China relations.

Last week, an international tribunal at The Hague sided with the United States and eviscerated one of China’s most contentious claims of sovereignty.

For years, Beijing has insisted that practically all of the South China Sea — a vital waterway that supports one-third of the world’s shipping trade — is the “blue national soil” of China.

Unsurprisingly, other nations who look upon the sea from their shores (namely Vietnam and the Philippines) have never agreed.

The US has urged both Vietnam and the Philippines to stand tall against China. All the while, the US military has deployed its superior fleet of drones and warships into the sea to scare China into submission.

China’s response? Transforming minuscule islands into remote military bases armed with powerful missiles. Once little specks of rock, these islands have swelled as Chinese barges dump mountains of sand around their edges.

Beijing has always paired its military maneuvers in the sea with rhetorical bombast printed in state-run media, which offers a window into the Communist Party’s thinking.

But in the wake of the Hague tribunal’s verdict, the government’s mouthpiece media have spoken more forcefully about the prospects for war.

One op-ed from a state-run outlet asks, “Is there any chance of war in the South China Sea?” The same piece suggests that, if the United States did battle China over the sea, America may be vanquished: “The 21st century has witnessed a series of failures of US military actions.”

Another column compares the tribunal’s South China Sea ruling to the US-orchestrated campaign to convince the world that Iraq possessed “weapons of mass destruction” — thus making the case for invasion.

According to the op-ed, this is the “same trick” played by the US, which “believes in nothing but ‘might makes right.’” (For good measure, the state-run paper adds that former President George W. Bush should be charged as a war criminal.)

In the view of Chinese communist stalwarts, the tribunal’s verdict is “radical and shameless” and will be disregarded as “nothing but a piece of paper.”

Yet they concede this this piece of paper “may bring the China-US contest to a new climax” — and offers the US “a great opportunity to humiliate and contain China.”

There is a common thread between the screeds coming from Beijing and Cleveland. Both parties, Communist and Republican, hope to project uncompromising power while satiating the nationalistic fervor that surges through their follower base.

On the Republican side, this anti-China drumbeat appears to have grown much louder with the ascent of Trump, a candidate who insists that “we can’t continue to allow China to rape our country.”

Trump’s Democrat rival Hillary Clinton hasn’t matched that level of outrageous rhetoric. But in Beijing’s halls of power, she too is regarded as overly hostile. As US secretary of state, she routinely castigated China. If elected, she could more forcefully challenge Beijing in the South China Sea than President Barack Obama ever did.

No matter who takes the US presidency, the odds of a naval war with China remain low — at least in the near future. The two nations are simply too intertwined to rush headlong into conflict. A Chinese state-run paper rightly points out that “only maniacs would start a war between China and the US.”

But nationalistic bluster is intensifying in both countries. And each year, an increasing number of warships, missiles and drones are brought to the sea to jockey for supremacy.

The sea is primed for an unintended event — a drone shot down, a game of chicken between warships gone too far — that would demand extraordinary tact from a future US president seeking to avoid war.

As China’s state-run Global Times puts it: “An accidental gunshot might put policymakers in both countries under huge pressure from public opinion, which could unexpectedly escalate the situation and lead to a grave crisis.”