Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url (#2086)
* Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Adding test to check if correct IVY repos were added Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Adding another test case when custom url is not passed and documenting usage of this in Developer Guide Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Adding TOC and making changes in DEVELOPER_GUIDE Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Making changes in DEVELOPER_GUIDE about Distribution Download plugin Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
This commit is contained in:
parent
f703de9394
commit
4a6f54bdeb
|
@ -33,6 +33,8 @@
|
||||||
- [runtimeOnly](#runtimeonly)
|
- [runtimeOnly](#runtimeonly)
|
||||||
- [compileOnly](#compileonly)
|
- [compileOnly](#compileonly)
|
||||||
- [testImplementation](#testimplementation)
|
- [testImplementation](#testimplementation)
|
||||||
|
- [Gradle Plugins](#gradle-plugins)
|
||||||
|
- [Distribution Download Plugin](#distribution-download-plugin)
|
||||||
- [Misc](#misc)
|
- [Misc](#misc)
|
||||||
- [git-secrets](#git-secrets)
|
- [git-secrets](#git-secrets)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
|
@ -340,6 +342,15 @@ somehow. OpenSearch plugins use this configuration to include dependencies that
|
||||||
Code that is on the classpath for compiling tests that are part of this project but not production code. The canonical example
|
Code that is on the classpath for compiling tests that are part of this project but not production code. The canonical example
|
||||||
of this is `junit`.
|
of this is `junit`.
|
||||||
|
|
||||||
|
### Gradle Plugins
|
||||||
|
|
||||||
|
#### Distribution Download Plugin
|
||||||
|
|
||||||
|
The Distribution Download plugin downloads the latest version of OpenSearch by default, and supports overriding this behavior by setting `customDistributionUrl`.
|
||||||
|
```
|
||||||
|
./gradlew integTest -DcustomDistributionUrl="https://ci.opensearch.org/ci/dbc/bundle-build/1.2.0/1127/linux/x64/dist/opensearch-1.2.0-linux-x64.tar.gz"
|
||||||
|
```
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
|
||||||
### git-secrets
|
### git-secrets
|
||||||
|
|
|
@ -105,7 +105,6 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
setupResolutionsContainer(project);
|
setupResolutionsContainer(project);
|
||||||
setupDistributionContainer(project, dockerSupport);
|
setupDistributionContainer(project, dockerSupport);
|
||||||
setupDownloadServiceRepo(project);
|
|
||||||
project.afterEvaluate(this::setupDistributions);
|
project.afterEvaluate(this::setupDistributions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +152,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||||
dependencies.add(distribution.getExtracted().getName(), distributionDependency.getExtractedNotation());
|
dependencies.add(distribution.getExtracted().getName(), distributionDependency.getExtractedNotation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setupDownloadServiceRepo(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionDependency resolveDependencyNotation(Project p, OpenSearchDistribution distribution) {
|
private DistributionDependency resolveDependencyNotation(Project p, OpenSearchDistribution distribution) {
|
||||||
|
@ -195,16 +195,22 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
|
||||||
if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) {
|
if (project.getRepositories().findByName(DOWNLOAD_REPO_NAME) != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addIvyRepo(
|
Object customDistributionUrl = project.findProperty("customDistributionUrl");
|
||||||
project,
|
// checks if custom Distribution Url has been passed by user from plugins
|
||||||
DOWNLOAD_REPO_NAME,
|
if (customDistributionUrl != null) {
|
||||||
"https://artifacts.opensearch.org",
|
addIvyRepo(project, DOWNLOAD_REPO_NAME, customDistributionUrl.toString(), FAKE_IVY_GROUP, "");
|
||||||
FAKE_IVY_GROUP,
|
addIvyRepo(project, SNAPSHOT_REPO_NAME, customDistributionUrl.toString(), FAKE_SNAPSHOT_IVY_GROUP, "");
|
||||||
"/releases" + RELEASE_PATTERN_LAYOUT,
|
} else {
|
||||||
"/release-candidates" + RELEASE_PATTERN_LAYOUT
|
addIvyRepo(
|
||||||
);
|
project,
|
||||||
|
DOWNLOAD_REPO_NAME,
|
||||||
addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://artifacts.opensearch.org", FAKE_SNAPSHOT_IVY_GROUP, SNAPSHOT_PATTERN_LAYOUT);
|
"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, 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);
|
addIvyRepo2(project, SNAPSHOT_REPO_NAME_ES, "https://snapshots-no-kpi.elastic.co", FAKE_SNAPSHOT_IVY_GROUP_ES);
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.opensearch.gradle.info.BuildParams;
|
||||||
import org.opensearch.gradle.test.GradleUnitTestCase;
|
import org.opensearch.gradle.test.GradleUnitTestCase;
|
||||||
import org.gradle.api.NamedDomainObjectContainer;
|
import org.gradle.api.NamedDomainObjectContainer;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository;
|
||||||
import org.gradle.testfixtures.ProjectBuilder;
|
import org.gradle.testfixtures.ProjectBuilder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -79,6 +80,58 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
|
||||||
assertEquals(distro.getVersion(), VersionProperties.getOpenSearch());
|
assertEquals(distro.getVersion(), VersionProperties.getOpenSearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCustomDistributionUrlWithUrl() {
|
||||||
|
Project project = createProject(null, false);
|
||||||
|
String customUrl = "https://artifacts.opensearch.org/custom";
|
||||||
|
project.getExtensions().getExtraProperties().set("customDistributionUrl", customUrl);
|
||||||
|
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
|
||||||
|
plugin.setupDistributions(project);
|
||||||
|
assertEquals(4, project.getRepositories().size());
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(),
|
||||||
|
customUrl
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(),
|
||||||
|
customUrl
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(),
|
||||||
|
"https://artifacts-no-kpi.elastic.co"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(),
|
||||||
|
"https://snapshots-no-kpi.elastic.co"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCustomDistributionUrlWithoutUrl() {
|
||||||
|
Project project = createProject(null, false);
|
||||||
|
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
|
||||||
|
plugin.setupDistributions(project);
|
||||||
|
assertEquals(5, project.getRepositories().size());
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(),
|
||||||
|
"https://artifacts.opensearch.org"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads2")).getUrl().toString(),
|
||||||
|
"https://artifacts.opensearch.org"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(),
|
||||||
|
"https://artifacts.opensearch.org"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(),
|
||||||
|
"https://artifacts-no-kpi.elastic.co"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(),
|
||||||
|
"https://snapshots-no-kpi.elastic.co"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void testBadVersionFormat() {
|
public void testBadVersionFormat() {
|
||||||
assertDistroError(
|
assertDistroError(
|
||||||
createProject(null, false),
|
createProject(null, false),
|
||||||
|
|
Loading…
Reference in New Issue