Skip to content

Commit f086e7d

Browse files
committed
remove redandunt fallback logic
1 parent ec77f59 commit f086e7d

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

internal/librarian/java/generate_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ func TestGenerate_Logic(t *testing.T) {
677677
Libraries: []*config.Library{
678678
library,
679679
{Name: rootLibrary, Version: "1.2.3"},
680+
{Name: parentPOM, Version: "1.2.3"},
680681
},
681682
}
682683
// Setup mandatory files for postProcessAPI and syncPOMs
@@ -753,6 +754,7 @@ func TestGenerate_ProtoExclusion(t *testing.T) {
753754
Libraries: []*config.Library{
754755
library,
755756
{Name: rootLibrary, Version: "1.2.3"},
757+
{Name: parentPOM, Version: "1.2.3"},
756758
},
757759
}
758760
err := Generate(t.Context(), cfg, library, &sources.Sources{Googleapis: googleapisDir})

internal/librarian/java/pom.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,13 @@ func findMonorepoVersion(cfg *config.Config) (string, error) {
526526
return "", errMonorepoVersion
527527
}
528528

529+
// TODO(https://github.com/googleapis/librarian/issues/6411):
530+
// Simplify logic here and check at validate step.
529531
func findParentPOMVersion(cfg *config.Config) (string, error) {
530532
for _, lib := range cfg.Libraries {
531533
if lib.Name == parentPOM {
532534
return lib.Version, nil
533535
}
534536
}
535-
// Fallback to monorepoVersion if google-cloud-pom-parent is missing (e.g. in tests)
536-
for _, lib := range cfg.Libraries {
537-
if lib.Name == rootLibrary {
538-
return lib.Version, nil
539-
}
540-
}
541537
return "", errParentVersion
542538
}

internal/librarian/java/postgenerate_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestPostGenerate(t *testing.T) {
4141
Language: "java",
4242
Libraries: []*config.Library{
4343
{Name: rootLibrary, Version: "1.2.3"},
44+
{Name: parentPOM, Version: "1.2.3"},
4445
{Name: "analytics-admin", Version: "0.98.0"},
4546
{Name: "area120-tables", Version: "0.92.0"},
4647
{Name: "aiplatform", Version: "3.89.0"},
@@ -196,6 +197,7 @@ func TestPostGenerate_SearchError(t *testing.T) {
196197
cfg := &config.Config{
197198
Libraries: []*config.Library{
198199
{Name: rootLibrary, Version: "1.2.3"},
200+
{Name: parentPOM, Version: "1.2.3"},
199201
},
200202
}
201203
err := PostGenerate(t.Context(), tmpDir, cfg, nil)
@@ -215,6 +217,7 @@ func TestPostGenerate_Error(t *testing.T) {
215217
cfg := &config.Config{
216218
Libraries: []*config.Library{
217219
{Name: rootLibrary, Version: "1.2.3"},
220+
{Name: parentPOM, Version: "1.2.3"},
218221
},
219222
}
220223
err := PostGenerate(t.Context(), tmpDir, cfg, nil)

internal/librarian/java/postprocess_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ func TestPostProcessLibrary(t *testing.T) {
520520
defaultCfg := &config.Config{
521521
Libraries: []*config.Library{
522522
{Name: rootLibrary, Version: "1.0.0"},
523+
{Name: parentPOM, Version: "1.0.0"},
523524
},
524525
Default: &config.Default{
525526
Java: &config.JavaModule{
@@ -621,6 +622,7 @@ func TestPostProcessLibrary_ErrorCase(t *testing.T) {
621622
defaultCfg := &config.Config{
622623
Libraries: []*config.Library{
623624
{Name: rootLibrary, Version: "1.0.0"},
625+
{Name: parentPOM, Version: "1.0.0"},
624626
},
625627
Default: &config.Default{
626628
Java: &config.JavaModule{

0 commit comments

Comments
 (0)