build: scope private repository to legacy xinda
This commit is contained in:
@@ -122,6 +122,16 @@ class MavenModuleProfileTest {
|
||||
"modules/apps/xinda-push-app");
|
||||
}
|
||||
|
||||
@Test
|
||||
void privateLingniuRepositoryIsScopedToLegacyXindaProfile() throws Exception {
|
||||
Document pom = rootPom();
|
||||
|
||||
assertThat(repositoryIds(pom.getDocumentElement()))
|
||||
.doesNotContain("lingniu-nexus");
|
||||
assertThat(profileRepositoryIds(pom, "legacy-xinda"))
|
||||
.containsExactly("lingniu-nexus");
|
||||
}
|
||||
|
||||
@Test
|
||||
void optionalModuleVersionsAreScopedToTheirProfiles() throws Exception {
|
||||
Document pom = rootPom();
|
||||
@@ -423,6 +433,33 @@ class MavenModuleProfileTest {
|
||||
return dependencyManagementArtifacts(profile);
|
||||
}
|
||||
|
||||
private static List<String> profileRepositoryIds(Document pom, String profileId) {
|
||||
Element profile = profile(pom, profileId);
|
||||
if (profile == null) {
|
||||
return List.of();
|
||||
}
|
||||
return repositoryIds(profile);
|
||||
}
|
||||
|
||||
private static List<String> repositoryIds(Element owner) {
|
||||
Element repositories = firstDirectChild(owner, "repositories");
|
||||
if (repositories == null) {
|
||||
return List.of();
|
||||
}
|
||||
List<String> ids = new ArrayList<>();
|
||||
NodeList children = repositories.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
if (!(children.item(i) instanceof Element repository) || !"repository".equals(repository.getTagName())) {
|
||||
continue;
|
||||
}
|
||||
Element id = firstDirectChild(repository, "id");
|
||||
if (id != null) {
|
||||
ids.add(id.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
return List.copyOf(ids);
|
||||
}
|
||||
|
||||
private static Element profile(Document pom, String profileId) {
|
||||
Element profiles = firstDirectChild(pom.getDocumentElement(), "profiles");
|
||||
if (profiles == null) {
|
||||
|
||||
Reference in New Issue
Block a user