Skip to content

Commit 3bf794f

Browse files
authored
Merge branch '2.x' into backport/backport-4597-to-2.x
2 parents 7f31b64 + a273f27 commit 3bf794f

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1818
- Add a new node role 'search' which is dedicated to provide search capability ([#4689](https://github.com/opensearch-project/OpenSearch/pull/4689))
1919
- Introduce experimental searchable snapshot API ([#4680](https://github.com/opensearch-project/OpenSearch/pull/4680))
2020
- Introduce Remote translog feature flag([#4158](https://github.com/opensearch-project/OpenSearch/pull/4158))
21+
- Add groupId value propagation tests for ZIP publication task ([#4848](https://github.com/opensearch-project/OpenSearch/pull/4848))
2122
- Add support for GeoJson Point type in GeoPoint field ([#4597](https://github.com/opensearch-project/OpenSearch/pull/4597))
2223

2324
### Dependencies

buildSrc/src/test/java/org/opensearch/gradle/pluginzip/PublishTests.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,76 @@ public void useDefaultValues() throws IOException, URISyntaxException, XmlPullPa
302302
assertEquals(model.getUrl(), "https://github.com/doe/sample-plugin");
303303
}
304304

305+
/**
306+
* If the `group` is defined in gradle's allprojects section then it does not have to defined in publications.
307+
*/
308+
@Test
309+
public void allProjectsGroup() throws IOException, URISyntaxException, XmlPullParserException {
310+
GradleRunner runner = prepareGradleRunnerFromTemplate("allProjectsGroup.gradle", "build", ZIP_PUBLISH_TASK);
311+
BuildResult result = runner.build();
312+
313+
/** Check if build and {@value ZIP_PUBLISH_TASK} tasks have run well */
314+
assertEquals(SUCCESS, result.task(":" + "build").getOutcome());
315+
assertEquals(SUCCESS, result.task(":" + ZIP_PUBLISH_TASK).getOutcome());
316+
317+
// Parse the maven file and validate default values
318+
MavenXpp3Reader reader = new MavenXpp3Reader();
319+
Model model = reader.read(
320+
new FileReader(
321+
new File(
322+
projectDir.getRoot(),
323+
String.join(
324+
File.separator,
325+
"build",
326+
"local-staging-repo",
327+
"org",
328+
"opensearch",
329+
PROJECT_NAME,
330+
"2.0.0.0",
331+
PROJECT_NAME + "-2.0.0.0.pom"
332+
)
333+
)
334+
)
335+
);
336+
assertEquals(model.getVersion(), "2.0.0.0");
337+
assertEquals(model.getGroupId(), "org.opensearch");
338+
}
339+
340+
/**
341+
* The groupId value can be defined on several levels. This tests that the most internal level outweighs other levels.
342+
*/
343+
@Test
344+
public void groupPriorityLevel() throws IOException, URISyntaxException, XmlPullParserException {
345+
GradleRunner runner = prepareGradleRunnerFromTemplate("groupPriorityLevel.gradle", "build", ZIP_PUBLISH_TASK);
346+
BuildResult result = runner.build();
347+
348+
/** Check if build and {@value ZIP_PUBLISH_TASK} tasks have run well */
349+
assertEquals(SUCCESS, result.task(":" + "build").getOutcome());
350+
assertEquals(SUCCESS, result.task(":" + ZIP_PUBLISH_TASK).getOutcome());
351+
352+
// Parse the maven file and validate default values
353+
MavenXpp3Reader reader = new MavenXpp3Reader();
354+
Model model = reader.read(
355+
new FileReader(
356+
new File(
357+
projectDir.getRoot(),
358+
String.join(
359+
File.separator,
360+
"build",
361+
"local-staging-repo",
362+
"level",
363+
"3",
364+
PROJECT_NAME,
365+
"2.0.0.0",
366+
PROJECT_NAME + "-2.0.0.0.pom"
367+
)
368+
)
369+
)
370+
);
371+
assertEquals(model.getVersion(), "2.0.0.0");
372+
assertEquals(model.getGroupId(), "level.3");
373+
}
374+
305375
/**
306376
* In this case the Publication entity is completely missing but still the POM file is generated using the default
307377
* values including the groupId and version values obtained from the Gradle project object.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id 'java-gradle-plugin'
3+
id 'opensearch.pluginzip'
4+
}
5+
6+
version='2.0.0.0'
7+
8+
// A bundlePlugin task mockup
9+
tasks.register('bundlePlugin', Zip.class) {
10+
archiveFileName = "sample-plugin-${version}.zip"
11+
destinationDirectory = layout.buildDirectory.dir('distributions')
12+
from layout.projectDirectory.file('sample-plugin-source.txt')
13+
}
14+
15+
allprojects {
16+
group = 'org.opensearch'
17+
}
18+
19+
publishing {
20+
publications {
21+
pluginZip(MavenPublication) { publication ->
22+
pom {
23+
name = "sample-plugin"
24+
description = "pluginDescription"
25+
}
26+
}
27+
}
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
plugins {
2+
id 'java-gradle-plugin'
3+
id 'opensearch.pluginzip'
4+
}
5+
6+
version='2.0.0.0'
7+
8+
// A bundlePlugin task mockup
9+
tasks.register('bundlePlugin', Zip.class) {
10+
archiveFileName = "sample-plugin-${version}.zip"
11+
destinationDirectory = layout.buildDirectory.dir('distributions')
12+
from layout.projectDirectory.file('sample-plugin-source.txt')
13+
}
14+
15+
allprojects {
16+
group = 'level.1'
17+
}
18+
19+
publishing {
20+
publications {
21+
pluginZip(MavenPublication) { publication ->
22+
groupId = "level.2"
23+
pom {
24+
name = "sample-plugin"
25+
description = "pluginDescription"
26+
groupId = "level.3"
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)