diff --git a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/ComplexProjectFunctionalTest.java b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/ComplexProjectFunctionalTest.java index 6b563019..5bd6e794 100644 --- a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/ComplexProjectFunctionalTest.java +++ b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/ComplexProjectFunctionalTest.java @@ -113,19 +113,11 @@ public void ensureAlignmentFileCreated() SettingsXpp3Reader settingsXpp3Reader = new SettingsXpp3Reader(); Settings generatedSettings = settingsXpp3Reader.read(reader); List repositories = generatedSettings.getProfiles().get(0).getRepositories(); - - if (GradleVersion.current().compareTo(GradleVersion.version("7.4")) <= 0) { - assertThat(repositories).extracting("url").containsOnly( - "https://repo.maven.apache.org/maven2/", - "https://oss.sonatype.org/content/repositories/snapshots/", - "https://dl.google.com/dl/android/maven2/"); - } else { - assertThat(repositories).extracting("url").containsOnly( - "https://repo.maven.apache.org/maven2/", - "https://plugins.gradle.org/m2", - "https://oss.sonatype.org/content/repositories/snapshots/", - "https://dl.google.com/dl/android/maven2/"); - } + assertThat(repositories).extracting("url").containsOnly( + "https://repo.maven.apache.org/maven2/", + "https://plugins.gradle.org/m2", + "https://oss.sonatype.org/content/repositories/snapshots/", + "https://dl.google.com/dl/android/maven2/"); } } } diff --git a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectFunctionalTest.java b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectFunctionalTest.java index 35e4f070..c58eda52 100644 --- a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectFunctionalTest.java +++ b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectFunctionalTest.java @@ -145,18 +145,12 @@ public void ensureAlignmentFileCreatedAndAlignmentTaskRun() Settings generatedSettings = settingsXpp3Reader.read(reader); List repositories = generatedSettings.getProfiles().get(0).getRepositories(); - if (GradleVersion.current().compareTo(GradleVersion.version("7.4")) <= 0) { - assertThat(repositories).extracting("url") - // should not contain duplicate entries - .containsOnly( - "https://repo.maven.apache.org/maven2/"); - } else { - assertThat(repositories).extracting("url") - // should not contain duplicate entries - .containsOnly( - "https://repo.maven.apache.org/maven2/", - "https://plugins.gradle.org/m2"); - } + assertThat(repositories).extracting("url") + // should not contain duplicate entries + .containsOnly( + "https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven", + "https://repo.maven.apache.org/maven2/", + "https://plugins.gradle.org/m2"); } // make sure the project name was not changed diff --git a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectWithOverridesFunctionalTest.java b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectWithOverridesFunctionalTest.java index 1724c6fb..6340f510 100644 --- a/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectWithOverridesFunctionalTest.java +++ b/analyzer/src/functTest/java/org/jboss/gm/analyzer/alignment/MultiModuleProjectWithOverridesFunctionalTest.java @@ -174,18 +174,11 @@ public void ensureAlignmentFileCreatedAndAlignmentTaskRun() Settings generatedSettings = settingsXpp3Reader.read(reader); List repositories = generatedSettings.getProfiles().get(0).getRepositories(); - if (GradleVersion.current().compareTo(GradleVersion.version("7.4")) <= 0) { - assertThat(repositories).extracting("url") - // should not contain duplicate entries - .containsOnly( - "https://repo.maven.apache.org/maven2/"); - } else { - assertThat(repositories).extracting("url") - // should not contain duplicate entries - .containsOnly( - "https://repo.maven.apache.org/maven2/", - "https://plugins.gradle.org/m2"); - } + assertThat(repositories).extracting("url") + // should not contain duplicate entries + .containsOnly( + "https://repo.maven.apache.org/maven2/", + "https://plugins.gradle.org/m2"); } // make sure the project name was not changed diff --git a/analyzer/src/functTest/resources/multi-module/settings.gradle b/analyzer/src/functTest/resources/multi-module/settings.gradle index b509f4bc..b7f9fd22 100644 --- a/analyzer/src/functTest/resources/multi-module/settings.gradle +++ b/analyzer/src/functTest/resources/multi-module/settings.gradle @@ -1,3 +1,13 @@ + +pluginManagement { + repositories { + maven { + url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven" + } + gradlePluginPortal() + } +} + rootProject.name = 'root' include 'subproject1' include 'subproject1:subproject11' diff --git a/analyzer/src/main/java/org/jboss/gm/analyzer/alignment/AlignmentTask.java b/analyzer/src/main/java/org/jboss/gm/analyzer/alignment/AlignmentTask.java index 2cf09563..4b1f0ef4 100644 --- a/analyzer/src/main/java/org/jboss/gm/analyzer/alignment/AlignmentTask.java +++ b/analyzer/src/main/java/org/jboss/gm/analyzer/alignment/AlignmentTask.java @@ -55,7 +55,9 @@ import org.gradle.api.artifacts.ResolvedDependency; import org.gradle.api.artifacts.UnresolvedDependency; import org.gradle.api.artifacts.repositories.ArtifactRepository; +import org.gradle.api.artifacts.repositories.MavenArtifactRepository; import org.gradle.api.attributes.Attribute; +import org.gradle.api.internal.GradleInternal; import org.gradle.api.internal.artifacts.result.DefaultResolvedDependencyResult; import org.gradle.api.internal.plugins.DefaultPluginManager; import org.gradle.api.logging.Logger; @@ -257,6 +259,15 @@ public void perform() { org.jboss.gm.common.utils.FileUtils.relativize(root, project.getProjectDir().toPath()))); project.getBuildscript().getRepositories().forEach(r -> cache.addRepository(r, org.jboss.gm.common.utils.FileUtils.relativize(root, project.getProjectDir().toPath()))); + // Complete hack due to + // /~https://github.com/gradle/gradle/issues/19711 + // /~https://github.com/gradle/gradle/issues/17295 + // /~https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/1c25db65e0080ee5dcb9f54bd7db2dda4ca80b6c/src/main/java/org/gradlex/javaecosystem/capabilities/BasePluginApplication.java + ((GradleInternal) project.getGradle()).getSettings().getSettings().getPluginManagement().getRepositories().forEach( + r -> { + cache.addRepository(r, + org.jboss.gm.common.utils.FileUtils.relativize(root, project.getProjectDir().toPath())); + }); if (StringUtils.isBlank(groupId) || DEFAULT_VERSION.equals(currentProjectVersion)) { diff --git a/manipulation/src/functTest/resources/multi-module/settings.gradle b/manipulation/src/functTest/resources/multi-module/settings.gradle index d37eb0c2..16d4de1b 100644 --- a/manipulation/src/functTest/resources/multi-module/settings.gradle +++ b/manipulation/src/functTest/resources/multi-module/settings.gradle @@ -1,3 +1,3 @@ rootProject.name = 'root' include 'subproject1' -include 'subproject2' \ No newline at end of file +include 'subproject2'