ModuleAnalyzer { public List<ArtifactSpec> getDependencies() { if (this.module == null) { return Collections.emptyList(); } List<ArtifactType<ResourcesType<ModuleDescriptor>>> artifacts = this.module.getOrCreateResources().getAllArtifact(); List<ArtifactSpec> dependencies = new ArrayList<>(); String localRepo = System.getProperty("maven.repo.local", DEFAULT_LOCAL_REPO); for (ArtifactType<ResourcesType<ModuleDescriptor>> artifact : artifacts) { ArtifactSpec dep = ArtifactSpec.fromMscGav(artifact.getName()); File file = Paths.get(localRepo, dep.jarRepoPath()).toFile(); if (!file.exists()) { dep.shouldGather = true; } else { dep.file = file; dep.shouldGather = false; } dependencies.add(dep); } return dependencies; } ModuleAnalyzer(File f);  ModuleAnalyzer(Path p);  ModuleAnalyzer(InputStream in); String getName(); String getSlot(); List<ArtifactSpec> getDependencies();  }
@Test public void testAnalysis() throws Exception { InputStream moduleXml = getClass().getClassLoader().getResourceAsStream("module.xml"); ModuleAnalyzer analyzer = new ModuleAnalyzer(moduleXml); assertThat(analyzer.getDependencies()).hasSize(2); List<String> gavs = analyzer.getDependencies().stream().map(e -> e.mscGav()).collect(Collectors.toList()); assertThat(gavs).contains("org.wildfly.core:wildfly-version:1.0.0.Final"); assertThat(gavs).contains("org.wildfly.common:wildfly-common:1.0.0.Final"); assertThat(analyzer.getDependencies().stream().allMatch(e -> e.shouldGather)); }
@Test public void testAvoidAliases() throws IOException { InputStream moduleXml = getClass().getClassLoader().getResourceAsStream("alias-module.xml"); ModuleAnalyzer analyzer = new ModuleAnalyzer(moduleXml); assertThat(analyzer.getDependencies()).hasSize(0); }