Esempio n. 1
0
    def __init__(self, context):
        NailgunTask.__init__(self, context)
        self._scalastyle_config = self.context.config.get_required(
            Scalastyle._CONFIG_SECTION, 'config')
        if not os.path.exists(self._scalastyle_config):
            raise Config.ConfigError(
                'Scalastyle config file does not exist: %s' %
                self._scalastyle_config)

        excludes_file = self.context.config.get(Scalastyle._CONFIG_SECTION,
                                                'excludes')
        self._excludes = set()
        if excludes_file:
            if not os.path.exists(excludes_file):
                raise Config.ConfigError(
                    'Scalastyle excludes file does not exist: %s' %
                    excludes_file)
            self.context.log.debug('Using scalastyle excludes file %s' %
                                   excludes_file)
            with open(excludes_file) as fh:
                for pattern in fh.readlines():
                    self._excludes.add(re.compile(pattern.strip()))

        self._scalastyle_bootstrap_key = 'scalastyle'
        self.register_jvm_tool(self._scalastyle_bootstrap_key, [':scalastyle'])