registry
.add(2500, "Create table USER_PROPERTIES", CreateUserPropertiesTable.class)
.add(2501, "Add index in table USER_PROPERTIES", AddUniqueIndexInUserPropertiesTable.class)
- .add(2502, "Move module and directory properties to a project level property", MigrateModuleProperties.class)
+ .add(2502, "Archive module properties in a new project level property", MigrateModuleProperties.class)
.add(2505, "Fix the direction values of certain metrics (prepare for migration of conditions)", FixDirectionOfMetrics.class)
.add(2506, "Migrate quality gate conditions using warning, period and no more supported operations", MigrateNoMoreUsedQualityGateConditions.class);
}
package org.sonar.server.platform.db.migration.version.v76;
import java.sql.SQLException;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import org.sonar.api.utils.System2;
import org.sonar.db.Database;
if (currentModuleUuid.get() != null && builder.length() != 0) {
builder.append("\n");
}
- builder.append("# previous settings for sub-project ").append(projectName).append("::").append(moduleName).append("\n");
+ builder.append("# Settings from '").append(projectName).append("::").append(moduleName).append("'\n");
currentModuleUuid.set(moduleUuid);
}
- String propertyValue = propertyTextValue == null ? propertyClobValue : propertyTextValue;
- builder.append(propertyKey).append("=").append(propertyValue).append("\n");
+ Optional.ofNullable(Optional.ofNullable(propertyTextValue).orElse(propertyClobValue))
+ .ifPresent(value -> builder.append(propertyKey).append("=").append(value).append("\n"));
});
if (builder.length() > 0) {
}
private static void removeModuleProperties(Context context) throws SQLException {
- MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("remove module properties");
+ MassUpdate massUpdate = context.prepareMassUpdate().rowPluralName("module level properties");
massUpdate.select("select prop.id as property_id " +
"from properties prop " +
"left join projects mod on mod.id = prop.resource_id " +
underTest.execute();
verifyMultiModuleProjectMigration();
+ assertThat(getRemainingProperties()).hasSize(3);
}
@Test
underTest.execute();
verifyMultiModuleProjectMigration();
- List<Map<String, Object>> remainingProperties = db.select("select ID from properties");
- assertThat(remainingProperties).hasSize(3);
+ assertThat(getRemainingProperties()).hasSize(3);
}
@Test
verifyMultiModuleProjectMigration();
verifySecondMultiModuleProjectMigration();
+ assertThat(getRemainingProperties()).hasSize(5);
+ }
+
+ private List<Map<String, Object>> getRemainingProperties() {
+ return db.select("select ID from properties");
}
private void insertComponent(long id, String uuid, @Nullable String rootUuid, String projectUuid, String qualifier, String name) {
}
private void verifyMultiModuleProjectMigration() {
- final String expectedResult = "# previous settings for sub-project Multi-module project::Module\n" +
+ final String expectedResult = "# Settings from 'Multi-module project::Module'\n" +
"sonar.coverage.exclusions=ModuleA.java\n" +
"sonar.cpd.exclusions=ModuleB.java\n" +
"\n" +
- "# previous settings for sub-project Multi-module project::Submodule 1\n" +
+ "# Settings from 'Multi-module project::Submodule 1'\n" +
"sonar.coverage.exclusions=Module1A.java\n" +
"sonar.cpd.exclusions=Moddule1B.java\n" +
"\n" +
- "# previous settings for sub-project Multi-module project::Submodule 2\n" +
+ "# Settings from 'Multi-module project::Submodule 2'\n" +
"sonar.coverage.exclusions=Module2A.java\n" +
"sonar.cpd.exclusions=Module2B.java\n";
}
private void verifySecondMultiModuleProjectMigration() {
- final String expectedResult = "# previous settings for sub-project Another multi-module project::Module X\n" +
+ final String expectedResult = "# Settings from 'Another multi-module project::Module X'\n" +
"sonar.coverage.exclusions=InModule.java\n";
List<Map<String, Object>> properties = db.select(String.format("select ID, TEXT_VALUE, CLOB_VALUE " +
defs.addAll(asList(
PropertyDefinition.builder(CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS)
.name("Archived Sub-Projects Settings")
- .description("DEPRECATED - Recap of the properties that were previously configured at sub-project / module level. " +
- "These properties are not used anymore and should now be configured at project level. " +
- "Set this parameter to empty to prevent the analysis from displaying a warning.")
+ .description("DEPRECATED - List of the properties that were previously configured at sub-project / module level. " +
+ "These properties are not used anymore and should now be configured at project level. When you've made the " +
+ "necessary changes, clear this setting to prevent analysis from showing a warning about it.")
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_MODULES)
.onlyOnQualifiers(Qualifiers.PROJECT)
private static final Logger LOG = Loggers.get(ProjectConfigurationProvider.class);
- private static final String MODULE_LEVEL_ARCHIVED_SETTINGS_WARNING = String.format("Please configure the settings listed in " +
- "`%s` at project level and remove that setting to prevent the analysis from displaying a warning.", CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS);
+ private static final String MODULE_LEVEL_ARCHIVED_SETTINGS_WARNING = "Settings that were previously configured at " +
+ "sub-project level are not used anymore. Transition the settings listed in ‘General Settings -> General -> " +
+ "Archived Sub-Projects Settings' at project level, and clear the property to prevent the analysis from " +
+ "displaying this warning.";
private ProjectServerSettings singleton = null;