diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3adb2fc4..0092b6706 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: java: - - 11 + - 17 steps: - name: Checkout @@ -67,7 +67,7 @@ jobs: ./gradlew clean build - name: Archive artifact - if: success() && matrix.java == '11' + if: success() && matrix.java == '17' uses: actions/upload-artifact@v3 with: name: snapshot @@ -87,7 +87,7 @@ jobs: name: Set up Java uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 java-package: jdk distribution: 'zulu' - @@ -148,7 +148,7 @@ jobs: name: Set up Java uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 java-package: jdk distribution: 'zulu' - diff --git a/build.gradle b/build.gradle index e9a6fc491..4f958cad8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Michael Clarke + * Copyright (C) 2020-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -40,7 +40,7 @@ repositories { } } -def sonarqubeVersion = '9.8.0.63668' +def sonarqubeVersion = '10.0.0.68432' def sonarqubeLibDir = "${projectDir}/sonarqube-lib" def sonarLibraries = "${sonarqubeLibDir}/sonarqube-${sonarqubeVersion}/lib" @@ -100,7 +100,7 @@ jar { 'Plugin-License': 'GNU LGPL 3', 'Plugin-Version': "${project.version}", 'Plugin-Organization': 'Michael Clarke', - 'Sonar-Version': "${sonarqubeVersion}", + 'Sonar-Version': "9.14.0.375", 'Plugin-IssueTrackerUrl': 'https://github.com/mc1arke/sonarqube-community-branch-plugin/issues', 'Plugin-Key': 'communityBranchPlugin', 'Plugin-Class': 'com.github.mc1arke.sonarqube.plugin.CommunityBranchPluginBootstrap', diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgent.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgent.java index d9f5cbe1b..743c14584 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgent.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Michael Clarke + * Copyright (C) 2021-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -52,9 +52,9 @@ public static void premain(String args, Instrumentation instrumentation) throws if (component == Component.CE) { redefineEdition(instrumentation, "org.sonar.core.platform.PlatformEditionProvider", redefineOptionalEditionGetMethod()); - redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsEnabledFlag()); + redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsAvailableFlag()); } else if (component == Component.WEB) { - redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsEnabledFlag()); + redefineEdition(instrumentation, "org.sonar.server.almsettings.MultipleAlmFeature", redefineIsAvailableFlag()); redefineEdition(instrumentation, "org.sonar.server.newcodeperiod.ws.SetAction", redefineConstructorEditionProviderField(EditionProvider.Edition.DEVELOPER)); redefineEdition(instrumentation, "org.sonar.server.newcodeperiod.ws.UnsetAction", redefineConstructorEditionProviderField(EditionProvider.Edition.DEVELOPER)); } @@ -102,9 +102,9 @@ private static Redefiner redefineOptionalEditionGetMethod() { }; } - private static Redefiner redefineIsEnabledFlag() { + private static Redefiner redefineIsAvailableFlag() { return ctClass -> { - CtMethod ctMethod = ctClass.getDeclaredMethod("isEnabled"); + CtMethod ctMethod = ctClass.getDeclaredMethod("isAvailable"); ctMethod.setBody("return true;"); }; } diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoader.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoader.java index 7d94f333f..e71671de0 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoader.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Michael Clarke + * Copyright (C) 2020-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,16 +54,13 @@ public class CommunityBranchConfigurationLoader implements BranchConfigurationLo ScannerProperties.PULL_REQUEST_BASE)); private final System2 system2; - private final AnalysisWarnings analysisWarnings; private final BranchConfigurationFactory branchConfigurationFactory; private final List autoConfigurers; - public CommunityBranchConfigurationLoader(System2 system2, AnalysisWarnings analysisWarnings, - BranchConfigurationFactory branchConfigurationFactory, + public CommunityBranchConfigurationLoader(System2 system2, BranchConfigurationFactory branchConfigurationFactory, List autoConfigurers) { super(); this.system2 = system2; - this.analysisWarnings = analysisWarnings; this.branchConfigurationFactory = branchConfigurationFactory; this.autoConfigurers = autoConfigurers; } @@ -94,12 +91,6 @@ public BranchConfiguration load(Map localSettings, ProjectBranch } } - if (null != localSettings.get(ScannerProperties.BRANCH_TARGET)) { //NOSONAR - purposefully checking for a deprecated parameter - String warning = String.format("Property '%s' is no longer supported", ScannerProperties.BRANCH_TARGET); //NOSONAR - reporting use of deprecated parameter - analysisWarnings.addUnique(warning); - LOGGER.warn(warning); - } - if (hasBranchParameters) { String branch = StringUtils.trimToNull(localSettings.get(ScannerProperties.BRANCH_NAME)); return branchConfigurationFactory.createBranchConfiguration(branch, projectBranches); diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtension.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtension.java index 8c69fc6f2..2b15d7032 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtension.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Michael Clarke + * Copyright (C) 2019-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,7 +33,7 @@ public String getName() { } @Override - public boolean isEnabled() { + public boolean isAvailable() { return true; } diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegate.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegate.java index 999d9f25a..6880d4645 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegate.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Michael Clarke + * Copyright (C) 2020-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -94,10 +94,8 @@ public ComponentDto createBranchComponent(DbSession dbSession, BranchSupport.Com ComponentDto componentDto = mainComponentDto.copy() .setUuid(branchUuid) - .setRootUuid(branchUuid) .setBranchUuid(branchUuid) .setUuidPath(ComponentDto.UUID_PATH_OF_ROOT) - .setModuleUuidPath(ComponentDto.UUID_PATH_SEPARATOR + branchUuid + ComponentDto.UUID_PATH_SEPARATOR) .setMainBranchProjectUuid(mainComponentDto.uuid()) .setCreatedAt(new Date(clock.millis())); dbClient.componentDao().insert(dbSession, componentDto); diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeature.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeature.java index 7a455ac49..2e3578c83 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeature.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Michael Clarke + * Copyright (C) 2022-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,7 +32,7 @@ public String getName() { } @Override - public boolean isEnabled() { + public boolean isAvailable() { return true; } } diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgentTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgentTest.java index 28eaa7ee6..4e63e115e 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgentTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/CommunityBranchAgentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Michael Clarke + * Copyright (C) 2021-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -76,7 +76,7 @@ void shouldRedefineMultipleAlmFeatureClassForWebLaunch() throws ReflectiveOperat SonarRuntime sonarRuntime = mock(SonarRuntime.class); SonarQubeFeature multipleAlmFeatureProvider = redefined.getConstructor(SonarRuntime.class).newInstance(sonarRuntime); - assertThat(multipleAlmFeatureProvider.isEnabled()).isTrue(); + assertThat(multipleAlmFeatureProvider.isAvailable()).isTrue(); } } @@ -207,7 +207,7 @@ void shouldRedefineTargetClassesForCeLaunch() throws ReflectiveOperationExceptio Class redefined = (Class) classLoader.loadClass(MultipleAlmFeature.class.getName(), result); SonarQubeFeature multipleAlmFeatureProvider = redefined.getConstructor(SonarRuntime.class).newInstance(sonarRuntime); - assertThat(multipleAlmFeatureProvider.isEnabled()).isTrue(); + assertThat(multipleAlmFeatureProvider.isAvailable()).isTrue(); } } diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoaderTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoaderTest.java index b749fec85..f40ed851c 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoaderTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/scanner/CommunityBranchConfigurationLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Michael Clarke + * Copyright (C) 2020-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,7 +31,6 @@ import java.util.Optional; import org.junit.jupiter.api.Test; -import org.sonar.api.notifications.AnalysisWarnings; import org.sonar.api.utils.System2; import org.sonar.scanner.scan.branch.BranchConfiguration; import org.sonar.scanner.scan.branch.BranchConfigurationLoader; @@ -43,11 +42,10 @@ */ class CommunityBranchConfigurationLoaderTest { - private final AnalysisWarnings analysisWarnings = mock(AnalysisWarnings.class); private final System2 system2 = mock(System2.class); private final BranchConfigurationFactory branchConfigurationFactory = mock(BranchConfigurationFactory.class); private final BranchAutoConfigurer branchAutoConfigurer = mock(BranchAutoConfigurer.class); - private final BranchConfigurationLoader testCase = new CommunityBranchConfigurationLoader(system2, analysisWarnings, branchConfigurationFactory, List.of(branchAutoConfigurer)); + private final BranchConfigurationLoader testCase = new CommunityBranchConfigurationLoader(system2, branchConfigurationFactory, List.of(branchAutoConfigurer)); @Test void shouldReturnResultFromAutoConfigurerIfPresentAndNoParametersSpecified() { @@ -87,7 +85,6 @@ void shouldCreateBranchConfigurationIfAnyBranchPropertiesSet() { assertThat(actual).isSameAs(branchConfiguration); verify(branchConfigurationFactory).createBranchConfiguration("branch", projectBranches); verifyNoInteractions(branchAutoConfigurer); - verify(analysisWarnings).addUnique("Property 'sonar.branch.target' is no longer supported"); } @Test @@ -101,7 +98,6 @@ void shouldCreatePullConfigurationIfAnyPullRequestPropertiesSet() { assertThat(actual).isSameAs(branchConfiguration); verify(branchConfigurationFactory).createPullRequestConfiguration("key", "source", "target", projectBranches); verifyNoInteractions(branchAutoConfigurer); - verifyNoInteractions(analysisWarnings); } @Test diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtensionTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtensionTest.java index eb19ac0c2..e107eb7e4 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtensionTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchFeatureExtensionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2022 Michael Clarke + * Copyright (C) 2019-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,6 +36,6 @@ void shouldReturnNameThatFrontEndLooksFor() { @Test void shouldReturnEnabledForFeature() { - assertThat(underTest.isEnabled()).isTrue(); + assertThat(underTest.isAvailable()).isTrue(); } } diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegateTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegateTest.java index 17c580ccf..af78184a8 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegateTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/CommunityBranchSupportDelegateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Michael Clarke + * Copyright (C) 2020-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -154,9 +154,7 @@ void shouldCreateComponentAndBranchDtoIfValidationPasses(String branchName, Stri when(componentDto.copy()).thenReturn(copyComponentDto); when(copyComponentDto.setBranchUuid(any())).thenReturn(copyComponentDto); when(copyComponentDto.setKey(any())).thenReturn(copyComponentDto); - when(copyComponentDto.setRootUuid(any())).thenReturn(copyComponentDto); when(copyComponentDto.setUuidPath(any())).thenReturn(copyComponentDto); - when(copyComponentDto.setModuleUuidPath(any())).thenReturn(copyComponentDto); when(copyComponentDto.setUuid(any())).thenReturn(copyComponentDto); when(copyComponentDto.setMainBranchProjectUuid(any())).thenReturn(copyComponentDto); when(copyComponentDto.setCreatedAt(any())).thenReturn(copyComponentDto); @@ -187,9 +185,7 @@ void shouldCreateComponentAndBranchDtoIfValidationPasses(String branchName, Stri verify(componentDao).insert(dbSession, copyComponentDto); verify(copyComponentDto).setUuid("uuid0"); - verify(copyComponentDto).setRootUuid("uuid0"); verify(copyComponentDto).setUuidPath("."); - verify(copyComponentDto).setModuleUuidPath(".uuid0."); verify(copyComponentDto).setMainBranchProjectUuid("componentUuid"); verify(copyComponentDto).setCreatedAt(new Date(12345678901234L)); diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeatureTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeatureTest.java index 3cf1582ff..f5879e5c4 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeatureTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/server/MonoRepoFeatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Michael Clarke + * Copyright (C) 2022-2023 Michael Clarke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,7 +33,7 @@ void shouldMatchNameRequiredByFrontEnd() { @Test void shouldSetFeatureAsEnabled() { - assertThat(underTest.isEnabled()).isTrue(); + assertThat(underTest.isAvailable()).isTrue(); } } \ No newline at end of file