我有以下Gradle构建文件:https://github.com/markuswustenberg/jsense/blob/a796055f984ec309db3cc0f3e8340cbccac36e4e/jsense-protobuf/build.gradle其中包括:
checkstyle {
// TODO The excludes are not working, ignore failures for now
//excludes '**/org/jsense/serialize/protobuf/gen/**'
ignoreFailures = true
showViolations = false
}
findbugs {
// TODO The excludes are not working, ignore failures for now
//excludes '**/org/jsense/serialize/protobuf/gen/**'
ignoreFailures = true
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我正在尝试在org.jsense.serialize.protobuf.gen包中排除自动生成的代码.我无法弄清楚为excludes参数提供的字符串的格式,并且文档没有多大帮助:http://www.gradle.org/docs/1.10/dsl/org.gradle.api.plugins.quality .FindBugs.html#org.gradle.api.plugins.quality.FindBugs:排除(它只是说"排除模式集".).
所以我的问题是:如何为Findbugs和Checkstyle插件格式化排除模式字符串?
我正在运行Gradle 1.10.
谢谢!
编辑1:我得到Checkstyle排除使用以下内容:
tasks.withType(Checkstyle) {
exclude '**/org/jsense/serialize/protobuf/gen/**'
}
Run Code Online (Sandbox Code Playgroud)
但是,在Findbugs插件上使用完全相同的排除不起作用:
tasks.withType(FindBugs) {
exclude '**/org/jsense/serialize/protobuf/gen/*'
}
Run Code Online (Sandbox Code Playgroud)
编辑2:接受的答案是有效的,使用XML文件并对其进行过滤也是如此,如下所示:
findbugs {
excludeFilter = file("$projectDir/config/findbugs/excludeFilter.xml")
}
Run Code Online (Sandbox Code Playgroud)
和
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 使用Guava的EventBus,我希望能够从后台线程(称为"后台")发布到更新UI的特定线程(在本例中为线程"main").我认为以下方法可行,但这会调用后台线程中的订阅者代码:
package com.example;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.common.util.concurrent.MoreExecutors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EventBusTester {
private static final Logger log = LoggerFactory.getLogger(EventBusTester.class);
public static void main(String... args) {
new EventBusTester().run();
}
private void run() {
log.info("Starting on thread {}.", Thread.currentThread().getName());
final EventBus eventBus = new AsyncEventBus(MoreExecutors.sameThreadExecutor());
eventBus.register(this);
Thread background = new Thread(new Runnable() {
@Override
public void run() {
long now = System.currentTimeMillis();
eventBus.post(now);
log.info("Posted {} to UI on thread {}.", now, Thread.currentThread().getName());
}
}, "background"); …Run Code Online (Sandbox Code Playgroud)