Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCLSUP-1186 Scan settings for repositories #472

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,11 @@ public void ensureAlignmentFileCreated()
SettingsXpp3Reader settingsXpp3Reader = new SettingsXpp3Reader();
Settings generatedSettings = settingsXpp3Reader.read(reader);
List<Repository> 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/");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,12 @@ public void ensureAlignmentFileCreatedAndAlignmentTaskRun()
Settings generatedSettings = settingsXpp3Reader.read(reader);
List<Repository> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,11 @@ public void ensureAlignmentFileCreatedAndAlignmentTaskRun()
Settings generatedSettings = settingsXpp3Reader.read(reader);
List<Repository> 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
Expand Down
10 changes: 10 additions & 0 deletions analyzer/src/functTest/resources/multi-module/settings.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = 'root'
include 'subproject1'
include 'subproject2'
include 'subproject2'
Loading