One build one microservice only on clean build

I have one microservice that is needed only locally, and not in any other envs.
Is it possbile to setup configuration so that one microservice and the build task’s of the service are run only on clean build? For existing configuration, the most straightforward solution would be to add if-clase into settings.gradle where all the services are listed. Is it possible, or is even by the book? Or how should this be done, so that build.gradle of that microservice would be never run on build, only clean build…