fix(java): use true as default value for Repository Release|Snapshot Enabled in pom.xml and settings.xml files (#9751)

This commit is contained in:
DmitriyLewen
2025-11-10 19:51:56 +06:00
committed by GitHub
parent 0487d8efd8
commit d87d9b97d1
3 changed files with 12 additions and 13 deletions

View File

@@ -31,8 +31,10 @@ func resolvePomRepos(servers []Server, pomRepos []pomRepository) []repository {
var repos []repository
for _, rep := range pomRepos {
r := repository{
releaseEnabled: rep.ReleasesEnabled == "true",
snapshotEnabled: rep.SnapshotsEnabled == "true",
// "<enabled>: true or false for whether this repository is enabled for the respective type (releases or snapshots). By default, this is true."
// cf. https://maven.apache.org/pom.html#Repositories
releaseEnabled: rep.ReleasesEnabled == "true" || rep.ReleasesEnabled == "",
snapshotEnabled: rep.SnapshotsEnabled == "true" || rep.SnapshotsEnabled == "",
}
// Add only enabled repositories

View File

@@ -43,7 +43,7 @@ func Test_ReadSettings(t *testing.T) {
{
ID: "mycompany-internal-releases",
URL: "https://mycompany.example.com/repository/internal-releases",
ReleasesEnabled: "true",
ReleasesEnabled: "",
SnapshotsEnabled: "false",
},
{
@@ -342,16 +342,16 @@ func Test_effectiveRepositories(t *testing.T) {
ID: "p1",
Repositories: []pomRepository{
{
ID: "r1",
URL: "https://example.com/repo1",
ReleasesEnabled: "true",
ID: "r1",
URL: "https://example.com/repo1",
// ReleasesEnabled: "true", Release field is not explicitly set.
SnapshotsEnabled: "false",
},
{
ID: "r2",
URL: "https://example.com/repo2",
ReleasesEnabled: "false",
SnapshotsEnabled: "true",
ID: "r2",
URL: "https://example.com/repo2",
ReleasesEnabled: "invalid", // invalid value treated as false
// SnapshotsEnabled: "true", Snapshot field is not explicitly set.
},
},
},

View File

@@ -25,9 +25,6 @@
<repository>
<id>mycompany-internal-releases</id>
<url>https://mycompany.example.com/repository/internal-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>