int sz = executions.size();
if (!hasNature) {
++sz;
}
monitor.beginTask("Configuring TeaVM builder", sz * 1000);
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
try {
if (!hasNature) {
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
}
settings.load();
Set<String> coveredProfiles = new HashSet<>();
for (MojoExecution execution : executions) {
if (monitor.isCanceled()) {
return;
}
String profileId = getIdForProfile(execution);
coveredProfiles.add(profileId);
TeaVMProfile profile = settings.getProfile(profileId);
if (profile == null) {
profile = settings.createProfile();
profile.setName(profileId);
}
profile.setExternalToolId(TOOL_ID);
configureProfile(execution, profile, new SubProgressMonitor(monitor, 1000));
if (monitor.isCanceled()) {
return;
}
}
for (TeaVMProfile profile : settings.getProfiles()) {
if (!coveredProfiles.contains(profile.getName()) && profile.getExternalToolId().equals(TOOL_ID)) {
settings.deleteProfile(profile);
}
}
settings.save();
} finally {
monitor.done();
}
}