"header specification is not a regular expression: InvocationTargetException"的原因是什么



我正在运行maven-checkstyle-plugin 2.15,其中包含以下标头检查规范

<module name="RegexpHeader">
    <property
        name="header"
        value="^&lt;!--n    Licensed to the Apache Software Foundation (ASF) under one or moren   contributor license agreements.  See the NOTICE file distributed withn   this work for additional information regarding copyright ownership.n   The ASF licenses this file to You under the Apache License, Version 2.0n   (the &quot;License&quot;); you may not use this file except in compliance withn   the License.  You may obtain a copy of the License atnn        http://www.apache.org/licenses/LICENSE-2.0nn   Unless required by applicable law or agreed to in writing, softwaren   distributed under the License is distributed on an &quot;AS IS&quot; BASIS,n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n   See the License for the specific language governing permissions andn   limitations under the License.--&gt;.*"/>
    <property name="fileExtensions" value="xml"/>
</module>
<module name="RegexpHeader">
    <property
        name="header"
        value="^/**n * Licensed to the Apache Software Foundation (ASF) under one or moren * contributor license agreements.  See the NOTICE file distributed withn * this work for additional information regarding copyright ownership.n * The ASF licenses this file to You under the Apache License, Version 2.0n * (the &quot;License&quot;); you may not use this file except in compliance withn * the License.  You may obtain a copy of the License atn *n *      http://www.apache.org/licenses/LICENSE-2.0n *n * Unless required by applicable law or agreed to in writing, softwaren * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n * See the License for the specific language governing permissions andn * 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 moren * contributor license agreements.  See the NOTICE file distributed withn * this work for additional information regarding copyright ownership.n * The ASF licenses this file to You under the Apache License, Version 2.0n * (the "License"); you may not use this file except in compliance withn * the License.  You may obtain a copy of the License atn *n *      http://www.apache.org/licenses/LICENSE-2.0n *n * Unless required by applicable law or agreed to in writing, softwaren * 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 andn * limitations under the License.n */.*': line 1 in header specification is not a regular expression: InvocationTargetException -> [Help 1]

一些未转义字符的实际原因,如正则表达式中的*

maven-checkstyle-plugin调用的checkstyle的反馈不是太大。我改进了代码以显示模式编译的错误消息,并在https://github.com/checkstyle/checkstyle/pull/897.

最新更新