Eclipse showing compile error if remove main

Continuing the discussion from Custom SourceSet issue while creating war:

Continuing the discussion from Custom SourceSet issue while creating war:

Eclipse showing compile errors for the classes in SVC if we remove main and use debug

This is one of the solution to override excluding attribute in classpathentry manually.

eclipse {
        classpath {
                  defaultOutputDir = file('web/WebContent/WEB-INF/classes')
            file {
                withXml {
                    def node = it.asNode()
                       for(classpathEntry in node) {
                          if (classpathEntry.attribute('excluding') == 'gov/fd/vc/svc/**') {
                             classpathEntry.attributes().put('excluding', '')
                          }
                          if (classpathEntry.attribute('excluding') == 'gov/fd/vc/dao/**') {
                             classpathEntry.attributes().put('excluding', '')
                          }
                        }
                  
                }
                
            }
        }
    }

But could any one please suggest optimize solution.