ModuleUtils { public static List<Artifact> getAllArtifacts(final Module module){ final List<Artifact> artifacts = new ArrayList<Artifact>(); for(final Module subModule: module.getSubmodules()){ artifacts.addAll(getAllArtifacts(subModule)); } artifacts.addAll(module.getArtifacts()); return artifacts; } private  ModuleUtils(); static List<Artifact> getAllArtifacts(final Module module); static List<Dependency> getAllDependencies(final Module module); static Set<Dependency> getAllDependencies(final Module module, final List<String> producedArtifacts); static List<Dependency> getCorporateDependencies(final Module module, final List<String> corporateFilters); static List<Dependency> getThirdPartyLibraries(final Module module, final List<String> corporateFilters);  }
@Test public void testGetAllTheArtifactsOfAModuleThatHasSubModules(){ final Module module = DataModelFactory.createModule("module1", "1.0.0-SNAPSHOT"); final Module subModule = DataModelFactory.createModule("module11", "1.0.0-SNAPSHOT"); final Module subSubModule = DataModelFactory.createModule("module111", "1.0.0-SNAPSHOT"); module.addSubmodule(subModule); subModule.addSubmodule(subSubModule); final Artifact artifact1 = DataModelFactory.createArtifact("com.my.company", "artifact1", "1.0.0-SNAPSHOT", null, "jar", "jar"); module.addArtifact(artifact1); final Artifact artifact2 = DataModelFactory.createArtifact("com.my.company", "artifact2", "1.0.0-SNAPSHOT", null, "jar", "jar"); subModule.addArtifact(artifact2); final Artifact artifact3 = DataModelFactory.createArtifact("com.my.company", "artifact3", "1.0.0-SNAPSHOT", null, "jar", "jar"); subSubModule.addArtifact(artifact3); final List<Artifact> artifacts = ModuleUtils.getAllArtifacts(module); assertEquals(3, artifacts.size()); assertTrue(artifacts.contains(artifact1)); assertTrue(artifacts.contains(artifact2)); assertTrue(artifacts.contains(artifact3)); }