Skip to content

Commit

Permalink
MavenJDOMWriter: apply POM convention to ordering POM elements
Browse files Browse the repository at this point in the history
And add missing snapshots and releases policies for deployment repositories
  • Loading branch information
murdos committed Feb 23, 2024
1 parent a56a10a commit 9f8ded4
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 275 deletions.
48 changes: 25 additions & 23 deletions src/main/java/io/fabric8/maven/MavenJDOMWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,8 @@ protected void updateDeploymentRepository(DeploymentRepository value, String xml
Element root = updateElement(counter, element, xmlTag, shouldExist);
if (shouldExist) {
Counter innerCount = new Counter(counter.getDepth() + 1);
updateRepositoryPolicy(value.getReleases(), "releases", innerCount, root);
updateRepositoryPolicy(value.getSnapshots(), "snapshots", innerCount, root);
findAndReplaceSimpleElement(innerCount, root, "uniqueVersion",
(value.isUniqueVersion()) ? null : String.valueOf(value.isUniqueVersion()), "true");
findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null);
Expand Down Expand Up @@ -1510,36 +1512,36 @@ protected void updateMailingList(MailingList value, String xmlTag, Counter count
protected void updateModel(Model value, String xmlTag, Counter counter, Element element) {
Element root = element;
Counter innerCount = new Counter(counter.getDepth() + 1);
updateParent(value.getParent(), "parent", innerCount, root);
findAndReplaceSimpleElement(innerCount, root, "modelVersion", value.getModelVersion(), null);
updateParent(value.getParent(), "parent", innerCount, root);
findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
findAndReplaceSimpleElement(innerCount, root, "packaging", value.getPackaging(), "jar");
findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null);
findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
findAndReplaceSimpleElement(innerCount, root, "description", value.getDescription(), null);
findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null);
updatePrerequisites(value.getPrerequisites(), "prerequisites", innerCount, root);
updateIssueManagement(value.getIssueManagement(), "issueManagement", innerCount, root);
updateCiManagement(value.getCiManagement(), "ciManagement", innerCount, root);
findAndReplaceSimpleElement(innerCount, root, "inceptionYear", value.getInceptionYear(), null);
iterateMailingList(innerCount, root, value.getMailingLists(), "mailingLists", "mailingList");
updateOrganization(value.getOrganization(), "organization", innerCount, root);
iterateLicense(innerCount, root, value.getLicenses(), "licenses", "license");
iterateDeveloper(innerCount, root, value.getDevelopers(), "developers", "developer");
iterateContributor(innerCount, root, value.getContributors(), "contributors", "contributor");
iterateLicense(innerCount, root, value.getLicenses(), "licenses", "license");
updateScm(value.getScm(), "scm", innerCount, root);
updateOrganization(value.getOrganization(), "organization", innerCount, root);
updateBuild(value.getBuild(), "build", innerCount, root);
iterateProfile(innerCount, root, value.getProfiles(), "profiles", "profile");
iterateMailingList(innerCount, root, value.getMailingLists(), "mailingLists", "mailingList");
updatePrerequisites(value.getPrerequisites(), "prerequisites", innerCount, root);
findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module");
updateScm(value.getScm(), "scm", innerCount, root);
updateIssueManagement(value.getIssueManagement(), "issueManagement", innerCount, root);
updateCiManagement(value.getCiManagement(), "ciManagement", innerCount, root);
updateDistributionManagement(value.getDistributionManagement(), "distributionManagement", innerCount, root);
findAndReplaceProperties(innerCount, root, "properties", value.getProperties());
updateDependencyManagement(value.getDependencyManagement(), "dependencyManagement", innerCount, root);
iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
iterateRepository(innerCount, root, value.getRepositories(), "repositories", "repository");
iterateRepository(innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository");
iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
updateBuild(value.getBuild(), "build", innerCount, root);
findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom) value.getReports());
updateReporting(value.getReporting(), "reporting", innerCount, root);
updateDependencyManagement(value.getDependencyManagement(), "dependencyManagement", innerCount, root);
updateDistributionManagement(value.getDistributionManagement(), "distributionManagement", innerCount, root);
findAndReplaceProperties(innerCount, root, "properties", value.getProperties());
iterateProfile(innerCount, root, value.getProfiles(), "profiles", "profile");
} // -- void updateModel(Model, String, Counter, Element)

/**
Expand Down Expand Up @@ -1623,8 +1625,8 @@ protected void updateParent(Parent value, String xmlTag, Counter counter, Elemen
Element root = updateElement(counter, element, xmlTag, shouldExist);
if (shouldExist) {
Counter innerCount = new Counter(counter.getDepth() + 1);
findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
findAndReplaceSimpleElement(innerCount, root, "relativePath", value.getRelativePath(), "../pom.xml");
}
Expand Down Expand Up @@ -1778,14 +1780,14 @@ protected void updateProfile(Profile value, String xmlTag, Counter counter, Elem
updateActivation(value.getActivation(), "activation", innerCount, root);
updateBuildBase(value.getBuild(), "build", innerCount, root);
findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module");
updateDistributionManagement(value.getDistributionManagement(), "distributionManagement", innerCount, root);
findAndReplaceProperties(innerCount, root, "properties", value.getProperties());
updateDependencyManagement(value.getDependencyManagement(), "dependencyManagement", innerCount, root);
iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
iterateRepository(innerCount, root, value.getRepositories(), "repositories", "repository");
iterateRepository(innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository");
iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom) value.getReports());
updateReporting(value.getReporting(), "reporting", innerCount, root);
updateDependencyManagement(value.getDependencyManagement(), "dependencyManagement", innerCount, root);
updateDistributionManagement(value.getDistributionManagement(), "distributionManagement", innerCount, root);
findAndReplaceProperties(innerCount, root, "properties", value.getProperties());
} // -- void updateProfile(Profile, String, Counter, Element)

/**
Expand Down Expand Up @@ -1842,9 +1844,9 @@ protected void updateReportPlugin(ReportPlugin value, String xmlTag, Counter cou
findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins");
findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
iterateReportSet(innerCount, root, value.getReportSets(), "reportSets", "reportSet");
findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
iterateReportSet(innerCount, root, value.getReportSets(), "reportSets", "reportSet");
} // -- void updateReportPlugin(ReportPlugin, String, Counter, Element)

/**
Expand All @@ -1859,9 +1861,9 @@ protected void updateReportSet(ReportSet value, String xmlTag, Counter counter,
Element root = element;
Counter innerCount = new Counter(counter.getDepth() + 1);
findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), "default");
findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
findAndReplaceSimpleLists(innerCount, root, value.getReports(), "reports", "report");
findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
} // -- void updateReportSet(ReportSet, String, Counter, Element)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
<distributionManagement>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>string</updatePolicy>
<checksumPolicy>string</checksumPolicy>
</releases>
Expand All @@ -128,7 +127,6 @@
<checksumPolicy>string</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>string</updatePolicy>
<checksumPolicy>string</checksumPolicy>
</snapshots>
Expand Down Expand Up @@ -553,7 +551,6 @@
<distributionManagement>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>string</updatePolicy>
<checksumPolicy>string</checksumPolicy>
</releases>
Expand All @@ -574,7 +571,6 @@
<checksumPolicy>string</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>string</updatePolicy>
<checksumPolicy>string</checksumPolicy>
</snapshots>
Expand Down
Loading

0 comments on commit 9f8ded4

Please sign in to comment.