我正在使用以下标头检查
运行maven-checkstyle-plugin
2.15
<module name="RegexpHeader">
<property
name="header"
value="^<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the "License"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.-->.*"/>
<property name="fileExtensions" value="xml"/>
</module>
<module name="RegexpHeader">
<property
name="header"
value="^/**\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the "License"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */"/>
<property name="fileExtensions" value="java"/>
</module>
什么可能导致错误line 1 in header specification is not a regular expression: InvocationTargetException
?没有什么可以尝试的,因为插件没有说明实际上有什么错误(可以返回解析器错误细节或任何有用的东西)。
完整的错误是
Failed during checkstyle configuration: cannot initialize module RegexpHeader - Cannot set property 'header' in module RegexpHeader to '^/**\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the "License"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.*': line 1 in header specification is not a regular expression: InvocationTargetException -> [Help 1]
答案 0 :(得分:1)
正常表达中某些未转义字符(例如*
)的实际原因。
checkstyle
调用maven-checkstyle-plugin
的反馈并不太好。我改进了代码以显示模式编译的错误消息,并在https://github.com/checkstyle/checkstyle/pull/897请求合并。