小编use*_*250的帖子

Checkstyle:尾随空格regexp问题

我正在将Checkstyle添加到我的项目中,但检测空格的规则不够好(RegexpSingleline):

(?<=\S)\s+$
Run Code Online (Sandbox Code Playgroud)

它检测尾随空格并忽略仅有空格的行(它应该允许缩进的空行).它在大多数情况下工作正常,但它使用空行抱怨javadoc/multiline注释:

/**
 * Some text
 * 
 * More text
 */
Run Code Online (Sandbox Code Playgroud)

两行之间的空行是'星号 - 空白'(默认的Eclipse格式),从而触发规则,到目前为止我无法忽略这种特殊情况.如何针对此案例修复此正则表达式?

谢谢!

注意:它不需要是多行检查并验证该行是否确实是注释的一部分,它足够好作为单行.


总结所需的规则......

正则表达式应匹配具有尾随空格的行:

x = y;     
void function() { 
Run Code Online (Sandbox Code Playgroud)

除非行上只有空格(在此异常中允许最后一个空格之前使用单个星号,但仅当星号是唯一的非空白字符时):

(only whitespaces here, all ok)
/**
 * (this text is not here, and this line is ok - this case is my uncovered situation)
 */
Run Code Online (Sandbox Code Playgroud)

regex checkstyle

6
推荐指数
1
解决办法
3864
查看次数

Maven 2-从传递依赖项版本定义依赖项版本

我将用我的实际情况解释这个问题。

我使用logback 1.0.1进行日志记录,它包括SLF4J 1.6.4作为依赖项。我还将SLF4J API桥用于旧式日志记录API(java.util.logging,log4j和commons-logging),它们不是显式的依赖项。这些还必须(最好是)版本1.6.4。

为了使我的pom.xml尽可能整洁且没有错误,我想强制要求这些API桥与SLF4J的版本相同。我知道的唯一方法是使用1.6.4版在我的pom.xml中手动将它们定义为依赖项。如果我更新了logback,并且提高了所需的SLF4J版本,则需要记住将网桥API更改为正确的版本。

我可以以某种方式将旧版API的版本与传递依赖项SLF4J的版本挂钩吗?

当前的pom.xml:

    <properties>
    <org.slf4j.version>1.6.4</org.slf4j.version>
</properties>

<dependencies>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.1</version>
        <!-- requires SLF4J 1.6.4 -->
    </dependency>
    <!-- ... -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${org.slf4j.version}</version>
        <!-- here, how to bind this version value to SLF4J's version? -->
        <scope>runtime</scope>
    </dependency>
    <!-- the other two bridge API's go here -->
</dependencies>
Run Code Online (Sandbox Code Playgroud)

java maven-2 dependency-management maven

5
推荐指数
1
解决办法
1185
查看次数

标签 统计

checkstyle ×1

dependency-management ×1

java ×1

maven ×1

maven-2 ×1

regex ×1