Redeploy process if changes detected

How can I detect when the definition for a process that has been deployed to the repository is different from the definition in the corresponding BPMN XML file? In other words, is there some way that I can figure out that a process has been modified so that I can programmatically (re)deploy it?

Ok, so I found DeploymentBuilder.enableDuplicateFiltering(), which I think answers my original question, except that it doesn’t seem to work:

Caused by: org.flowable.common.engine.api.FlowableIllegalArgumentException: deploymentName is null
	at org.flowable.engine.impl.DeploymentQueryImpl.deploymentName(

The problem appears to be that if I am creating a deployment using a classpath resource, I don’t set the deployment name (because I have no idea what the name is - it’s inside the BPMN XML file), but executeDeploy() tries to set the deploymentName when creating the query to search for existing deployments by getting the name from the requested deployment (which is of course null):

List<Deployment> deploymentEntities = new DeploymentQueryImpl(processEngineConfiguration.getCommandExecutor()).deploymentName(deployment.getName())

This seems to suggest that it is impossible to create a deployment using duplicate filtering without explicitly specifying the deployment name.

@shanloid the deployment name is not linked to the process name. You can put whatever you want in there. In a single deployment you can have multiple resources being deployed. If you don’t have a name for duplicate filtering you are going to touch all deployments which are present and that can be a bit dangerous.