本文整理了Java中org.gradle.api.invocation.Gradle.addListener()
方法的一些代码示例,展示了Gradle.addListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gradle.addListener()
方法的具体详情如下:
包路径:org.gradle.api.invocation.Gradle
类名称:Gradle
方法名:addListener
暂无
代码示例来源:origin: gradle.plugin.com.palantir/gradle-circle-style
private void configureBuildFailureFinalizer(Project rootProject, String circleReportsDir) {
int attemptNumber = 1;
File targetFile = new File(new File(circleReportsDir, "gradle"), "build.xml");
while (targetFile.exists()) {
targetFile = new File(new File(circleReportsDir, "gradle"), "build" + (++attemptNumber) + ".xml");
}
Integer container;
try {
container = Integer.parseInt(System.getenv("CIRCLE_NODE_INDEX"));
} catch (NumberFormatException e) {
container = null;
}
CircleBuildFailureListener listener = new CircleBuildFailureListener();
CircleBuildFinishedAction action = new CircleBuildFinishedAction(container, targetFile, listener);
rootProject.getGradle().addListener(listener);
rootProject.getGradle().buildFinished(action);
}
代码示例来源:origin: palantir/gradle-circle-style
private static void configureBuildFailureFinalizer(Project rootProject, String circleReportsDir) {
int attemptNumber = 1;
File targetFile = new File(new File(circleReportsDir, "gradle"), "build.xml");
while (targetFile.exists()) {
targetFile = new File(new File(circleReportsDir, "gradle"), "build" + (++attemptNumber) + ".xml");
}
Integer container;
try {
container = Integer.parseInt(System.getenv("CIRCLE_NODE_INDEX"));
} catch (NumberFormatException e) {
container = null;
}
CircleBuildFailureListener listener = new CircleBuildFailureListener();
CircleBuildFinishedAction action = new CircleBuildFinishedAction(container, targetFile, listener);
rootProject.getGradle().addListener(listener);
rootProject.getGradle().buildFinished(action);
}
}
代码示例来源:origin: google/play-services-plugins
@Override
public void apply(@Nonnull Project project) {
// When debugging and testing ensure to look at release dependencies,
// not testing dependencies because of the Android test-app
// de-duplication that happens to produce an Android test app that
// can be run in the same process as the Android App (under test).
project.getGradle().addListener(
new DependencyInspector(globalDependencies, project.getName(),
"This error message came from the strict-version-matcher-plugin Gradle plugin, report" +
" issues at https://github.com/google/play-services-plugins and disable by " +
"removing the reference to the plugin (\"apply 'strict-version-matcher-plugin'\")" +
" from build.gradle."));
}
}
代码示例来源:origin: google/play-services-plugins
@Override
public void apply(@Nonnull Project project) {
// When debugging and testing ensure to look at release dependencies,
// not testing dependencies because of the Android test-app
// de-duplication that happens to produce an Android test app that
// can be run in the same process as the Android App (under test).
project.getGradle().addListener(
new DependencyInspector(globalDependencies, project.getName(),
"This error message came from the strict-version-matcher-plugin Gradle plugin, report" +
" issues at https://github.com/google/play-services-plugins and disable by " +
"removing the reference to the plugin (\"apply 'strict-version-matcher-plugin'\")" +
" from build.gradle."));
}
}
代码示例来源:origin: palantir/gradle-baseline
private static void configureBuildFailureFinalizer(Project rootProject, String circleReportsDir) {
int attemptNumber = 1;
Path targetFile = Paths.get(circleReportsDir, "gradle", "build.xml");
while (targetFile.toFile().exists()) {
targetFile = Paths.get(circleReportsDir, "gradle", "build" + (++attemptNumber) + ".xml");
}
Integer container;
try {
container = Integer.parseInt(System.getenv("CIRCLE_NODE_INDEX"));
} catch (NumberFormatException e) {
container = null;
}
CircleBuildFailureListener listener = new CircleBuildFailureListener();
CircleBuildFinishedAction action = new CircleBuildFinishedAction(container, targetFile, listener);
rootProject.getGradle().addListener(listener);
rootProject.getGradle().buildFinished(action);
}
}
代码示例来源:origin: gradle.plugin.org.mockito/release
public void apply(final Project project) {
//main release task
project.getTasks().create("release");
final ReleaseWorkflowExtension ext = project.getExtensions().create("releaseWorkflow", ReleaseWorkflowExtension.class, project);
//setup listener, so that the postSteps are only executed if one of the main tasks fail
project.getGradle().addListener(new PostStepTaskEnabler(ext));
//TODO very implicit, it needs to go to some tools for release, for example, "releaseTools.git"
GitTool gitTool = Git.gitTool(Exec.getProcessRunner(project.getProjectDir()));
project.getExtensions().getExtraProperties().set("gitTool", gitTool);
}
代码示例来源:origin: mockito/shipkit
/**
* Gets singleton configurer from the root project
*/
@ExposedForTesting
static LazyConfiguration getConfigurer(Project project) {
Project rootProject = project.getRootProject();
//single configurer for the entire build, hooked up to the root project, for simplicity and speed
//we don't want too many listeners that introduce blocking callbacks to Gradle internals
LazyConfiguration configurer = rootProject.getExtensions().findByType(LazyConfiguration.class);
if (configurer == null) {
configurer = new LazyConfiguration();
rootProject.getExtensions().add(LazyConfiguration.class.getName(), configurer);
rootProject.getGradle().addListener(configurer.listener);
}
return configurer;
}
}
代码示例来源:origin: org.shipkit/shipkit
/**
* Gets singleton configurer from the root project
*/
@ExposedForTesting
static LazyConfiguration getConfigurer(Project project) {
Project rootProject = project.getRootProject();
//single configurer for the entire build, hooked up to the root project, for simplicity and speed
//we don't want too many listeners that introduce blocking callbacks to Gradle internals
LazyConfiguration configurer = rootProject.getExtensions().findByType(LazyConfiguration.class);
if (configurer == null) {
configurer = new LazyConfiguration();
rootProject.getExtensions().add(LazyConfiguration.class.getName(), configurer);
rootProject.getGradle().addListener(configurer.listener);
}
return configurer;
}
}
代码示例来源:origin: gradle.plugin.org.shipkit/shipkit
/**
* Gets singleton configurer from the root project
*/
@ExposedForTesting
static LazyConfiguration getConfigurer(Project project) {
Project rootProject = project.getRootProject();
//single configurer for the entire build, hooked up to the root project, for simplicity and speed
//we don't want too many listeners that introduce blocking callbacks to Gradle internals
LazyConfiguration configurer = rootProject.getExtensions().findByType(LazyConfiguration.class);
if (configurer == null) {
configurer = new LazyConfiguration();
rootProject.getExtensions().add(LazyConfiguration.class.getName(), configurer);
rootProject.getGradle().addListener(configurer.listener);
}
return configurer;
}
}
代码示例来源:origin: gradle.plugin.com.palantir/gradle-circle-style
@Override
public void execute(Project evaluatedRootProject) {
final String circleReportsDir = System.getenv(extension.getTestReportsEnvVariable());
if (circleReportsDir == null) {
return;
}
configureBuildFailureFinalizer(evaluatedRootProject, circleReportsDir);
final StyleTaskTimer timer = new StyleTaskTimer();
evaluatedRootProject.getGradle().addListener(timer);
evaluatedRootProject.allprojects(new Action<Project>() {
@Override
public void execute(final Project project) {
project.getTasks().withType(Checkstyle.class, new Action<Checkstyle>() {
@Override
public void execute(Checkstyle checkstyleTask) {
configureCheckstyleTask(project, checkstyleTask, circleReportsDir, timer);
}
});
project.getTasks().withType(FindBugs.class, new Action<FindBugs>() {
@Override
public void execute(FindBugs findbugsTask) {
configureFindbugsTask(project, findbugsTask, circleReportsDir, timer);
}
});
}
});
}
});
代码示例来源:origin: palantir/gradle-circle-style
rootProject.getGradle().addListener(timer);
代码示例来源:origin: com.android.tools.build/gradle-core
/**
* Initialize the {@link ProcessProfileWriterFactory}. Idempotent.
*
* @param project the current Gradle {@link Project}.
*/
public static void init(@NonNull Project project) {
synchronized (LOCK) {
//noinspection VariableNotUsedInsideIf
if (recordingBuildListener != null) {
return;
}
ProcessProfileWriterFactory.initialize(
project.getRootProject().getProjectDir(),
project.getGradle().getGradleVersion(),
new LoggerWrapper(project.getLogger()),
new File(project.getRootProject().getBuildDir(), "android-profile"));
recordingBuildListener = new RecordingBuildListener(ProcessProfileWriter.get());
project.getGradle().addListener(recordingBuildListener);
}
project.getGradle().addListener(new ProfileShutdownListener(project));
}
代码示例来源:origin: palantir/gradle-baseline
project.getRootProject().getGradle().addListener(timer);
内容来源于网络,如有侵权,请联系作者删除!