@@ -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.
0 commit comments