Skip to content

Commit

Permalink
Accidently made commit to main branch, this revives it.Override defau…
Browse files Browse the repository at this point in the history
…lt Distribution Download URL with custom Distribution URL

Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
  • Loading branch information
Rishikesh1159 committed Feb 10, 2022
1 parent f2555cc commit 730c958
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void apply(Project project) {

setupResolutionsContainer(project);
setupDistributionContainer(project, dockerSupport);
setupDownloadServiceRepo(project);
project.afterEvaluate(this::setupDistributions);
}

Expand Down Expand Up @@ -152,7 +153,6 @@ void setupDistributions(Project project) {
dependencies.add(distribution.getExtracted().getName(), distributionDependency.getExtractedNotation());
}
}
setupDownloadServiceRepo(project);
}

private DistributionDependency resolveDependencyNotation(Project p, OpenSearchDistribution distribution) {
Expand All @@ -176,10 +176,6 @@ private static void addIvyRepo(Project project, String name, String url, String
exclusiveContentRepository.filter(config -> config.includeGroup(group));
exclusiveContentRepository.forRepositories(repos.toArray(new IvyArtifactRepository[repos.size()]));
});
//set testCustomDistributionUrlProperty with url passed as parameter
if(project.findProperty("customDistributionUrl") != null) {
project.getExtensions().getExtraProperties().set("testCustomDistributionUrlProperty", url);
}
}

private static void addIvyRepo2(Project project, String name, String url, String group) {
Expand All @@ -199,22 +195,16 @@ private static void setupDownloadServiceRepo(Project project) {
if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) {
return;
}
Object customDistributionUrl = project.findProperty("customDistributionUrl");
// checks if custom Distribution Url has been passed by user from plugins
if (customDistributionUrl != null) {
addIvyRepo(project, DOWNLOAD_REPO_NAME, customDistributionUrl.toString(), FAKE_IVY_GROUP, "");
addIvyRepo(project, SNAPSHOT_REPO_NAME, customDistributionUrl.toString(), FAKE_SNAPSHOT_IVY_GROUP, "");
} else {
addIvyRepo(
project,
DOWNLOAD_REPO_NAME,
"https://artifacts.opensearch.org",
FAKE_IVY_GROUP,
"/releases" + RELEASE_PATTERN_LAYOUT,
"/release-candidates" + RELEASE_PATTERN_LAYOUT
);
addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://artifacts.opensearch.org", FAKE_SNAPSHOT_IVY_GROUP, SNAPSHOT_PATTERN_LAYOUT);
}
addIvyRepo(
project,
DOWNLOAD_REPO_NAME,
"https://artifacts.opensearch.org",
FAKE_IVY_GROUP,
"/releases" + RELEASE_PATTERN_LAYOUT,
"/release-candidates" + RELEASE_PATTERN_LAYOUT
);

addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://artifacts.opensearch.org", FAKE_SNAPSHOT_IVY_GROUP, SNAPSHOT_PATTERN_LAYOUT);

addIvyRepo2(project, DOWNLOAD_REPO_NAME_ES, "https://artifacts-no-kpi.elastic.co", FAKE_IVY_GROUP_ES);
addIvyRepo2(project, SNAPSHOT_REPO_NAME_ES, "https://snapshots-no-kpi.elastic.co", FAKE_SNAPSHOT_IVY_GROUP_ES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.gradle.testfixtures.ProjectBuilder;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.TreeSet;

Expand Down Expand Up @@ -80,27 +79,6 @@ public void testVersionDefault() {
assertEquals(distro.getVersion(), VersionProperties.getOpenSearch());
}

public void testCustomDistributionUrlForNull() {
Project project = createProject(null, false);
assertNull(project.findProperty("customDistributionUrl"));
}

public void testCustomDistributionUrlWithUrl() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Project project = createProject(null, false);
String customUrl = "https://artifacts.opensearch.org";
project.getExtensions().getExtraProperties().set("customDistributionUrl", customUrl);
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
plugin.setupDistributions(project);
assertEquals(project.property("testCustomDistributionUrlProperty").toString(), "https://artifacts.opensearch.org");
}

public void testCustomDistributionUrlWithoutUrl(){
Project project = createProject(null, false);
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
plugin.setupDistributions(project);
assertFalse(project.hasProperty("testCustomDistributionUrlProperty"));
}

public void testBadVersionFormat() {
assertDistroError(
createProject(null, false),
Expand Down

0 comments on commit 730c958

Please sign in to comment.