@VisibleForTesting public static void initializeForTests(@NonNull Path profileOutputFile) { sINSTANCE = new ProcessProfileWriterFactory(); sINSTANCE.setProfileOutputFile(profileOutputFile); ProcessProfileWriter recorder = sINSTANCE.get(); // Initialize the ProcessProfileWriter instance recorder.resetForTests(); setGlobalProperties(recorder, new File("fake/path/to/test_project/"), "2.10", new StdLogger(StdLogger.Level.VERBOSE)); }
public static Recorder get() { return ProcessProfileWriterFactory.getFactory().isInitialized() ? RECORDER : NO_OP_RECORDER; }
/** Set up the the ProcessProfileWriter. Idempotent for multi-project builds. */ public static void initialize( @NonNull File rootProjectDirectoryPath, @NonNull String gradleVersion, @NonNull ILogger logger, @NonNull File profileOutputDirectory) { synchronized (LOCK) { if (sINSTANCE.isInitialized()) { return; } sINSTANCE.setLogger(logger); sINSTANCE.setProfileOutputFile( profileOutputDirectory .toPath() .resolve(PROFILE_FILE_NAME.format(LocalDateTime.now()))); ProcessProfileWriter recorder = sINSTANCE.get(); // Initialize the ProcessProfileWriter instance setGlobalProperties(recorder, rootProjectDirectoryPath, gradleVersion, logger); } }
@SuppressWarnings("VariableNotUsedInsideIf") private void assertRecorderNotCreated() { if (isInitialized()) { throw new RuntimeException("ProcessProfileWriter already created."); } }
@NonNull public static ProcessProfileWriter get() { return ProcessProfileWriterFactory.sINSTANCE.get(); }
public synchronized void setLogger(@NonNull ILogger iLogger) { assertRecorderNotCreated(); this.mLogger = iLogger; }
synchronized ProcessProfileWriter get() { if (processProfileWriter == null) { Preconditions.checkState( profileOutputFile != null, "call setProfileOutputFile() first"); if (mLogger == null) { mLogger = new StdLogger(StdLogger.Level.INFO); } initializeAnalytics(mLogger, mScheduledExecutorService); processProfileWriter = new ProcessProfileWriter(profileOutputFile); } return processProfileWriter; } }
/** * 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)); }
public static void shutdown() throws InterruptedException { synchronized (LOCK) { if (sINSTANCE.isInitialized()) { sINSTANCE.processProfileWriter.finish(); } sINSTANCE.processProfileWriter = null; } }